int misc_register(struct miscdevice * misc);
struct miscdevice {
int minor;
const char *name;
const struct file_operations *fops;
struct list_head list;
struct device *parent;
struct device *this_device;
const char *nodename;
mode_t mode;
};
=============================================
drv_read()
{
}
drv_write()
{
}
drv_open()
{
}
drv_release()
{
}
static const struct file_operations fops = {
.read = drv_read,
.write = drv_write,
.open = drv_open,
.release = drv_release,
};
static struct miscdevice miscdev = {
.minor = 0,
.name = "demo_misc",
.fops = &fops,
};
int init(void)
{
return misc_register(&miscdev);
}
void exit(void)
{
misc_deregister(&miscdev);
}
struct miscdevice {
int minor;
const char *name;
const struct file_operations *fops;
struct list_head list;
struct device *parent;
struct device *this_device;
const char *nodename;
mode_t mode;
};
=============================================
drv_read()
{
}
drv_write()
{
}
drv_open()
{
}
drv_release()
{
}
static const struct file_operations fops = {
.read = drv_read,
.write = drv_write,
.open = drv_open,
.release = drv_release,
};
static struct miscdevice miscdev = {
.minor = 0,
.name = "demo_misc",
.fops = &fops,
};
int init(void)
{
return misc_register(&miscdev);
}
void exit(void)
{
misc_deregister(&miscdev);
}