Changeset 3937
- Timestamp:
- 12/03/04 23:14:09 (4 years ago)
- Files:
-
- i2c/trunk/Makefile (modified) (2 diffs)
- i2c/trunk/doc/writing-clients (modified) (2 diffs)
- i2c/trunk/kernel/i2c-core.c (modified) (2 diffs)
- i2c/trunk/kernel/i2c-dev.c (modified) (1 diff)
- i2c/trunk/kernel/i2c.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
i2c/trunk/Makefile
r3933 r3937 191 191 install :: all 192 192 ifeq ($(DESTDIR),) 193 @echo "*** If the depmod command below generates errors, you should pay particular"194 @echo "*** attention to the note #1 below."195 193 -/sbin/depmod -a 196 194 else … … 208 206 @echo "*** Installation successful!" 209 207 @echo "*** Important notes:" 210 @echo "*** 1* Due to a change in our i2c structures, i2c-related drivers from" 211 @echo "*** the Linux kernel and from external sources won't work with this" 212 @echo "*** version of i2c. Such drivers include commonly used video drivers" 213 @echo "*** such as bttv and zoran, and less commonly used ones such as" 214 @echo "*** i2c-matroxfb. If you really need these, then you shouldn't use our" 215 @echo "*** i2c package. If you can live without them, you should make sure" 216 @echo "*** such drivers do not exist on your system anymore. Loading them" 217 @echo "*** now would result in a severe system crash. We are working on the" 218 @echo "*** problem and will soon submit a complete i2c patch for inclusion in" 219 @echo "*** the Linux 2.4 kernel." 208 @echo "*** 1* Compatibility with the Linux 2.4 kernel has been restored." 220 209 @echo "*** 2* The i2c-elektor and i2c-pcf-epp modules were not built. If you" 221 210 @echo "*** need them, you have to use compilation option 3 as described in" i2c/trunk/doc/writing-clients
r3920 r3937 26 26 27 27 static struct i2c_driver foo_driver = { 28 .owner = THIS_MODULE,29 28 .name = "Foo version 2.3 driver", 30 29 .id = I2C_DRIVERID_FOO, /* from i2c-id.h, optional */ 31 30 .flags = I2C_DF_NOTIFY, 32 .attach_adapter = &foo_attach_adapter, 33 .detach_client = &foo_detach_client, 34 .command = &foo_command /* may be NULL */ 31 .attach_adapter = foo_attach_adapter, 32 .detach_client = foo_detach_client, 33 .command = foo_command, /* may be NULL */ 34 .inc_use = foo_inc_use, /* May be NULL */ 35 .dec_use = foo_dec_use, /* May be NULL */ 35 36 } 36 37 … … 51 52 below. 52 53 53 There use to be two additional fields in this structure, inc_use et dec_use, 54 for module usage count, but these fields were obsoleted and removed. 54 55 Module usage count 56 ================== 57 58 If your driver can also be compiled as a module, there are moments at 59 which the module can not be removed from memory. For example, when you 60 are doing a lengthy transaction, or when you create a /proc directory, 61 and some process has entered that directory. 62 63 i2c-core and i2c-proc will take care of properly counting the users 64 of the client driver for the common cases. If however your driver has 65 functions used by other parts of the kernel, you will have to implement 66 the inc_use and dec_use callback functions and use them. 67 68 To increase or decrease the module usage count, you can use the 69 MOD_{INC,DEC}_USE_COUNT macros. They must be called from the module 70 which needs to get its usage count changed; that is why each driver 71 module has to implement its own callback functions. 72 73 static void foo_inc_use (struct i2c_client *client) 74 { 75 #ifdef MODULE 76 MOD_INC_USE_COUNT; 77 #endif 78 } 79 80 static void foo_dec_use (struct i2c_client *client) 81 { 82 #ifdef MODULE 83 MOD_DEC_USE_COUNT; 84 #endif 85 } 86 87 Do not call these callback functions directly; instead, use the 88 following functions defined in i2c.h: 89 90 void i2c_inc_use_client(struct i2c_client *); 91 void i2c_dec_use_client(struct i2c_client *); 92 93 You should *not* increase the module count just because a device is 94 detected and a client created. This would make it impossible to remove 95 an adapter driver! 55 96 56 97 i2c/trunk/kernel/i2c-core.c
r3935 r3937 392 392 static void i2c_inc_use_client(struct i2c_client *client) 393 393 { 394 if (client->driver->owner)395 __MOD_INC_USE_COUNT(client->driver->owner);394 if (client->driver->inc_use != NULL) 395 client->driver->inc_use(client); 396 396 if (client->adapter->inc_use != NULL) 397 397 client->adapter->inc_use(client->adapter); … … 400 400 static void i2c_dec_use_client(struct i2c_client *client) 401 401 { 402 if (client->driver->owner)403 __MOD_DEC_USE_COUNT(client->driver->owner);402 if (client->driver->dec_use != NULL) 403 client->driver->dec_use(client); 404 404 if (client->adapter->dec_use != NULL) 405 405 client->adapter->dec_use(client->adapter); i2c/trunk/kernel/i2c-dev.c
r3935 r3937 84 84 85 85 static struct i2c_driver i2cdev_driver = { 86 .owner = THIS_MODULE, /* not really used */87 86 .name = "i2c-dev dummy driver", 88 87 .id = I2C_DRIVERID_I2CDEV, i2c/trunk/kernel/i2c.h
r3935 r3937 124 124 125 125 struct i2c_driver { 126 struct module *owner;127 126 char name[32]; 128 127 int id; … … 148 147 */ 149 148 int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); 149 150 /* These two are used for bookkeeping & dynamic unloading of 151 * kernel modules. inc_use tells the driver that a client is being 152 * used by another module & that it should increase its ref. counter. 153 * dec_use is the inverse operation. 154 * NB: Make sure you have no circular dependencies, or else you get a 155 * deadlock when trying to unload the modules. 156 * You should use the i2c_{inc,dec}_use_client functions instead of 157 * calling this function directly. 158 * Note that most clients won't need to implement these, only those 159 * which have users inside the kernel (as opposed to only in 160 * user-space through i2c-proc). 161 */ 162 void (*inc_use)(struct i2c_client *client); 163 void (*dec_use)(struct i2c_client *client); 150 164 }; 151 165
