Commit 84fed9da authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[PATCH] 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.
parent 8ef26e17
...@@ -296,17 +296,6 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr, ...@@ -296,17 +296,6 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
return 0; 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) static u32 amd756_func(struct i2c_adapter *adapter)
{ {
return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
...@@ -322,11 +311,10 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -322,11 +311,10 @@ static struct i2c_algorithm smbus_algorithm = {
}; };
static struct i2c_adapter amd756_adapter = { static struct i2c_adapter amd756_adapter = {
.owner = THIS_MODULE,
.name = "unset", .name = "unset",
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756, .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.inc_use = amd756_inc,
.dec_use = amd756_dec,
}; };
enum chiptype { AMD756, AMD766, AMD768, NFORCE }; enum chiptype { AMD756, AMD766, AMD768, NFORCE };
......
...@@ -320,16 +320,6 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, ...@@ -320,16 +320,6 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
return 0; 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) u32 amd8111_func(struct i2c_adapter *adapter)
{ {
return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA |
...@@ -368,12 +358,11 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ ...@@ -368,12 +358,11 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
return -1; return -1;
} }
smbus->adapter.owner = THIS_MODULE;
sprintf(smbus->adapter.name, "SMBus2 AMD8111 adapter at %04x", smbus->base); sprintf(smbus->adapter.name, "SMBus2 AMD8111 adapter at %04x", smbus->base);
smbus->adapter.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD8111; smbus->adapter.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD8111;
smbus->adapter.algo = &smbus_algorithm; smbus->adapter.algo = &smbus_algorithm;
smbus->adapter.algo_data = smbus; smbus->adapter.algo_data = smbus;
smbus->adapter.inc_use = amd8111_inc;
smbus->adapter.dec_use = amd8111_dec;
if (i2c_add_adapter(&smbus->adapter)) { if (i2c_add_adapter(&smbus->adapter)) {
printk(KERN_WARNING "i2c-amd8111.c: Failed to register adapter.\n"); printk(KERN_WARNING "i2c-amd8111.c: Failed to register adapter.\n");
......
...@@ -114,8 +114,6 @@ static void adm1021_init_client(struct i2c_client *client); ...@@ -114,8 +114,6 @@ static void adm1021_init_client(struct i2c_client *client);
static int adm1021_detach_client(struct i2c_client *client); static int adm1021_detach_client(struct i2c_client *client);
static int adm1021_command(struct i2c_client *client, unsigned int cmd, static int adm1021_command(struct i2c_client *client, unsigned int cmd,
void *arg); 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_read_value(struct i2c_client *client, u8 reg);
static int adm1021_write_value(struct i2c_client *client, u8 reg, static int adm1021_write_value(struct i2c_client *client, u8 reg,
u16 value); u16 value);
...@@ -136,14 +134,13 @@ static int read_only = 0; ...@@ -136,14 +134,13 @@ static int read_only = 0;
/* This is the driver that will be inserted */ /* This is the driver that will be inserted */
static struct i2c_driver adm1021_driver = { static struct i2c_driver adm1021_driver = {
/* name */ "ADM1021, MAX1617 sensor driver", .owner = THIS_MODULE,
/* id */ I2C_DRIVERID_ADM1021, .name = "ADM1021, MAX1617 sensor driver",
/* flags */ I2C_DF_NOTIFY, .id = I2C_DRIVERID_ADM1021,
/* attach_adapter */ &adm1021_attach_adapter, .flags = I2C_DF_NOTIFY,
/* detach_client */ &adm1021_detach_client, .attach_adapter = adm1021_attach_adapter,
/* command */ &adm1021_command, .detach_client = adm1021_detach_client,
/* inc_use */ &adm1021_inc_use, .command = adm1021_command,
/* dec_use */ &adm1021_dec_use
}; };
/* These files are created for each detected adm1021. This is just a template; /* These files are created for each detected adm1021. This is just a template;
...@@ -375,16 +372,6 @@ int adm1021_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -375,16 +372,6 @@ int adm1021_command(struct i2c_client *client, unsigned int cmd, void *arg)
return 0; 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 */ /* All registers are byte-sized */
int adm1021_read_value(struct i2c_client *client, u8 reg) int adm1021_read_value(struct i2c_client *client, u8 reg)
{ {
...@@ -478,8 +465,9 @@ void adm1021_temp(struct i2c_client *client, int operation, int ctl_name, ...@@ -478,8 +465,9 @@ void adm1021_temp(struct i2c_client *client, int operation, int ctl_name,
void adm1021_remote_temp(struct i2c_client *client, int operation, void adm1021_remote_temp(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results) int ctl_name, int *nrels_mag, long *results)
{ {
int prec=0;
struct adm1021_data *data = client->data; struct adm1021_data *data = client->data;
int prec = 0;
if (operation == SENSORS_PROC_REAL_INFO) if (operation == SENSORS_PROC_REAL_INFO)
if (data->type == adm1023) { *nrels_mag = 3; } if (data->type == adm1023) { *nrels_mag = 3; }
else { *nrels_mag = 0; } else { *nrels_mag = 0; }
......
...@@ -72,8 +72,6 @@ static void lm75_init_client(struct i2c_client *client); ...@@ -72,8 +72,6 @@ static void lm75_init_client(struct i2c_client *client);
static int lm75_detach_client(struct i2c_client *client); static int lm75_detach_client(struct i2c_client *client);
static int lm75_command(struct i2c_client *client, unsigned int cmd, static int lm75_command(struct i2c_client *client, unsigned int cmd,
void *arg); void *arg);
static void lm75_inc_use(struct i2c_client *client);
static void lm75_dec_use(struct i2c_client *client);
static u16 swap_bytes(u16 val); static u16 swap_bytes(u16 val);
static int lm75_read_value(struct i2c_client *client, u8 reg); static int lm75_read_value(struct i2c_client *client, u8 reg);
static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value); static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value);
...@@ -84,14 +82,12 @@ static void lm75_update_client(struct i2c_client *client); ...@@ -84,14 +82,12 @@ static void lm75_update_client(struct i2c_client *client);
/* This is the driver that will be inserted */ /* This is the driver that will be inserted */
static struct i2c_driver lm75_driver = { static struct i2c_driver lm75_driver = {
/* name */ "LM75 sensor chip driver", .name = "LM75 sensor chip driver",
/* id */ I2C_DRIVERID_LM75, .id = I2C_DRIVERID_LM75,
/* flags */ I2C_DF_NOTIFY, .flags = I2C_DF_NOTIFY,
/* attach_adapter */ &lm75_attach_adapter, .attach_adapter = lm75_attach_adapter,
/* detach_client */ &lm75_detach_client, .detach_client = lm75_detach_client,
/* command */ &lm75_command, .command = lm75_command,
/* inc_use */ &lm75_inc_use,
/* dec_use */ &lm75_dec_use
}; };
/* These files are created for each detected LM75. This is just a template; /* These files are created for each detected LM75. This is just a template;
...@@ -221,24 +217,11 @@ int lm75_detect(struct i2c_adapter *adapter, int address, ...@@ -221,24 +217,11 @@ int lm75_detect(struct i2c_adapter *adapter, int address,
int lm75_detach_client(struct i2c_client *client) int lm75_detach_client(struct i2c_client *client)
{ {
int err; struct lm75_data *data = client->data;
#ifdef MODULE
if (MOD_IN_USE)
return -EBUSY;
#endif
i2c_deregister_entry(((struct lm75_data *) (client->data))->
sysctl_id);
if ((err = i2c_detach_client(client))) {
printk
("lm75.o: Client deregistration failed, client not detached.\n");
return err;
}
i2c_deregister_entry(data->sysctl_id);
i2c_detach_client(client);
kfree(client); kfree(client);
return 0; return 0;
} }
...@@ -247,16 +230,6 @@ int lm75_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -247,16 +230,6 @@ int lm75_command(struct i2c_client *client, unsigned int cmd, void *arg)
return 0; return 0;
} }
void lm75_inc_use(struct i2c_client *client)
{
MOD_INC_USE_COUNT;
}
void lm75_dec_use(struct i2c_client *client)
{
MOD_DEC_USE_COUNT;
}
u16 swap_bytes(u16 val) u16 swap_bytes(u16 val)
{ {
return (val >> 8) | (val << 8); return (val >> 8) | (val << 8);
......
...@@ -184,35 +184,6 @@ static void iic_ite_release(void) ...@@ -184,35 +184,6 @@ static void iic_ite_release(void)
release_region(gpi.iic_base , 2); 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. * Encapsulate the above functions in the correct operations structure.
* This is only done when more than one hardware adapter is supported. * This is only done when more than one hardware adapter is supported.
...@@ -228,14 +199,10 @@ static struct i2c_algo_iic_data iic_ite_data = { ...@@ -228,14 +199,10 @@ static struct i2c_algo_iic_data iic_ite_data = {
}; };
static struct i2c_adapter iic_ite_ops = { static struct i2c_adapter iic_ite_ops = {
"ITE IIC adapter", .owner = THIS_MODULE,
I2C_HW_I_IIC, .name = "ITE IIC adapter",
NULL, .id = I2C_HW_I_IIC,
&iic_ite_data, .algo_data = &iic_ite_data,
iic_ite_inc_use,
iic_ite_dec_use,
iic_ite_reg,
iic_ite_unreg,
}; };
/* Called when the module is loaded. This function starts the /* Called when the module is loaded. This function starts the
......
...@@ -529,14 +529,11 @@ static u32 bit_func(struct i2c_adapter *adap) ...@@ -529,14 +529,11 @@ static u32 bit_func(struct i2c_adapter *adap)
/* -----exported algorithm data: ------------------------------------- */ /* -----exported algorithm data: ------------------------------------- */
static struct i2c_algorithm i2c_bit_algo = { static struct i2c_algorithm i2c_bit_algo = {
"Bit-shift algorithm", .name = "Bit-shift algorithm",
I2C_ALGO_BIT, .id = I2C_ALGO_BIT,
bit_xfer, .master_xfer = bit_xfer,
NULL, .algo_control = algo_control,
NULL, /* slave_xmit */ .functionality = bit_func,
NULL, /* slave_recv */
algo_control, /* ioctl */
bit_func, /* functionality */
}; };
/* /*
...@@ -581,11 +578,7 @@ int i2c_bit_add_bus(struct i2c_adapter *adap) ...@@ -581,11 +578,7 @@ int i2c_bit_add_bus(struct i2c_adapter *adap)
printk("\n"); printk("\n");
} }
#ifdef MODULE
MOD_INC_USE_COUNT;
#endif
i2c_add_adapter(adap); i2c_add_adapter(adap);
return 0; return 0;
} }
...@@ -599,9 +592,6 @@ int i2c_bit_del_bus(struct i2c_adapter *adap) ...@@ -599,9 +592,6 @@ int i2c_bit_del_bus(struct i2c_adapter *adap)
DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: adapter unregistered: %s\n",adap->name)); DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: adapter unregistered: %s\n",adap->name));
#ifdef MODULE
MOD_DEC_USE_COUNT;
#endif
return 0; return 0;
} }
......
...@@ -474,10 +474,6 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap) ...@@ -474,10 +474,6 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
return i; return i;
} }
#ifdef MODULE
MOD_INC_USE_COUNT;
#endif
i2c_add_adapter(adap); i2c_add_adapter(adap);
/* scan bus */ /* scan bus */
...@@ -509,15 +505,7 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap) ...@@ -509,15 +505,7 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
int i2c_pcf_del_bus(struct i2c_adapter *adap) int i2c_pcf_del_bus(struct i2c_adapter *adap)
{ {
int res; return i2c_del_adapter(adap);
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;
} }
EXPORT_SYMBOL(i2c_pcf_add_bus); EXPORT_SYMBOL(i2c_pcf_add_bus);
......
...@@ -446,24 +446,23 @@ int i2c_detach_client(struct i2c_client *client) ...@@ -446,24 +446,23 @@ int i2c_detach_client(struct i2c_client *client)
return 0; return 0;
} }
void i2c_inc_use_client(struct i2c_client *client) static int i2c_inc_use_client(struct i2c_client *client)
{ {
if (client->driver->inc_use != NULL) if (!try_module_get(client->driver->owner))
client->driver->inc_use(client); return -ENODEV;
if (!try_module_get(client->adapter->owner)) {
module_put(client->driver->owner);
return -ENODEV;
}
if (client->adapter->inc_use != NULL) return 0;
client->adapter->inc_use(client->adapter);
} }
void i2c_dec_use_client(struct i2c_client *client) static void i2c_dec_use_client(struct i2c_client *client)
{ {
module_put(client->driver->owner);
if (client->driver->dec_use != NULL) module_put(client->adapter->owner);
client->driver->dec_use(client);
if (client->adapter->dec_use != NULL)
client->adapter->dec_use(client->adapter);
} }
struct i2c_client *i2c_get_client(int driver_id, int adapter_id, struct i2c_client *i2c_get_client(int driver_id, int adapter_id,
...@@ -535,20 +534,22 @@ struct i2c_client *i2c_get_client(int driver_id, int adapter_id, ...@@ -535,20 +534,22 @@ struct i2c_client *i2c_get_client(int driver_id, int adapter_id,
int i2c_use_client(struct i2c_client *client) int i2c_use_client(struct i2c_client *client)
{ {
if(client->flags & I2C_CLIENT_ALLOW_USE) { if (!i2c_inc_use_client(client))
if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) return -ENODEV;
if (client->flags & I2C_CLIENT_ALLOW_USE) {
if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE)
client->usage_count++;
else if (client->usage_count > 0)
goto busy;
else
client->usage_count++; client->usage_count++;
else {
if(client->usage_count > 0)
return -EBUSY;
else
client->usage_count++;
}
} }
i2c_inc_use_client(client);
return 0; return 0;
busy:
i2c_dec_use_client(client);
return -EBUSY;
} }
int i2c_release_client(struct i2c_client *client) int i2c_release_client(struct i2c_client *client)
...@@ -1420,8 +1421,6 @@ EXPORT_SYMBOL(i2c_add_driver); ...@@ -1420,8 +1421,6 @@ EXPORT_SYMBOL(i2c_add_driver);
EXPORT_SYMBOL(i2c_del_driver); EXPORT_SYMBOL(i2c_del_driver);
EXPORT_SYMBOL(i2c_attach_client); EXPORT_SYMBOL(i2c_attach_client);
EXPORT_SYMBOL(i2c_detach_client); EXPORT_SYMBOL(i2c_detach_client);
EXPORT_SYMBOL(i2c_inc_use_client);
EXPORT_SYMBOL(i2c_dec_use_client);
EXPORT_SYMBOL(i2c_get_client); EXPORT_SYMBOL(i2c_get_client);
EXPORT_SYMBOL(i2c_use_client); EXPORT_SYMBOL(i2c_use_client);
EXPORT_SYMBOL(i2c_release_client); EXPORT_SYMBOL(i2c_release_client);
......
...@@ -364,8 +364,10 @@ int i2cdev_open (struct inode *inode, struct file *file) ...@@ -364,8 +364,10 @@ int i2cdev_open (struct inode *inode, struct file *file)
client->adapter = i2cdev_adaps[minor]; client->adapter = i2cdev_adaps[minor];
file->private_data = client; file->private_data = client;
if (i2cdev_adaps[minor]->inc_use) if (!try_module_get(i2cdev_adaps[minor]->owner)) {
i2cdev_adaps[minor]->inc_use(i2cdev_adaps[minor]); kfree(client);
return -ENODEV;
}
#ifdef DEBUG #ifdef DEBUG
printk(KERN_DEBUG "i2c-dev.o: opened i2c-%d\n",minor); printk(KERN_DEBUG "i2c-dev.o: opened i2c-%d\n",minor);
...@@ -381,10 +383,7 @@ static int i2cdev_release (struct inode *inode, struct file *file) ...@@ -381,10 +383,7 @@ static int i2cdev_release (struct inode *inode, struct file *file)
#ifdef DEBUG #ifdef DEBUG
printk(KERN_DEBUG "i2c-dev.o: Closed: i2c-%d\n", minor); printk(KERN_DEBUG "i2c-dev.o: Closed: i2c-%d\n", minor);
#endif #endif
lock_kernel(); module_put(i2cdev_adaps[minor]->owner);
if (i2cdev_adaps[minor]->dec_use)
i2cdev_adaps[minor]->dec_use(i2cdev_adaps[minor]);
unlock_kernel();
return 0; return 0;
} }
......
...@@ -142,7 +142,7 @@ static void pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs *regs) { ...@@ -142,7 +142,7 @@ static void pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs *regs) {
static int pcf_isa_init(void) static int pcf_isa_init(void)
{ {
if (!mmapped) { if (!mmapped) {
if (!request_region(base, 2, "i2c (isa bus adapter)")) if (!request_region(base, 2, "i2c (isa bus adapter)")) {
printk(KERN_ERR printk(KERN_ERR
"i2c-elektor.o: requested I/O region (0x%X:2) " "i2c-elektor.o: requested I/O region (0x%X:2) "
"is in use.\n", base); "is in use.\n", base);
...@@ -159,32 +159,6 @@ static int pcf_isa_init(void) ...@@ -159,32 +159,6 @@ static int pcf_isa_init(void)
return 0; 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. * Encapsulate the above functions in the correct operations structure.
* This is only done when more than one hardware adapter is supported. * This is only done when more than one hardware adapter is supported.
...@@ -201,13 +175,10 @@ static struct i2c_algo_pcf_data pcf_isa_data = { ...@@ -201,13 +175,10 @@ static struct i2c_algo_pcf_data pcf_isa_data = {
}; };
static struct i2c_adapter pcf_isa_ops = { static struct i2c_adapter pcf_isa_ops = {
.owner = THIS_MODULE,
.name = "PCF8584 ISA adapter", .name = "PCF8584 ISA adapter",
.id = I2C_HW_P_ELEK, .id = I2C_HW_P_ELEK,
.algo_data = &pcf_isa_data, .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) static int __init i2c_pcfisa_init(void)
......
...@@ -115,30 +115,6 @@ static int bit_elv_init(void) ...@@ -115,30 +115,6 @@ static int bit_elv_init(void)
return -ENODEV; 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. * Encapsulate the above functions in the correct operations structure.
* This is only done when more than one hardware adapter is supported. * This is only done when more than one hardware adapter is supported.
...@@ -153,14 +129,10 @@ static struct i2c_algo_bit_data bit_elv_data = { ...@@ -153,14 +129,10 @@ static struct i2c_algo_bit_data bit_elv_data = {
}; };
static struct i2c_adapter bit_elv_ops = { static struct i2c_adapter bit_elv_ops = {
"ELV Parallel port adaptor", .owner = THIS_MODULE,
I2C_HW_B_ELV, .name = "ELV Parallel port adaptor",
NULL, .id = I2C_HW_B_ELV,
&bit_elv_data, .algo_data = &bit_elv_data,
bit_elv_inc_use,
bit_elv_dec_use,
bit_elv_reg,
bit_elv_unreg,
}; };
static int __init i2c_bitelv_init(void) static int __init i2c_bitelv_init(void)
......
...@@ -61,44 +61,21 @@ static struct i2c_algo_bit_data bit_frodo_data = { ...@@ -61,44 +61,21 @@ static struct i2c_algo_bit_data bit_frodo_data = {
.timeout = 100 .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 = { static struct i2c_adapter frodo_ops = {
.owner = THIS_MODULE,
.name = "Frodo adapter driver", .name = "Frodo adapter driver",
.id = I2C_HW_B_FRODO, .id = I2C_HW_B_FRODO,
.algo_data = &bit_frodo_data, .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) 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) 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 <abraham@2d3d.co.za>"); MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>");
......
...@@ -129,26 +129,6 @@ static int bit_lp_getsda2(void *data) ...@@ -129,26 +129,6 @@ static int bit_lp_getsda2(void *data)
PARPORT_STATUS_BUSY) ? 0 : 1; 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. * Encapsulate the above functions in the correct operations structure.
* This is only done when more than one hardware adapter is supported. * This is only done when more than one hardware adapter is supported.
...@@ -173,15 +153,9 @@ static struct i2c_algo_bit_data bit_lp_data2 = { ...@@ -173,15 +153,9 @@ static struct i2c_algo_bit_data bit_lp_data2 = {
}; };
static struct i2c_adapter bit_lp_ops = { static struct i2c_adapter bit_lp_ops = {
"Philips Parallel port adapter", .owner = THIS_MODULE,
I2C_HW_B_LP, .name = "Philips Parallel port adapter",
NULL, .id = I2C_HW_B_LP,
NULL,
bit_lp_inc_use,
bit_lp_dec_use,
bit_lp_reg,
bit_lp_unreg,
}; };
static void i2c_parport_attach (struct parport *port) static void i2c_parport_attach (struct parport *port)
......
...@@ -210,49 +210,6 @@ void i2c_deregister_entry(int id) ...@@ -210,49 +210,6 @@ void i2c_deregister_entry(int id)
} }
} }
/* Monitor access for /proc/sys/dev/sensors; make unloading i2c-proc.o
impossible if some process still uses it or some file in it */
void i2c_fill_inode(struct inode *inode, int fill)
{
if (fill)
MOD_INC_USE_COUNT;
else
MOD_DEC_USE_COUNT;
}
/* Monitor access for /proc/sys/dev/sensors/ directories; make unloading
the corresponding module impossible if some process still uses it or
some file in it */
void i2c_dir_fill_inode(struct inode *inode, int fill)
{
int i;
struct i2c_client *client;
#ifdef DEBUG
if (!inode) {
printk(KERN_ERR "i2c-proc.o: Warning: inode NULL in fill_inode()\n");
return;
}
#endif /* def DEBUG */
for (i = 0; i < SENSORS_ENTRY_MAX; i++)
if (i2c_clients[i]
&& (i2c_inodes[i] == inode->i_ino)) break;
#ifdef DEBUG
if (i == SENSORS_ENTRY_MAX) {
printk
(KERN_ERR "i2c-proc.o: Warning: inode (%ld) not found in fill_inode()\n",
inode->i_ino);
return;
}
#endif /* def DEBUG */
client = i2c_clients[i];
if (fill)
client->driver->inc_use(client);
else
client->driver->dec_use(client);
}
int i2c_proc_chips(ctl_table * ctl, int write, struct file *filp, int i2c_proc_chips(ctl_table * ctl, int write, struct file *filp,
void *buffer, size_t * lenp) void *buffer, size_t * lenp)
{ {
......
...@@ -66,44 +66,15 @@ static int rpx_install_isr(int irq, void (*func)(void *, void *), void *data) ...@@ -66,44 +66,15 @@ static int rpx_install_isr(int irq, void (*func)(void *, void *), void *data)
return 0; 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 = { static struct i2c_algo_8xx_data rpx_data = {
.setisr = rpx_install_isr .setisr = rpx_install_isr
}; };
static struct i2c_adapter rpx_ops = { static struct i2c_adapter rpx_ops = {
"m8xx", .owner = THIS_MODULE,
I2C_HW_MPC8XX_EPON, .name = "m8xx",
NULL, .id = I2C_HW_MPC8XX_EPON,
&rpx_data, .algo_data = &rpx_data,
rpx_inc_use,
rpx_dec_use,
rpx_reg,
rpx_unreg,
}; };
int __init i2c_rpx_init(void) int __init i2c_rpx_init(void)
......
...@@ -89,43 +89,15 @@ static int bit_velle_getsda(void *data) ...@@ -89,43 +89,15 @@ static int bit_velle_getsda(void *data)
static int bit_velle_init(void) static int bit_velle_init(void)
{ {
if (check_region(base,(base == 0x3bc)? 3 : 8) < 0 ) { if (!request_region(base, (base == 0x3bc) ? 3 : 8,
DEBE(printk(KERN_DEBUG "i2c-velleman.o: Port %#x already in use.\n", "i2c (Vellemann adapter)"))
base));
return -ENODEV; return -ENODEV;
} else {
request_region(base, (base == 0x3bc)? 3 : 8,
"i2c (Vellemann adapter)");
bit_velle_setsda((void*)base,1);
bit_velle_setscl((void*)base,1);
}
return 0;
}
static int bit_velle_reg(struct i2c_client *client)
{
return 0;
}
static int bit_velle_unreg(struct i2c_client *client) bit_velle_setsda((void*)base,1);
{ bit_velle_setscl((void*)base,1);
return 0; return 0;
} }
static void bit_velle_inc_use(struct i2c_adapter *adap)
{
#ifdef MODULE
MOD_INC_USE_COUNT;
#endif
}
static void bit_velle_dec_use(struct i2c_adapter *adap)
{
#ifdef MODULE
MOD_DEC_USE_COUNT;
#endif
}
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
* Encapsulate the above functions in the correct operations structure. * Encapsulate the above functions in the correct operations structure.
* This is only done when more than one hardware adapter is supported. * This is only done when more than one hardware adapter is supported.
...@@ -141,14 +113,10 @@ static struct i2c_algo_bit_data bit_velle_data = { ...@@ -141,14 +113,10 @@ static struct i2c_algo_bit_data bit_velle_data = {
}; };
static struct i2c_adapter bit_velle_ops = { static struct i2c_adapter bit_velle_ops = {
"Velleman K8000", .owner = THIS_MODULE,
I2C_HW_B_VELLE, .name = "Velleman K8000",
NULL, .id = I2C_HW_B_VELLE,
&bit_velle_data, .algo_data = &bit_velle_data,
bit_velle_inc_use,
bit_velle_dec_use,
bit_velle_reg,
bit_velle_unreg,
}; };
static int __init i2c_bitvelle_init(void) static int __init i2c_bitvelle_init(void)
......
...@@ -397,26 +397,6 @@ static u32 scx200_acb_func(struct i2c_adapter *adapter) ...@@ -397,26 +397,6 @@ static u32 scx200_acb_func(struct i2c_adapter *adapter)
I2C_FUNC_SMBUS_BLOCK_DATA; 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) */ /* For now, we only handle combined mode (smbus) */
static struct i2c_algorithm scx200_acb_algorithm = { static struct i2c_algorithm scx200_acb_algorithm = {
.name = "NatSemi SCx200 ACCESS.bus", .name = "NatSemi SCx200 ACCESS.bus",
...@@ -479,12 +459,9 @@ static int __init scx200_acb_create(int base, int index) ...@@ -479,12 +459,9 @@ static int __init scx200_acb_create(int base, int index)
adapter = &iface->adapter; adapter = &iface->adapter;
adapter->data = iface; adapter->data = iface;
sprintf(adapter->name, "SCx200 ACB%d", index); sprintf(adapter->name, "SCx200 ACB%d", index);
adapter->owner = THIS_MODULE;
adapter->id = I2C_ALGO_SMBUS; adapter->id = I2C_ALGO_SMBUS;
adapter->algo = &scx200_acb_algorithm; 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); init_MUTEX(&iface->sem);
......
...@@ -66,26 +66,6 @@ static int scx200_i2c_getsda(void *data) ...@@ -66,26 +66,6 @@ static int scx200_i2c_getsda(void *data)
return scx200_gpio_get(sda); 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. * Encapsulate the above functions in the correct operations structure.
* This is only done when more than one hardware adapter is supported. * This is only done when more than one hardware adapter is supported.
...@@ -101,13 +81,10 @@ static struct i2c_algo_bit_data scx200_i2c_data = { ...@@ -101,13 +81,10 @@ static struct i2c_algo_bit_data scx200_i2c_data = {
}; };
static struct i2c_adapter scx200_i2c_ops = { static struct i2c_adapter scx200_i2c_ops = {
.owner = THIS_MODULE,
.name = "NatSemi SCx200 I2C", .name = "NatSemi SCx200 I2C",
.id = I2C_HW_B_VELLE, .id = I2C_HW_B_VELLE,
.algo_data = &scx200_i2c_data, .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) int scx200_i2c_init(void)
......
...@@ -396,39 +396,26 @@ static int adv717x_command(struct i2c_client *client, unsigned int cmd, ...@@ -396,39 +396,26 @@ static int adv717x_command(struct i2c_client *client, unsigned int cmd,
return 0; 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 = { static struct i2c_driver i2c_driver_adv7175 = {
.owner = THIS_MODULE,
.name = "adv7175", /* name */ .name = "adv7175", /* name */
.id = I2C_DRIVERID_ADV717x, /* ID */ .id = I2C_DRIVERID_ADV717x, /* ID */
.flags = I2C_DF_NOTIFY, //I2C_ADV7175, I2C_ADV7175 + 3, .flags = I2C_DF_NOTIFY, //I2C_ADV7175, I2C_ADV7175 + 3,
.attach_adapter = adv717x_probe, .attach_adapter = adv717x_probe,
.detach_client = adv717x_detach, .detach_client = adv717x_detach,
.command = adv717x_command, .command = adv717x_command,
.inc_use = &adv717x_inc_use,
.dec_use = &adv717x_dec_use
}; };
static struct i2c_driver i2c_driver_adv7176 = { static struct i2c_driver i2c_driver_adv7176 = {
.owner = THIS_MODULE,
.name = "adv7176", /* name */ .name = "adv7176", /* name */
.id = I2C_DRIVERID_ADV717x, /* ID */ .id = I2C_DRIVERID_ADV717x, /* ID */
.flags = I2C_DF_NOTIFY, //I2C_ADV7176, I2C_ADV7176 + 3, .flags = I2C_DF_NOTIFY, //I2C_ADV7176, I2C_ADV7176 + 3,
.attach_adapter = adv717x_probe, .attach_adapter = adv717x_probe,
.detach_client = adv717x_detach, .detach_client = adv717x_detach,
.command = adv717x_command, .command = adv717x_command,
.inc_use = &adv717x_inc_use,
.dec_use = &adv717x_dec_use
}; };
static struct i2c_client client_template = { static struct i2c_client client_template = {
......
...@@ -194,16 +194,6 @@ static int bttv_bit_getsda(void *data) ...@@ -194,16 +194,6 @@ static int bttv_bit_getsda(void *data)
return state; 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) static int attach_inform(struct i2c_client *client)
{ {
struct bttv *btv = (struct bttv*)client->adapter->data; struct bttv *btv = (struct bttv*)client->adapter->data;
...@@ -272,10 +262,9 @@ static struct i2c_algo_bit_data bttv_i2c_algo_template = { ...@@ -272,10 +262,9 @@ static struct i2c_algo_bit_data bttv_i2c_algo_template = {
}; };
static struct i2c_adapter bttv_i2c_adap_template = { static struct i2c_adapter bttv_i2c_adap_template = {
.owner = THIS_MODULE,
.name = "bt848", .name = "bt848",
.id = I2C_HW_B_BT848, .id = I2C_HW_B_BT848,
.inc_use = bttv_inc_use,
.dec_use = bttv_dec_use,
.client_register = attach_inform, .client_register = attach_inform,
.client_unregister = detach_inform, .client_unregister = detach_inform,
}; };
......
...@@ -318,16 +318,6 @@ static u32 functionality(struct i2c_adapter *adap) ...@@ -318,16 +318,6 @@ static u32 functionality(struct i2c_adapter *adap)
return I2C_FUNC_SMBUS_EMUL; 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) static int attach_inform(struct i2c_client *client)
{ {
struct saa7134_dev *dev = client->adapter->algo_data; struct saa7134_dev *dev = client->adapter->algo_data;
...@@ -346,11 +336,10 @@ static struct i2c_algorithm saa7134_algo = { ...@@ -346,11 +336,10 @@ static struct i2c_algorithm saa7134_algo = {
}; };
static struct i2c_adapter saa7134_adap_template = { static struct i2c_adapter saa7134_adap_template = {
.owner = THIS_MODULE,
.name = "saa7134", .name = "saa7134",
.id = I2C_ALGO_SAA7134, .id = I2C_ALGO_SAA7134,
.algo = &saa7134_algo, .algo = &saa7134_algo,
.inc_use = inc_use,
.dec_use = dec_use,
.client_register = attach_inform, .client_register = attach_inform,
}; };
......
...@@ -195,8 +195,9 @@ static int tvmixer_open(struct inode *inode, struct file *file) ...@@ -195,8 +195,9 @@ static int tvmixer_open(struct inode *inode, struct file *file)
/* lock bttv in memory while the mixer is in use */ /* lock bttv in memory while the mixer is in use */
file->private_data = mix; 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; return 0;
} }
...@@ -210,8 +211,7 @@ static int tvmixer_release(struct inode *inode, struct file *file) ...@@ -210,8 +211,7 @@ static int tvmixer_release(struct inode *inode, struct file *file)
return -ENODEV; return -ENODEV;
} }
if (client->adapter->dec_use) module_put(client->adapter->owner);
client->adapter->dec_use(client->adapter);
return 0; return 0;
} }
......
...@@ -87,19 +87,10 @@ static int matroxfb_gpio_getscl(void* data) { ...@@ -87,19 +87,10 @@ static int matroxfb_gpio_getscl(void* data) {
return (matroxfb_read_gpio(b->minfo) & b->mask.clock) ? 1 : 0; 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 = static struct i2c_adapter matrox_i2c_adapter_template =
{ {
.owner = THIS_MODULE,
.id = I2C_HW_B_G400, .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 = static struct i2c_algo_bit_data matrox_i2c_algo_template =
......
...@@ -945,14 +945,6 @@ static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END }; ...@@ -945,14 +945,6 @@ static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END };
static unsigned short normal_i2c_range[] = { MAVEN_I2CID, MAVEN_I2CID, I2C_CLIENT_END }; static unsigned short normal_i2c_range[] = { MAVEN_I2CID, MAVEN_I2CID, I2C_CLIENT_END };
I2C_CLIENT_INSMOD; 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 struct i2c_driver maven_driver;
static int maven_detect_client(struct i2c_adapter* adapter, int address, unsigned short flags, static int maven_detect_client(struct i2c_adapter* adapter, int address, unsigned short flags,
...@@ -1016,17 +1008,13 @@ static int maven_command(struct i2c_client* client, unsigned int cmd, void* arg) ...@@ -1016,17 +1008,13 @@ static int maven_command(struct i2c_client* client, unsigned int cmd, void* arg)
return -ENOIOCTLCMD; /* or -EINVAL, depends on who will call this */ return -ENOIOCTLCMD; /* or -EINVAL, depends on who will call this */
} }
static int maven_driver_registered = 0;
static struct i2c_driver maven_driver={ static struct i2c_driver maven_driver={
"maven", .owner = THIS_MODULE,
I2C_DRIVERID_MGATVO, .name = "maven",
I2C_DF_NOTIFY, .id = I2C_DRIVERID_MGATVO,
maven_attach_adapter, .flags = I2C_DF_NOTIFY,
maven_detach_client, .attach_adapter = maven_attach_adapter,
maven_command, .detach_client = maven_detach_client,
maven_inc_use,
maven_dec_use
}; };
/* ************************** */ /* ************************** */
...@@ -1039,13 +1027,11 @@ static int matroxfb_maven_init(void) { ...@@ -1039,13 +1027,11 @@ static int matroxfb_maven_init(void) {
printk(KERN_ERR "maven: Maven driver failed to register (%d).\n", err); printk(KERN_ERR "maven: Maven driver failed to register (%d).\n", err);
return err; return err;
} }
maven_driver_registered = 1;
return 0; return 0;
} }
static void matroxfb_maven_exit(void) { 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 <vandrove@vc.cvut.cz>"); MODULE_AUTHOR("(c) 1999-2002 Petr Vandrovec <vandrove@vc.cvut.cz>");
......
...@@ -132,6 +132,7 @@ extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, ...@@ -132,6 +132,7 @@ extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client,
*/ */
struct i2c_driver { struct i2c_driver {
struct module *owner;
char name[32]; char name[32];
int id; int id;
unsigned int flags; /* div., see below */ unsigned int flags; /* div., see below */
...@@ -155,18 +156,6 @@ struct i2c_driver { ...@@ -155,18 +156,6 @@ struct i2c_driver {
* with the device. * with the device.
*/ */
int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); 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 @@ struct proc_dir_entry; ...@@ -232,16 +221,13 @@ struct proc_dir_entry;
* with the access algorithms necessary to access it. * with the access algorithms necessary to access it.
*/ */
struct i2c_adapter { struct i2c_adapter {
struct module *owner;
char name[32]; /* some useful name to identify the adapter */ char name[32]; /* some useful name to identify the adapter */
unsigned int id;/* == is algo->id | hwdep.struct->id, */ unsigned int id;/* == is algo->id | hwdep.struct->id, */
/* for registered values see below */ /* for registered values see below */
struct i2c_algorithm *algo;/* the algorithm to access the bus */ struct i2c_algorithm *algo;/* the algorithm to access the bus */
void *algo_data; 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. */ /* --- administration stuff. */
int (*client_register)(struct i2c_client *); int (*client_register)(struct i2c_client *);
int (*client_unregister)(struct i2c_client *); int (*client_unregister)(struct i2c_client *);
...@@ -319,12 +305,6 @@ extern int i2c_del_driver(struct i2c_driver *); ...@@ -319,12 +305,6 @@ extern int i2c_del_driver(struct i2c_driver *);
extern int i2c_attach_client(struct i2c_client *); extern int i2c_attach_client(struct i2c_client *);
extern int i2c_detach_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 /* New function: This is to get an i2c_client-struct for controlling the
client either by using i2c_control-function or having the client either by using i2c_control-function or having the
client-module export functions that can be used with the i2c_client client-module export functions that can be used with the i2c_client
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment