- 论坛徽章:
- 0
|
LDM5 STUDY:
Today we come to the ldm5,in the ldm5 the subsystem conception has been carried out ! The subsystem offers a general interface for the applications and low level drivers.When a application works, it calls the subsystem's general interface applications,and then the subsystem calls the functions(drivers) that you write.In the linux kernel almost every kind of devices has a corresponding subsystem.
There also is a subsystem in ldm5:
static struct file_operations file_operation = {
.owner = THIS_MODULE,
.open = lmd5_open,
.read = lmd5_read,
.write = lmd5_write,
.release = lmd5_close,
};
static struct lmd_dev{
dev_t dev_id;
int (*open)(struct lmd_dev * lmd_dev);
int (*close)(struct lmd_dev * lmd_dev);
int (*read)(struct lmd_dev *, char *buff);
int (*write)(struct lmd_dev *,const char *buff);
};
static int lmd5_open(struct inode * inodep, struct file * filep)
{
struct lmd_dev *lmd = lmd_devs[iminor(inodep)];
filep->private_data = lmd;
printk("%s()\n", __FUNCTION__);
return (lmd->open(lmd));
// return 0;
}
When the application calls the open(....) function, it will call the lmd5_open(....) which calls lmd->open(lmd) that you write in the drivers. |
|