Note
分类
最新文章
回复
站点统计
3.1 i
Algorithm代表了当前I
struct i
char name[32]; //算法名称
unsigned int id; //算法ID
//master_xfer提供的是i
int (*master_xfer)(struct i
int num);
// smbus_xfer提供i
int (*smbus_xfer) (struct i
unsigned short flags, char read_write,
u8 command, int size, union i
/* 从机模式,通常adapter不会做从机*/
int (*slave_send)(struct i
int (*slave_recv)(struct i
/* 类似于ioctl,实现一些设定控制功能 */
int (*algo_control)(struct i
/* I
u32 (*functionality) (struct i
};
3.2 struct i
struct i
char name[32]; /* 适配器的名字*/
unsigned int id;/* == is algo->id | hwdep.struct->id, */
/* for registered values see below */
struct i
void *algo_data; /*使用标准算法时,提供算法需要的特殊函数入口*/
/* --- These may be NULL, but should increase the module use count */
void (*inc_use)(struct i
void (*dec_use)(struct i
/* --- administration stuff. */
int (*client_register)(struct i
int (*client_unregister)(struct i
void *data; /* private data for the adapter */
/* some data fields that are used by all types */
/* these data fields are readonly to the public */
/* and can be set via the i
/* data fields that are valid for all devices */
struct semaphore lock;
unsigned int flags;/* flags specifying div. data */
struct i
int client_count;
int timeout; //超时时间
int retries; //重试次数
#ifdef CONFIG_PROC_FS
/* No need to set this when you initialize the adapter */
int inode;
#endif /* def CONFIG_PROC_FS */
}
3.3 i
struct i
char name[32]; //驱动的名称
int id; //驱动的ID
unsigned int flags; /* div., see below */
/* 寻找当前client对应的adapter是否存在。
若存在,调用i
*/
int (*attach_adapter)(struct i
/* tells the driver that a client is about to be deleted & gives it
* the chance to remove its private data. Also, if the client struct
* has been dynamically allocated by the driver in the function above,
* it must be freed here.
*/
int (*detach_client)(struct i
/* a ioctl like command that can be used to perform specific functions
* with the device.
*/
int (*command)(struct i
/* These two are mainly used for bookkeeping & dynamic unloading of
* kernel modules. inc_use tells the driver that a client is being
* used by another module & that it should increase its ref. counter.
* dec_use is the inverse operation.
* NB: Make sure you have no circular dependencies, or else you get a
* deadlock when trying to unload the modules.
* You should use the i
* calling this function directly.
*/
void (*inc_use)(struct i
void (*dec_use)(struct i
3.4 i
/*
* i
* i
* function is mainly used for lookup & other admin. functions.
*/
struct i
char name[32]; //client 名字
int id; //client ID
unsigned int flags; /* div., see below */
unsigned int addr; /* client地址: 7bit */
/* addresses are stored in the */
/* _LOWER_ 7 bits of this char */
/* addr: unsigned int to make lm_sensors i
more cleanly. It does not take any more memory space, due to
alignment considerations */
struct i
struct i
void *data; /* for the clients */
int usage_count; /* How many accesses currently */
/* to the client */
};
- 上一篇:linux下I2C驱动(二)
- 下一篇:linux下I2C驱动(四)