亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? writing-clients

?? I2C總線LINUX驅動程序
??
?? 第 1 頁 / 共 3 頁
字號:
This is a small guide for those who want to write kernel drivers for I2Cor SMBus devices.To set up a driver, you need to do several things. Some are optional, andsome things can be done slightly or completely different. Use this as aguide, not as a rule book!General remarks===============Try to keep the kernel namespace as clean as possible. The best way todo this is to use a unique prefix for all global symbols. This is especially important for exported symbols, but it is a good idea to doit for non-exported symbols too. We will use the prefix `foo_' in thistutorial, and `FOO_' for preprocessor variables.The driver structure====================Usually, you will implement a single driver structure, and instantiateall clients from it. Remember, a driver structure contains general access routines, a client structure specific information like the actual I2Caddress.static struct i2c_driver foo_driver = {	.name		= "Foo version 2.3 driver",	.id		= I2C_DRIVERID_FOO, /* from i2c-id.h, optional */	.flags		= I2C_DF_NOTIFY,	.attach_adapter	= foo_attach_adapter,	.detach_client	= foo_detach_client,	.command	= foo_command, /* may be NULL */	.inc_use	= foo_inc_use, /* May be NULL */	.dec_use	= foo_dec_use, /* May be NULL */} The name can be chosen freely, and may be up to 31 characters long. Pleaseuse something descriptive here.If used, the id should be a unique ID. The range 0xf000 to 0xffff isreserved for local use, and you can use one of those until you startdistributing the driver, at which time you should contact the i2c authorsto get your own ID(s). Note that most of the time you don't need an IDat all so you can just omit it.Don't worry about the flags field; just put I2C_DF_NOTIFY into it. Thismeans that your driver will be notified when new adapters are found.This is almost always what you want.All other fields are for call-back functions which will be explained below.Module usage count==================If your driver can also be compiled as a module, there are moments at which the module can not be removed from memory. For example, when youare doing a lengthy transaction, or when you create a /proc directory,and some process has entered that directory.i2c-core and i2c-proc will take care of properly counting the usersof the client driver for the common cases. If however your driver hasfunctions used by other parts of the kernel, you will have to implementthe inc_use and dec_use callback functions and use them.To increase or decrease the module usage count, you can use theMOD_{INC,DEC}_USE_COUNT macros. They must be called from the modulewhich needs to get its usage count changed; that is why each drivermodule has to implement its own callback functions.static void foo_inc_use (struct i2c_client *client){#ifdef MODULE	MOD_INC_USE_COUNT;#endif}static void foo_dec_use (struct i2c_client *client){#ifdef MODULE	MOD_DEC_USE_COUNT;#endif}Do not call these callback functions directly; instead, use thefollowing functions defined in i2c.h:void i2c_inc_use_client(struct i2c_client *);void i2c_dec_use_client(struct i2c_client *);You should *not* increase the module count just because a device isdetected and a client created. This would make it impossible to removean adapter driver! Extra client data=================The client structure has a special `data' field that can point to anystructure at all. You can use this to keep client-specific data. Youdo not always need this, but especially for `sensors' drivers, it canbe very useful.An example structure is below.  struct foo_data {    struct i2c_client client;    struct semaphore lock; /* For ISA access in `sensors' drivers. */    int sysctl_id;         /* To keep the /proc directory entry for                               `sensors' drivers. */    enum chips type;       /* To keep the chips type for `sensors' drivers. */       /* Because the i2c bus is slow, it is often useful to cache the read       information of a chip for some time (for example, 1 or 2 seconds).       It depends of course on the device whether this is really worthwhile       or even sensible. */    struct semaphore update_lock; /* When we are reading lots of information,                                     another process should not update the                                     below information */    char valid;                   /* != 0 if the following fields are valid. */    unsigned long last_updated;   /* In jiffies */    /* Add the read information here too */  };Accessing the client====================Let's say we have a valid client structure. At some time, we will needto gather information from the client, or write new information to theclient. How we will export this information to user-space is less important at this moment (perhaps we do not need to do this at all forsome obscure clients). But we need generic reading and writing routines.I have found it useful to define foo_read and foo_write function for this.For some cases, it will be easier to call the i2c functions directly,but many chips have some kind of register-value idea that can easilybe encapsulated. Also, some chips have both ISA and I2C interfaces, andit useful to abstract from this (only for `sensors' drivers).The below functions are simple examples, and should not be copiedliterally.  int foo_read_value(struct i2c_client *client, u8 reg)  {    if (reg < 0x10) /* byte-sized register */      return i2c_smbus_read_byte_data(client,reg);    else /* word-sized register */      return i2c_smbus_read_word_data(client,reg);  }  int foo_write_value(struct i2c_client *client, u8 reg, u16 value)  {    if (reg == 0x10) /* Impossible to write - driver error! */ {      return -1;    else if (reg < 0x10) /* byte-sized register */      return i2c_smbus_write_byte_data(client,reg,value);    else /* word-sized register */      return i2c_smbus_write_word_data(client,reg,value);  }For sensors code, you may have to cope with ISA registers too. Somethinglike the below often works. Note the locking!   int foo_read_value(struct i2c_client *client, u8 reg)  {    int res;    if (i2c_is_isa_client(client)) {      down(&(((struct foo_data *) (client->data)) -> lock));      outb_p(reg,client->addr + FOO_ADDR_REG_OFFSET);      res = inb_p(client->addr + FOO_DATA_REG_OFFSET);      up(&(((struct foo_data *) (client->data)) -> lock));      return res;    } else      return i2c_smbus_read_byte_data(client,reg);  }Writing is done the same way.Probing and attaching=====================Most i2c devices can be present on several i2c addresses; for some thisis determined in hardware (by soldering some chip pins to Vcc or Ground),for others this can be changed in software (by writing to specific clientregisters). Some devices are usually on a specific address, but not always;and some are even more tricky. So you will probably need to scan severali2c addresses for your clients, and do some sort of detection to seewhether it is actually a device supported by your driver.To give the user a maximum of possibilities, some default module parametersare defined to help determine what addresses are scanned. Several macrosare defined in i2c.h to help you support them, as well as a genericdetection algorithm.You do not have to use this parameter interface; but don't try to usefunction i2c_probe() (or i2c_detect()) if you don't.NOTE: If you want to write a `sensors' driver, the interface is slightly      different! See below.Probing classes (i2c)---------------------All parameters are given as lists of unsigned 16-bit integers. Lists areterminated by I2C_CLIENT_END.The following lists are used internally:  normal_i2c: filled in by the module writer.      A list of I2C addresses which should normally be examined.   normal_i2c_range: filled in by the module writer.     A list of pairs of I2C addresses, each pair being an inclusive range of     addresses which should normally be examined.   probe: insmod parameter.      A list of pairs. The first value is a bus number (-1 for any I2C bus),      the second is the address. These addresses are also probed, as if they      were in the 'normal' list.   probe_range: insmod parameter.      A list of triples. The first value is a bus number (-1 for any I2C bus),      the second and third are addresses.  These form an inclusive range of      addresses that are also probed, as if they were in the 'normal' list.   ignore: insmod parameter.     A list of pairs. The first value is a bus number (-1 for any I2C bus),      the second is the I2C address. These addresses are never probed.      This parameter overrules 'normal' and 'probe', but not the 'force' lists.   ignore_range: insmod parameter.      A list of triples. The first value is a bus number (-1 for any I2C bus),      the second and third are addresses. These form an inclusive range of      I2C addresses that are never probed.     This parameter overrules 'normal' and 'probe', but not the 'force' lists.   force: insmod parameter.      A list of pairs. The first value is a bus number (-1 for any I2C bus),     the second is the I2C address. A device is blindly assumed to be on     the given address, no probing is done. Fortunately, as a module writer, you just have to define the `normal' and/or `normal_range' parameters. The complete declaration could looklike this:  /* Scan 0x20 to 0x2f, 0x37, and 0x40 to 0x4f */  static unsigned short normal_i2c[] = { 0x37,I2C_CLIENT_END };   static unsigned short normal_i2c_range[] = { 0x20, 0x2f, 0x40, 0x4f,                                                I2C_CLIENT_END };  /* Magic definition of all other variables and things */  I2C_CLIENT_INSMOD;Note that you *have* to call the two defined variables `normal_i2c' and`normal_i2c_range', without any prefix!Probing classes (sensors)-------------------------If you write a `sensors' driver, you use a slightly different interface.As well as I2C addresses, we have to cope with ISA addresses. Also, weuse a enum of chip types. Don't forget to include `sensors.h'.The following lists are used internally. They are all lists of integers.   normal_i2c: filled in by the module writer. Terminated by SENSORS_I2C_END.     A list of I2C addresses which should normally be examined.   normal_i2c_range: filled in by the module writer. Terminated by      SENSORS_I2C_END     A list of pairs of I2C addresses, each pair being an inclusive range of     addresses which should normally be examined.   normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END.     A list of ISA addresses which should normally be examined.   normal_isa_range: filled in by the module writer. Terminated by      SENSORS_ISA_END     A list of triples. The first two elements are ISA addresses, being an     range of addresses which should normally be examined. The third is the     modulo parameter: only addresses which are 0 module this value relative     to the first address of the range are actually considered.   probe: insmod parameter. Initialize this list with SENSORS_I2C_END values.     A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for     the ISA bus, -1 for any I2C bus), the second is the address. These     addresses are also probed, as if they were in the 'normal' list.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本不卡一区二区三区| 精品国产露脸精彩对白| 成人精品国产一区二区4080| 免费国产亚洲视频| 蜜桃视频第一区免费观看| 日韩精品乱码av一区二区| 一区二区三区欧美日韩| 亚洲精品国产一区二区三区四区在线| 国产精品美女视频| 国产精品国产馆在线真实露脸| 国产人久久人人人人爽| 中文字幕不卡的av| 亚洲欧洲色图综合| 亚洲自拍都市欧美小说| 亚洲123区在线观看| 日本在线不卡视频| 麻豆久久一区二区| 国产成人精品免费在线| 91视频在线观看| 欧美日韩午夜精品| 欧美福利视频一区| 国产色婷婷亚洲99精品小说| 日欧美一区二区| 日韩av成人高清| 国产suv一区二区三区88区| av男人天堂一区| 91精彩视频在线观看| 欧美电影在线免费观看| 欧美不卡一区二区三区| 欧美经典一区二区三区| 亚洲资源中文字幕| 国产做a爰片久久毛片| 成人免费看视频| 欧美三级中文字幕| 国产视频一区二区在线| 综合久久久久久久| 免费精品视频在线| 99在线视频精品| 在线观看91精品国产麻豆| 久久九九久久九九| 一区二区三区四区不卡视频| 日本美女一区二区| 不卡视频在线看| 欧美日韩在线播放一区| 久久久五月婷婷| 亚洲高清三级视频| 国产乱码精品一区二区三区av | 欧美成人三级在线| 中文字幕五月欧美| 日韩精品欧美精品| 99精品久久99久久久久| 日韩女优电影在线观看| 一区二区高清视频在线观看| 国产综合色产在线精品| 欧美三级日韩三级| 亚洲三级免费观看| 国产精品一卡二卡在线观看| 欧美日韩亚洲综合| 亚洲欧美日韩国产综合在线| 国产自产高清不卡| 欧美精品日韩综合在线| 亚洲欧美日韩成人高清在线一区| 激情综合色综合久久| 精品视频一区三区九区| 国产精品第五页| 国产精品77777| 精品福利一区二区三区| 首页国产欧美久久| 欧美视频一区二区在线观看| 中文字幕中文字幕在线一区| 国产激情一区二区三区四区 | 欧美在线制服丝袜| 18成人在线观看| 国产成人午夜99999| 日韩欧美色综合| 奇米777欧美一区二区| 在线看日本不卡| 夜夜嗨av一区二区三区四季av | 91久久久免费一区二区| 亚洲另类中文字| 色欧美日韩亚洲| 亚洲色大成网站www久久九九| 国产成人精品影视| 欧美国产禁国产网站cc| 成人一区二区三区视频| 中文字幕的久久| www.欧美精品一二区| 中文字幕一区在线观看| 99综合电影在线视频| 一区二区三区日韩欧美精品| 欧美色综合天天久久综合精品| 亚洲人午夜精品天堂一二香蕉| 成人av在线一区二区| 亚洲欧美另类在线| 色婷婷激情一区二区三区| 伊人色综合久久天天| 欧美日韩国产三级| 性欧美大战久久久久久久久| 欧美一区二区三区四区视频| 久久99精品久久久久久| 久久久激情视频| 91成人看片片| 婷婷成人激情在线网| 日韩精品专区在线| 成人免费视频app| 亚洲一区二区三区在线| 91精品国产入口| 国产美女av一区二区三区| 中文在线免费一区三区高中清不卡 | 一区二区视频免费在线观看| 欧美日本在线一区| 国产在线精品一区二区夜色 | 5566中文字幕一区二区电影| 麻豆精品久久精品色综合| 国产精品免费aⅴ片在线观看| 色av综合在线| 国精产品一区一区三区mba视频| 亚洲女同女同女同女同女同69| 日韩一级完整毛片| 99久久精品一区| 美女视频网站久久| 亚洲人吸女人奶水| 久久久不卡网国产精品二区| 欧美色涩在线第一页| 国产成人亚洲精品青草天美| 丝袜美腿亚洲综合| 国产精品久久久久久户外露出| 欧美一级生活片| 欧美三级日本三级少妇99| 成人午夜视频免费看| 久久97超碰国产精品超碰| 亚洲精品国产一区二区精华液 | 亚洲另类春色国产| 久久色在线观看| 4438亚洲最大| 91福利在线导航| jlzzjlzz亚洲女人18| 国产一区福利在线| 日本午夜精品一区二区三区电影| 中文字幕一区二区三区在线观看| 26uuu色噜噜精品一区二区| 欧美区在线观看| 欧美亚洲动漫精品| 日本乱码高清不卡字幕| 成人18视频在线播放| 国产精品一级黄| 久久99精品网久久| 捆绑调教美女网站视频一区| 午夜精品视频一区| 亚洲第一成人在线| 一区二区三区在线观看国产| 亚洲欧美日韩中文播放| 国产精品美日韩| 亚洲视频网在线直播| 中文字幕一区二区不卡| 国产精品卡一卡二| 日本一区二区三区四区在线视频| 精品欧美久久久| 日韩你懂的电影在线观看| 日韩一区二区精品葵司在线| 91精品国产一区二区| 日韩一卡二卡三卡国产欧美| 欧美一级理论性理论a| 日韩一区二区影院| 26uuu亚洲婷婷狠狠天堂| 久久免费精品国产久精品久久久久| 日韩欧美高清一区| 欧美变态口味重另类| 久久综合久久久久88| 国产精品久久久久影院老司| 亚洲欧美精品午睡沙发| 亚洲综合图片区| 日韩成人精品在线观看| 蜜桃av噜噜一区| 成人性生交大片| 91久久国产综合久久| 欧美久久高跟鞋激| 亚洲精品一区二区三区精华液| 国产午夜精品福利| 亚洲一区二区三区四区的| 天堂精品中文字幕在线| 国产在线精品免费av| 成人免费电影视频| 欧美日韩你懂得| 久久久亚洲午夜电影| 一区二区三区毛片| 国内精品在线播放| 91在线国产福利| 精品99一区二区| 亚洲人成亚洲人成在线观看图片| 婷婷亚洲久悠悠色悠在线播放 | 成人丝袜视频网| 欧美私人免费视频| 国产人成一区二区三区影院| 一区二区日韩电影| 成人毛片在线观看| 欧美日韩成人在线一区| 中文字幕+乱码+中文字幕一区| 性做久久久久久免费观看| 丁香天五香天堂综合|