fix i2c module handling
Subsystems (5)
PATCH 1/1 fix i2c module handling
Add a struct module *owner field to struct i2c_adapter and i2c_algorithm and do refcouting on them before use instead of the inc_use and dec_use callbacks. While at it convert those structures to named initializers.
drivers/i2c/i2c-adap-ite.c +4 -37
@@ -184,35 +184,6 @@release_region (gpi.iic_base ,2 ); } - -static int iic_ite_reg (struct i2c_client *client) -{ -return 0 ; -} - - -static int iic_ite_unreg (struct i2c_client *client) -{ -return 0 ; -} - - -static void iic_ite_inc_use (struct i2c_adapter *adap) -{ -#ifdef MODULE -MOD_INC_USE_COUNT ; -#endif -} - - -static void iic_ite_dec_use (struct i2c_adapter *adap) -{ -#ifdef MODULE -MOD_DEC_USE_COUNT ; -#endif -} - -/* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported.
@@ -228,14 +199,10 @@ };static struct i2c_adapter iic_ite_ops = { -"ITE IIC adapter" , -I2C_HW_I_IIC , -NULL , - &iic_ite_data, - iic_ite_inc_use, - iic_ite_dec_use, - iic_ite_reg, - iic_ite_unreg, + .owner =THIS_MODULE , + .name ="ITE IIC adapter" , + .id =I2C_HW_I_IIC , + .algo_data = &iic_ite_data, };/* Called when the module is loaded. This function starts the
===== drivers/i2c/i2c-algo-bit.c 1.10 vs edited =====
drivers/i2c/i2c-algo-bit.c +5 -15
@@ -529,14 +529,11 @@/* -----exported algorithm data: ------------------------------------- */ static struct i2c_algorithm i2c_bit_algo = { -"Bit-shift algorithm" , -I2C_ALGO_BIT , - bit_xfer, -NULL , -NULL ,/* slave_xmit */ -NULL ,/* slave_recv */ - algo_control,/* ioctl */ - bit_func,/* functionality */ + .name ="Bit-shift algorithm" , + .id =I2C_ALGO_BIT , + .master_xfer = bit_xfer, + .algo_control = algo_control, + .functionality = bit_func, };/*
@@ -581,11 +578,7 @@printk ("\n" ); } -#ifdef MODULE -MOD_INC_USE_COUNT ; -#endif i2c_add_adapter (adap); -return 0 ; }
@@ -599,9 +592,6 @@DEB2 (printk (KERN_DEBUG "i2c-algo-bit.o: adapter unregistered: %s\n" ,adap->name)); -#ifdef MODULE -MOD_DEC_USE_COUNT ; -#endif return 0 ; }
===== drivers/i2c/i2c-algo-pcf.c 1.6 vs edited =====
drivers/i2c/i2c-algo-pcf.c +1 -13
@@ -474,10 +474,6 @@return i; } -#ifdef MODULE -MOD_INC_USE_COUNT ; -#endif -i2c_add_adapter (adap);/* scan bus */
@@ -509,15 +505,7 @@int i2c_pcf_del_bus (struct i2c_adapter *adap) { -int res; -if ((res =i2c_del_adapter (adap)) <0 ) -return res; -DEB2 (printk (KERN_DEBUG "i2c-algo-pcf.o: adapter unregistered: %s\n" ,adap->name)); - -#ifdef MODULE -MOD_DEC_USE_COUNT ; -#endif -return 0 ; +return i2c_del_adapter (adap); }EXPORT_SYMBOL (i2c_pcf_add_bus);
===== drivers/i2c/i2c-core.c 1.13 vs edited =====
drivers/i2c/i2c-core.c +23 -24
75 lines not on this page · raw message
===== drivers/i2c/i2c-dev.c 1.19 vs edited =====
drivers/i2c/i2c-dev.c +5 -6
@@ -364,8 +364,10 @@ client->adapter = i2cdev_adaps[minor]; file->private_data = client; -if (i2cdev_adaps[minor]->inc_use) - i2cdev_adaps[minor]->inc_use (i2cdev_adaps[minor]); +if (!try_module_get (i2cdev_adaps[minor]->owner)) { +kfree (client); +return -ENODEV ; + }#ifdef DEBUG printk (KERN_DEBUG "i2c-dev.o: opened i2c-%d\n" ,minor);
@@ -381,10 +383,7 @@#ifdef DEBUG printk (KERN_DEBUG "i2c-dev.o: Closed: i2c-%d\n" , minor);#endif -lock_kernel (); -if (i2cdev_adaps[minor]->dec_use) - i2cdev_adaps[minor]->dec_use (i2cdev_adaps[minor]); -unlock_kernel (); +module_put (i2cdev_adaps[minor]->owner);return 0 ; }
===== drivers/i2c/i2c-elektor.c 1.12 vs edited =====
drivers/i2c/i2c-elektor.c +2 -31
@@ -142,7 +142,7 @@static int pcf_isa_init (void ) {if (!mmapped) { -if (!request_region (base,2 ,"i2c (isa bus adapter)" )) +if (!request_region (base,2 ,"i2c (isa bus adapter)" )) {printk (KERN_ERR "i2c-elektor.o: requested I/O region (0x%X:2) " "is in use.\n" , base);
@@ -159,32 +159,6 @@return 0 ; } -static int pcf_isa_reg (struct i2c_client *client) -{ -return 0 ; -} - - -static int pcf_isa_unreg (struct i2c_client *client) -{ -return 0 ; -} - -static void pcf_isa_inc_use (struct i2c_adapter *adap) -{ -#ifdef MODULE -MOD_INC_USE_COUNT ; -#endif -} - -static void pcf_isa_dec_use (struct i2c_adapter *adap) -{ -#ifdef MODULE -MOD_DEC_USE_COUNT ; -#endif -} - -/* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported.
@@ -201,13 +175,10 @@ };static struct i2c_adapter pcf_isa_ops = { + .owner =THIS_MODULE , .name ="PCF8584 ISA adapter" , .id =I2C_HW_P_ELEK , .algo_data = &pcf_isa_data, - .inc_use = pcf_isa_inc_use, - .dec_use = pcf_isa_dec_use, - .client_register = pcf_isa_reg, - .client_unregister = pcf_isa_unreg, };static int __init i2c_pcfisa_init (void )
===== drivers/i2c/i2c-elv.c 1.8 vs edited =====
drivers/i2c/i2c-elv.c +4 -32
@@ -115,30 +115,6 @@return -ENODEV ; } -static int bit_elv_reg (struct i2c_client *client) -{ -return 0 ; -} - -static int bit_elv_unreg (struct i2c_client *client) -{ -return 0 ; -} - -static void bit_elv_inc_use (struct i2c_adapter *adap) -{ -#ifdef MODULE -MOD_INC_USE_COUNT ; -#endif -} - -static void bit_elv_dec_use (struct i2c_adapter *adap) -{ -#ifdef MODULE -MOD_DEC_USE_COUNT ; -#endif -} -/* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported.
@@ -153,14 +129,10 @@ };static struct i2c_adapter bit_elv_ops = { -"ELV Parallel port adaptor" , -I2C_HW_B_ELV , -NULL , - &bit_elv_data, - bit_elv_inc_use, - bit_elv_dec_use, - bit_elv_reg, - bit_elv_unreg, + .owner =THIS_MODULE , + .name ="ELV Parallel port adaptor" , + .id =I2C_HW_B_ELV , + .algo_data = &bit_elv_data, };static int __init i2c_bitelv_init (void )
===== drivers/i2c/i2c-frodo.c 1.4 vs edited =====
drivers/i2c/i2c-frodo.c +3 -26
@@ -61,44 +61,21 @@ .timeout = 100 }; -static int frodo_client_register (struct i2c_client *client) -{ -return (0 ); -} - -static int frodo_client_unregister (struct i2c_client *client) -{ -return (0 ); -} - -static void frodo_inc_use (struct i2c_adapter *adapter) -{ -MOD_INC_USE_COUNT ; -} - -static void frodo_dec_use (struct i2c_adapter *adapter) -{ -MOD_DEC_USE_COUNT ; -} -static struct i2c_adapter frodo_ops = { + .owner =THIS_MODULE , .name ="Frodo adapter driver" , .id =I2C_HW_B_FRODO , .algo_data = &bit_frodo_data, - .inc_use = frodo_inc_use, - .dec_use = frodo_dec_use, - .client_register = frodo_client_register, - .client_unregister = frodo_client_unregister };static int __init i2c_frodo_init (void ) { -return (i2c_bit_add_bus (&frodo_ops)); +return i2c_bit_add_bus (&frodo_ops); } static void __exit i2c_frodo_exit (void) { -i2c_bit_del_bus (&frodo_ops); +i2c_bit_del_bus (&frodo_ops); }MODULE_AUTHOR ("Abraham van der Merwe <[email protected]>" );
===== drivers/i2c/i2c-philips-par.c 1.7 vs edited =====
drivers/i2c/i2c-philips-par.c +3 -29
@@ -129,26 +129,6 @@ PARPORT_STATUS_BUSY) ? 0 : 1; } -static int bit_lp_reg (struct i2c_client *client) -{ -return 0 ; -} - -static int bit_lp_unreg (struct i2c_client *client) -{ -return 0 ; -} - -static void bit_lp_inc_use (struct i2c_adapter *adap) -{ -MOD_INC_USE_COUNT ; -} - -static void bit_lp_dec_use (struct i2c_adapter *adap) -{ -MOD_DEC_USE_COUNT ; -} -/* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported.
@@ -173,15 +153,9 @@ };static struct i2c_adapter bit_lp_ops = { -"Philips Parallel port adapter" , -I2C_HW_B_LP , -NULL , -NULL , - bit_lp_inc_use, - bit_lp_dec_use, - bit_lp_reg, - - bit_lp_unreg, + .owner =THIS_MODULE , + .name ="Philips Parallel port adapter" , + .id =I2C_HW_B_LP , };static void i2c_parport_attach (struct parport *port)
===== drivers/i2c/i2c-proc.c 1.10 vs edited =====
drivers/i2c/i2c-proc.c +0 -43
49 lines not on this page · raw message
===== drivers/i2c/i2c-rpx.c 1.3 vs edited =====
drivers/i2c/i2c-rpx.c +4 -33
@@ -66,44 +66,15 @@return 0 ; } -static int rpx_reg (struct i2c_client *client) -{ -return 0 ; -} - -static int rpx_unreg (struct i2c_client *client) -{ -return 0 ; -} - -static void rpx_inc_use (struct i2c_adapter *adap) -{ -#ifdef MODULE -MOD_INC_USE_COUNT ; -#endif -} - -static void rpx_dec_use (struct i2c_adapter *adap) -{ -#ifdef MODULE -MOD_DEC_USE_COUNT ; -#endif -} -static struct i2c_algo_8xx_data rpx_data = { .setisr = rpx_install_isr }; -static struct i2c_adapter rpx_ops = { -"m8xx" , -I2C_HW_MPC8XX_EPON , -NULL , - &rpx_data, - rpx_inc_use, - rpx_dec_use, - rpx_reg, - rpx_unreg, + .owner =THIS_MODULE , + .name ="m8xx" , + .id =I2C_HW_MPC8XX_EPON , + .algo_data = &rpx_data, };int __init i2c_rpx_init (void )
===== drivers/i2c/i2c-velleman.c 1.6 vs edited =====
drivers/i2c/i2c-velleman.c +8 -40
65 lines not on this page · raw message
===== drivers/i2c/scx200_acb.c 1.2 vs edited =====
drivers/i2c/scx200_acb.c +1 -24
@@ -397,26 +397,6 @@I2C_FUNC_SMBUS_BLOCK_DATA ; } -static int scx200_acb_reg (struct i2c_client *client) -{ -return 0 ; -} - -static int scx200_acb_unreg (struct i2c_client *client) -{ -return 0 ; -} - -static void scx200_acb_inc_use (struct i2c_adapter *adapter) -{ -MOD_INC_USE_COUNT ; -} - -static void scx200_acb_dec_use (struct i2c_adapter *adapter) -{ -MOD_DEC_USE_COUNT ; -} -/* For now, we only handle combined mode (smbus) */ static struct i2c_algorithm scx200_acb_algorithm = { .name ="NatSemi SCx200 ACCESS.bus" ,
@@ -479,12 +459,9 @@ adapter = &iface->adapter; adapter->data = iface;sprintf (adapter->name,"SCx200 ACB%d" , index); + adapter->owner =THIS_MODULE ; adapter->id =I2C_ALGO_SMBUS ; adapter->algo = &scx200_acb_algorithm; - adapter->inc_use = scx200_acb_inc_use; - adapter->dec_use = scx200_acb_dec_use; - adapter->client_register = scx200_acb_reg; - adapter->client_unregister = scx200_acb_unreg;init_MUTEX (&iface->sem);
===== drivers/i2c/scx200_i2c.c 1.1 vs edited =====
drivers/i2c/scx200_i2c.c +1 -24
@@ -66,26 +66,6 @@return scx200_gpio_get (sda); } -static int scx200_i2c_reg (struct i2c_client *client) -{ -return 0 ; -} - -static int scx200_i2c_unreg (struct i2c_client *client) -{ -return 0 ; -} - -static void scx200_i2c_inc_use (struct i2c_adapter *adap) -{ -MOD_INC_USE_COUNT ; -} - -static void scx200_i2c_dec_use (struct i2c_adapter *adap) -{ -MOD_DEC_USE_COUNT ; -} -/* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported.
@@ -101,13 +81,10 @@ };static struct i2c_adapter scx200_i2c_ops = { + .owner =THIS_MODULE , .name ="NatSemi SCx200 I2C" , .id =I2C_HW_B_VELLE , .algo_data = &scx200_i2c_data, - .inc_use = scx200_i2c_inc_use, - .dec_use = scx200_i2c_dec_use, - .client_register = scx200_i2c_reg, - .client_unregister = scx200_i2c_unreg, };int scx200_i2c_init (void )
===== drivers/i2c/busses/i2c-amd756.c 1.2 vs edited =====
drivers/i2c/busses/i2c-amd756.c +1 -13
@@ -296,17 +296,6 @@return 0 ; } -static void amd756_inc (struct i2c_adapter *adapter) -{ -MOD_INC_USE_COUNT ; -} - -static void amd756_dec (struct i2c_adapter *adapter) -{ - -MOD_DEC_USE_COUNT ; -} -static u32 amd756_func (struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
@@ -322,11 +311,10 @@ };static struct i2c_adapter amd756_adapter = { + .owner =THIS_MODULE , .name ="unset" , .id =I2C_ALGO_SMBUS |I2C_HW_SMBUS_AMD756 , .algo = &smbus_algorithm, - .inc_use = amd756_inc, - .dec_use = amd756_dec, };enum chiptype {AMD756 ,AMD766 ,AMD768 ,NFORCE };
===== drivers/i2c/busses/i2c-amd8111.c 1.1 vs edited =====
drivers/i2c/busses/i2c-amd8111.c +1 -12
@@ -320,16 +320,6 @@return 0 ; } -void amd8111_inc (struct i2c_adapter *adapter) -{ -MOD_INC_USE_COUNT ; -} - -void amd8111_dec (struct i2c_adapter *adapter) -{ -MOD_DEC_USE_COUNT ; -} -u32 amd8111_func (struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA |
@@ -368,12 +358,11 @@return -1 ; } + smbus->adapter.owner =THIS_MODULE ;sprintf (smbus->adapter.name,"SMBus2 AMD8111 adapter at %04x" , smbus->base); smbus->adapter.id =I2C_ALGO_SMBUS |I2C_HW_SMBUS_AMD8111 ; smbus->adapter.algo = &smbus_algorithm; smbus->adapter.algo_data = smbus; - smbus->adapter.inc_use = amd8111_inc; - smbus->adapter.dec_use = amd8111_dec;if (i2c_add_adapter (&smbus->adapter)) {printk (KERN_WARNING "i2c-amd8111.c: Failed to register adapter.\n" );
===== drivers/i2c/chips/adm1021.c 1.2 vs edited =====
drivers/i2c/chips/adm1021.c +9 -21
@@ -114,8 +114,6 @@static int adm1021_detach_client (struct i2c_client *client);static int adm1021_command (struct i2c_client *client,unsigned int cmd,void *arg); -static void adm1021_inc_use (struct i2c_client *client); -static void adm1021_dec_use (struct i2c_client *client);static int adm1021_read_value (struct i2c_client *client,u8 reg);static int adm1021_write_value (struct i2c_client *client,u8 reg,u16 value);
@@ -136,14 +134,13 @@/* This is the driver that will be inserted */ static struct i2c_driver adm1021_driver = { -/* name */ "ADM1021, MAX1617 sensor driver" , -/* id */ I2C_DRIVERID_ADM1021 , -/* flags */ I2C_DF_NOTIFY , -/* attach_adapter */ &adm1021_attach_adapter, -/* detach_client */ &adm1021_detach_client, -/* command */ &adm1021_command, -/* inc_use */ &adm1021_inc_use, -/* dec_use */ &adm1021_dec_use + .owner =THIS_MODULE , + .name ="ADM1021, MAX1617 sensor driver" , + .id =I2C_DRIVERID_ADM1021 , + .flags =I2C_DF_NOTIFY , + .attach_adapter = adm1021_attach_adapter, + .detach_client = adm1021_detach_client, + .command = adm1021_command, };/* These files are created for each detected adm1021. This is just a template;
@@ -375,16 +372,6 @@return 0 ; } -void adm1021_inc_use (struct i2c_client *client) -{ -MOD_INC_USE_COUNT ; -} - -void adm1021_dec_use (struct i2c_client *client) -{ -MOD_DEC_USE_COUNT ; -} -/* All registers are byte-sized */ int adm1021_read_value (struct i2c_client *client,u8 reg) {
@@ -478,8 +465,9 @@void adm1021_remote_temp (struct i2c_client *client,int operation,int ctl_name,int *nrels_mag,long *results) { -int prec=0 ;struct adm1021_data *data = client->data; +int prec =0 ; +if (operation ==SENSORS_PROC_REAL_INFO )if (data->type == adm1023) { *nrels_mag =3 ; }else { *nrels_mag =0 ; }
===== drivers/i2c/chips/lm75.c 1.2 vs edited =====
drivers/i2c/chips/lm75.c +9 -36
71 lines not on this page · raw message
===== drivers/media/video/adv7175.c 1.7 vs edited =====
drivers/media/video/adv7175.c +2 -15
@@ -396,39 +396,26 @@return 0 ; } -static void adv717x_inc_use (struct i2c_client *client) -{ -MOD_INC_USE_COUNT ; -} - -static void adv717x_dec_use (struct i2c_client *client) -{ -MOD_DEC_USE_COUNT ; -} - -/* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_adv7175 = { + .owner =THIS_MODULE , .name ="adv7175" ,/* name */ .id = I2C_DRIVERID_ADV717x,/* ID */ .flags =I2C_DF_NOTIFY ,//I2C_ADV7175, I2C_ADV7175 + 3, .attach_adapter = adv717x_probe, .detach_client = adv717x_detach, .command = adv717x_command, - .inc_use = &adv717x_inc_use, - .dec_use = &adv717x_dec_use };static struct i2c_driver i2c_driver_adv7176 = { + .owner =THIS_MODULE , .name ="adv7176" ,/* name */ .id = I2C_DRIVERID_ADV717x,/* ID */ .flags =I2C_DF_NOTIFY ,//I2C_ADV7176, I2C_ADV7176 + 3, .attach_adapter = adv717x_probe, .detach_client = adv717x_detach, .command = adv717x_command, - .inc_use = &adv717x_inc_use, - .dec_use = &adv717x_dec_use };static struct i2c_client client_template = {
===== drivers/media/video/bttv-if.c 1.6 vs edited =====
drivers/media/video/bttv-if.c +1 -12
@@ -194,16 +194,6 @@return state; } -static void bttv_inc_use (struct i2c_adapter *adap) -{ -MOD_INC_USE_COUNT ; -} - -static void bttv_dec_use (struct i2c_adapter *adap) -{ -MOD_DEC_USE_COUNT ; -} -static int attach_inform (struct i2c_client *client) {struct bttv *btv = (struct bttv *)client->adapter->data;
@@ -272,10 +262,9 @@ };static struct i2c_adapter bttv_i2c_adap_template = { + .owner =THIS_MODULE , .name ="bt848" , .id =I2C_HW_B_BT848 , - .inc_use = bttv_inc_use, - .dec_use = bttv_dec_use, .client_register = attach_inform, .client_unregister = detach_inform, };
===== drivers/media/video/tvmixer.c 1.9 vs edited =====
drivers/media/video/tvmixer.c +4 -4
@@ -195,8 +195,9 @@/* lock bttv in memory while the mixer is in use */ file->private_data = mix; -if (client->adapter->inc_use) - client->adapter->inc_use (client->adapter); + +if (!try_module_get (client->adapter->owner)) +return -ENODEV ;return 0 ; }
@@ -210,8 +211,7 @@return -ENODEV ; } -if (client->adapter->dec_use) - client->adapter->dec_use (client->adapter); +module_put (client->adapter->owner);return 0 ; }
===== drivers/media/video/saa7134/saa7134-i2c.c 1.2 vs edited =====
drivers/media/video/saa7134/saa7134-i2c.c +1 -12
@@ -318,16 +318,6 @@return I2C_FUNC_SMBUS_EMUL ; } -static void inc_use (struct i2c_adapter *adap) -{ -MOD_INC_USE_COUNT ; -} - -static void dec_use (struct i2c_adapter *adap) -{ -MOD_DEC_USE_COUNT ; -} -static int attach_inform (struct i2c_client *client) {struct saa7134_dev *dev = client->adapter->algo_data;
@@ -346,11 +336,10 @@ };static struct i2c_adapter saa7134_adap_template = { + .owner =THIS_MODULE , .name ="saa7134" , .id =I2C_ALGO_SAA7134 , .algo = &saa7134_algo, - .inc_use = inc_use, - .dec_use = dec_use, .client_register = attach_inform, };
drivers/video/matrox/i2c-matroxfb.c +1 -10
@@ -87,19 +87,10 @@return (matroxfb_read_gpio (b->minfo) & b->mask.clock) ?1 :0 ; } -static void matroxfb_dh_inc_use (struct i2c_adapter * dummy) { -MOD_INC_USE_COUNT ; -} - -static void matroxfb_dh_dec_use (struct i2c_adapter * dummy) { -MOD_DEC_USE_COUNT ; -} -static struct i2c_adapter matrox_i2c_adapter_template = { + .owner =THIS_MODULE , .id =I2C_HW_B_G400 , - .inc_use = matroxfb_dh_inc_use, - .dec_use = matroxfb_dh_dec_use, }; static struct i2c_algo_bit_data matrox_i2c_algo_template =
===== drivers/video/matrox/matroxfb_maven.c 1.11 vs edited =====
drivers/video/matrox/matroxfb_maven.c +7 -21
@@ -945,14 +945,6 @@static unsigned short normal_i2c_range[] = {MAVEN_I2CID ,MAVEN_I2CID ,I2C_CLIENT_END };I2C_CLIENT_INSMOD ; -static void maven_inc_use (struct i2c_client * clnt) { -MOD_INC_USE_COUNT ; -} - -static void maven_dec_use (struct i2c_client * clnt) { -MOD_DEC_USE_COUNT ; -} -static struct i2c_driver maven_driver; static int maven_detect_client(struct i2c_adapter* adapter, int address, unsigned short flags,
@@ -1016,17 +1008,13 @@return -ENOIOCTLCMD ;/* or -EINVAL, depends on who will call this */ } -static int maven_driver_registered =0 ; -static struct i2c_driver maven_driver={ -"maven" , -I2C_DRIVERID_MGATVO , -I2C_DF_NOTIFY , - maven_attach_adapter, - maven_detach_client, - maven_command, - maven_inc_use, - maven_dec_use + .owner =THIS_MODULE , + .name ="maven" , + .id =I2C_DRIVERID_MGATVO , + .flags =I2C_DF_NOTIFY , + .attach_adapter = maven_attach_adapter, + .detach_client = maven_detach_client, };/* ************************** */
@@ -1039,13 +1027,11 @@printk (KERN_ERR "maven: Maven driver failed to register (%d).\n" , err);return err; } - maven_driver_registered =1 ;return 0 ; }static void matroxfb_maven_exit (void ) { -if (maven_driver_registered) -i2c_del_driver (&maven_driver); +i2c_del_driver (&maven_driver); }MODULE_AUTHOR ("(c) 1999-2002 Petr Vandrovec <[email protected]>" );
===== include/linux/i2c.h 1.7 vs edited =====
include/linux/i2c.h +2 -22
@@ -132,6 +132,7 @@*/ struct i2c_driver { +struct module *owner;char name[32 ];int id;unsigned int flags;/* div., see below */
@@ -155,18 +156,6 @@* with the device. */ int (*command)(struct i2c_client *client,unsigned int cmd,void *arg); - -/* 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 i2c_{inc,dec}_use_client functions instead of -* calling this function directly. -*/ -void (*inc_use)(struct i2c_client *client); -void (*dec_use)(struct i2c_client *client); };/*
@@ -232,16 +221,13 @@* with the access algorithms necessary to access it. */ struct i2c_adapter { +struct module *owner;char name[32 ];/* some useful name to identify the adapter */ unsigned int id;/* == is algo->id | hwdep.struct->id, */ /* for registered values see below */ struct i2c_algorithm *algo;/* the algorithm to access the bus */ void *algo_data; -/* --- These may be NULL, but should increase the module use count */ -void (*inc_use)(struct i2c_adapter *); -void (*dec_use)(struct i2c_adapter *); -/* --- administration stuff. */ int (*client_register)(struct i2c_client *);int (*client_unregister)(struct i2c_client *);
@@ -318,12 +304,6 @@extern int i2c_attach_client (struct i2c_client *);extern int i2c_detach_client (struct i2c_client *); - -/* Only call these if you grab a resource that makes unloading the -client and the adapter it is on completely impossible. Like when a -/proc directory is entered. */ -extern void i2c_inc_use_client (struct i2c_client *); -extern void i2c_dec_use_client (struct i2c_client *);/* New function: This is to get an i2c_client-struct for controlling the client either by using i2c_control-function or having the