Commit e4c95e8e authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge gregkh@kernel.bkbits.net:/home/gregkh/linux/i2c-2.5

into kroah.com:/home/linux/linux/BK/i2c-2.5
parents d84366b4 b345ff48
...@@ -474,9 +474,11 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -474,9 +474,11 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter ali15x3_adapter = { static struct i2c_adapter ali15x3_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "unset",
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI15X3, .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI15X3,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.dev = {
.name = "unset",
},
}; };
static struct pci_device_id ali15x3_ids[] __devinitdata = { static struct pci_device_id ali15x3_ids[] __devinitdata = {
...@@ -500,8 +502,8 @@ static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_ ...@@ -500,8 +502,8 @@ static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_
/* set up the driverfs linkage to our parent device */ /* set up the driverfs linkage to our parent device */
ali15x3_adapter.dev.parent = &dev->dev; ali15x3_adapter.dev.parent = &dev->dev;
sprintf(ali15x3_adapter.name, "SMBus ALI15X3 adapter at %04x", snprintf(ali15x3_adapter.dev.name, DEVICE_NAME_SIZE,
ali15x3_smba); "SMBus ALI15X3 adapter at %04x", ali15x3_smba);
return i2c_add_adapter(&ali15x3_adapter); return i2c_add_adapter(&ali15x3_adapter);
} }
......
...@@ -312,9 +312,11 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -312,9 +312,11 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter amd756_adapter = { static struct i2c_adapter amd756_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "unset",
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756, .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.dev = {
.name = "unset",
},
}; };
enum chiptype { AMD756, AMD766, AMD768, NFORCE }; enum chiptype { AMD756, AMD766, AMD768, NFORCE };
...@@ -376,7 +378,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev, ...@@ -376,7 +378,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
/* set up the driverfs linkage to our parent device */ /* set up the driverfs linkage to our parent device */
amd756_adapter.dev.parent = &pdev->dev; amd756_adapter.dev.parent = &pdev->dev;
sprintf(amd756_adapter.name, snprintf(amd756_adapter.dev.name, DEVICE_NAME_SIZE,
"SMBus AMD75x adapter at %04x", amd756_ioport); "SMBus AMD75x adapter at %04x", amd756_ioport);
error = i2c_add_adapter(&amd756_adapter); error = i2c_add_adapter(&amd756_adapter);
......
...@@ -357,7 +357,7 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ ...@@ -357,7 +357,7 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
goto out_kfree; goto out_kfree;
smbus->adapter.owner = THIS_MODULE; smbus->adapter.owner = THIS_MODULE;
sprintf(smbus->adapter.name, snprintf(smbus->adapter.dev.name, DEVICE_NAME_SIZE,
"SMBus2 AMD8111 adapter at %04x", smbus->base); "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;
......
...@@ -546,9 +546,11 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -546,9 +546,11 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter i801_adapter = { static struct i2c_adapter i801_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "unset",
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_I801, .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_I801,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.dev = {
.name = "unset",
},
}; };
static struct pci_device_id i801_ids[] __devinitdata = { static struct pci_device_id i801_ids[] __devinitdata = {
...@@ -597,8 +599,8 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id ...@@ -597,8 +599,8 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
/* set up the driverfs linkage to our parent device */ /* set up the driverfs linkage to our parent device */
i801_adapter.dev.parent = &dev->dev; i801_adapter.dev.parent = &dev->dev;
sprintf(i801_adapter.name, "SMBus I801 adapter at %04x", snprintf(i801_adapter.dev.name, DEVICE_NAME_SIZE,
i801_smba); "SMBus I801 adapter at %04x", i801_smba);
return i2c_add_adapter(&i801_adapter); return i2c_add_adapter(&i801_adapter);
} }
......
...@@ -39,9 +39,11 @@ static struct i2c_algorithm isa_algorithm = { ...@@ -39,9 +39,11 @@ static struct i2c_algorithm isa_algorithm = {
/* There can only be one... */ /* There can only be one... */
static struct i2c_adapter isa_adapter = { static struct i2c_adapter isa_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "ISA main adapter",
.id = I2C_ALGO_ISA | I2C_HW_ISA, .id = I2C_ALGO_ISA | I2C_HW_ISA,
.algo = &isa_algorithm, .algo = &isa_algorithm,
.dev = {
.name = "ISA main adapter",
},
}; };
static int __init i2c_isa_init(void) static int __init i2c_isa_init(void)
......
...@@ -394,9 +394,11 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -394,9 +394,11 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter piix4_adapter = { static struct i2c_adapter piix4_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "unset",
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_PIIX4, .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_PIIX4,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.dev = {
.name = "unset",
},
}; };
static struct pci_device_id piix4_ids[] __devinitdata = { static struct pci_device_id piix4_ids[] __devinitdata = {
...@@ -449,8 +451,8 @@ static int __devinit piix4_probe(struct pci_dev *dev, const struct pci_device_id ...@@ -449,8 +451,8 @@ static int __devinit piix4_probe(struct pci_dev *dev, const struct pci_device_id
/* set up the driverfs linkage to our parent device */ /* set up the driverfs linkage to our parent device */
piix4_adapter.dev.parent = &dev->dev; piix4_adapter.dev.parent = &dev->dev;
sprintf(piix4_adapter.name, "SMBus PIIX4 adapter at %04x", snprintf(piix4_adapter.dev.name, DEVICE_NAME_SIZE,
piix4_smba); "SMBus PIIX4 adapter at %04x", piix4_smba);
retval = i2c_add_adapter(&piix4_adapter); retval = i2c_add_adapter(&piix4_adapter);
......
...@@ -144,7 +144,7 @@ static int read_only = 0; ...@@ -144,7 +144,7 @@ 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 = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "ADM1021, MAX1617 sensor driver", .name = "ADM1021-MAX1617",
.id = I2C_DRIVERID_ADM1021, .id = I2C_DRIVERID_ADM1021,
.flags = I2C_DF_NOTIFY, .flags = I2C_DF_NOTIFY,
.attach_adapter = adm1021_attach_adapter, .attach_adapter = adm1021_attach_adapter,
...@@ -221,10 +221,12 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, ...@@ -221,10 +221,12 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
err = -ENOMEM; err = -ENOMEM;
goto error0; goto error0;
} }
memset(new_client, 0x00, sizeof(struct i2c_client) +
sizeof(struct adm1021_data));
data = (struct adm1021_data *) (new_client + 1); data = (struct adm1021_data *) (new_client + 1);
i2c_set_clientdata(new_client, data);
new_client->addr = address; new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter; new_client->adapter = adapter;
new_client->driver = &adm1021_driver; new_client->driver = &adm1021_driver;
new_client->flags = 0; new_client->flags = 0;
...@@ -299,7 +301,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, ...@@ -299,7 +301,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
} }
/* Fill in the remaining client fields and put it into the global list */ /* Fill in the remaining client fields and put it into the global list */
strcpy(new_client->name, client_name); strncpy(new_client->dev.name, client_name, DEVICE_NAME_SIZE);
data->type = kind; data->type = kind;
new_client->id = adm1021_id++; new_client->id = adm1021_id++;
...@@ -354,8 +356,7 @@ static int adm1021_detach_client(struct i2c_client *client) ...@@ -354,8 +356,7 @@ static int adm1021_detach_client(struct i2c_client *client)
int err; int err;
i2c_deregister_entry(((struct adm1021_data *) (client->data))-> i2c_deregister_entry(((struct adm1021_data *) (i2c_get_clientdata(client)))->sysctl_id);
sysctl_id);
if ((err = i2c_detach_client(client))) { if ((err = i2c_detach_client(client))) {
printk printk
...@@ -384,7 +385,7 @@ static int adm1021_write_value(struct i2c_client *client, u8 reg, u16 value) ...@@ -384,7 +385,7 @@ static int adm1021_write_value(struct i2c_client *client, u8 reg, u16 value)
static void adm1021_update_client(struct i2c_client *client) static void adm1021_update_client(struct i2c_client *client)
{ {
struct adm1021_data *data = client->data; struct adm1021_data *data = i2c_get_clientdata(client);
down(&data->update_lock); down(&data->update_lock);
...@@ -435,7 +436,7 @@ static void adm1021_update_client(struct i2c_client *client) ...@@ -435,7 +436,7 @@ static void adm1021_update_client(struct i2c_client *client)
static void adm1021_temp(struct i2c_client *client, int operation, static void adm1021_temp(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results) int ctl_name, int *nrels_mag, long *results)
{ {
struct adm1021_data *data = client->data; struct adm1021_data *data = i2c_get_clientdata(client);
if (operation == SENSORS_PROC_REAL_INFO) if (operation == SENSORS_PROC_REAL_INFO)
*nrels_mag = 0; *nrels_mag = 0;
...@@ -462,7 +463,7 @@ static void adm1021_temp(struct i2c_client *client, int operation, ...@@ -462,7 +463,7 @@ static void adm1021_temp(struct i2c_client *client, int operation,
static void adm1021_remote_temp(struct i2c_client *client, int operation, static 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)
{ {
struct adm1021_data *data = client->data; struct adm1021_data *data = i2c_get_clientdata(client);
int prec = 0; int prec = 0;
if (operation == SENSORS_PROC_REAL_INFO) if (operation == SENSORS_PROC_REAL_INFO)
...@@ -535,7 +536,7 @@ static void adm1021_remote_temp(struct i2c_client *client, int operation, ...@@ -535,7 +536,7 @@ static void adm1021_remote_temp(struct i2c_client *client, int operation,
static void adm1021_die_code(struct i2c_client *client, int operation, static void adm1021_die_code(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results) int ctl_name, int *nrels_mag, long *results)
{ {
struct adm1021_data *data = client->data; struct adm1021_data *data = i2c_get_clientdata(client);
if (operation == SENSORS_PROC_REAL_INFO) if (operation == SENSORS_PROC_REAL_INFO)
*nrels_mag = 0; *nrels_mag = 0;
...@@ -551,7 +552,7 @@ static void adm1021_die_code(struct i2c_client *client, int operation, ...@@ -551,7 +552,7 @@ static void adm1021_die_code(struct i2c_client *client, int operation,
static void adm1021_alarms(struct i2c_client *client, int operation, static void adm1021_alarms(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results) int ctl_name, int *nrels_mag, long *results)
{ {
struct adm1021_data *data = client->data; struct adm1021_data *data = i2c_get_clientdata(client);
if (operation == SENSORS_PROC_REAL_INFO) if (operation == SENSORS_PROC_REAL_INFO)
*nrels_mag = 0; *nrels_mag = 0;
else if (operation == SENSORS_PROC_REAL_READ) { else if (operation == SENSORS_PROC_REAL_READ) {
......
...@@ -82,7 +82,7 @@ static void lm75_update_client(struct i2c_client *client); ...@@ -82,7 +82,7 @@ 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 = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "LM75 sensor chip driver", .name = "LM75 sensor",
.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,
...@@ -140,10 +140,12 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, ...@@ -140,10 +140,12 @@ static int lm75_detect(struct i2c_adapter *adapter, int address,
err = -ENOMEM; err = -ENOMEM;
goto error0; goto error0;
} }
memset(new_client, 0x00, sizeof(struct i2c_client) +
sizeof(struct lm75_data));
data = (struct lm75_data *) (new_client + 1); data = (struct lm75_data *) (new_client + 1);
i2c_set_clientdata(new_client, data);
new_client->addr = address; new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter; new_client->adapter = adapter;
new_client->driver = &lm75_driver; new_client->driver = &lm75_driver;
new_client->flags = 0; new_client->flags = 0;
...@@ -180,7 +182,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, ...@@ -180,7 +182,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address,
} }
/* Fill in the remaining client fields and put it into the global list */ /* Fill in the remaining client fields and put it into the global list */
strcpy(new_client->name, client_name); strncpy(new_client->dev.name, client_name, DEVICE_NAME_SIZE);
new_client->id = lm75_id++; new_client->id = lm75_id++;
data->valid = 0; data->valid = 0;
...@@ -215,7 +217,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, ...@@ -215,7 +217,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address,
static int lm75_detach_client(struct i2c_client *client) static int lm75_detach_client(struct i2c_client *client)
{ {
struct lm75_data *data = client->data; struct lm75_data *data = i2c_get_clientdata(client);
i2c_deregister_entry(data->sysctl_id); i2c_deregister_entry(data->sysctl_id);
i2c_detach_client(client); i2c_detach_client(client);
...@@ -263,7 +265,7 @@ static void lm75_init_client(struct i2c_client *client) ...@@ -263,7 +265,7 @@ static void lm75_init_client(struct i2c_client *client)
static void lm75_update_client(struct i2c_client *client) static void lm75_update_client(struct i2c_client *client)
{ {
struct lm75_data *data = client->data; struct lm75_data *data = i2c_get_clientdata(client);
down(&data->update_lock); down(&data->update_lock);
...@@ -286,7 +288,7 @@ static void lm75_update_client(struct i2c_client *client) ...@@ -286,7 +288,7 @@ static void lm75_update_client(struct i2c_client *client)
static void lm75_temp(struct i2c_client *client, int operation, int ctl_name, static void lm75_temp(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results) int *nrels_mag, long *results)
{ {
struct lm75_data *data = client->data; struct lm75_data *data = i2c_get_clientdata(client);
if (operation == SENSORS_PROC_REAL_INFO) if (operation == SENSORS_PROC_REAL_INFO)
*nrels_mag = 1; *nrels_mag = 1;
else if (operation == SENSORS_PROC_REAL_READ) { else if (operation == SENSORS_PROC_REAL_READ) {
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
/* $Id: i2c-algo-bit.c,v 1.44 2003/01/21 08:08:16 kmalkki Exp $ */ /* $Id: i2c-algo-bit.c,v 1.44 2003/01/21 08:08:16 kmalkki Exp $ */
/* #define DEBUG 1 */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -338,16 +340,14 @@ static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) ...@@ -338,16 +340,14 @@ static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
while (count > 0) { while (count > 0) {
c = *temp; c = *temp;
DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: %s sendbytes: writing %2.2X\n", DEB2(dev_dbg(&i2c_adap->dev, "sendbytes: writing %2.2X\n", c&0xff));
i2c_adap->name, c&0xff));
retval = i2c_outb(i2c_adap,c); retval = i2c_outb(i2c_adap,c);
if ((retval>0) || (nak_ok && (retval==0))) { /* ok or ignored NAK */ if ((retval>0) || (nak_ok && (retval==0))) { /* ok or ignored NAK */
count--; count--;
temp++; temp++;
wrcount++; wrcount++;
} else { /* arbitration or no acknowledge */ } else { /* arbitration or no acknowledge */
printk(KERN_ERR "i2c-algo-bit.o: %s sendbytes: error - bailout.\n", dev_err(&i2c_adap->dev, "sendbytes: error - bailout.\n");
i2c_adap->name);
i2c_stop(adap); i2c_stop(adap);
return (retval<0)? retval : -EFAULT; return (retval<0)? retval : -EFAULT;
/* got a better one ?? */ /* got a better one ?? */
...@@ -527,13 +527,12 @@ int i2c_bit_add_bus(struct i2c_adapter *adap) ...@@ -527,13 +527,12 @@ int i2c_bit_add_bus(struct i2c_adapter *adap)
struct i2c_algo_bit_data *bit_adap = adap->algo_data; struct i2c_algo_bit_data *bit_adap = adap->algo_data;
if (bit_test) { if (bit_test) {
int ret = test_bus(bit_adap, adap->name); int ret = test_bus(bit_adap, adap->dev.name);
if (ret<0) if (ret<0)
return -ENODEV; return -ENODEV;
} }
DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: hw routines for %s registered.\n", DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));
adap->name));
/* register new adapter to i2c module... */ /* register new adapter to i2c module... */
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
messages, proper stop/repstart signaling during receive, messages, proper stop/repstart signaling during receive,
added detect code */ added detect code */
/* #define DEBUG 1 */ /* to pick up dev_dbg calls */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -222,21 +224,19 @@ static int pcf_sendbytes(struct i2c_adapter *i2c_adap, const char *buf, ...@@ -222,21 +224,19 @@ static int pcf_sendbytes(struct i2c_adapter *i2c_adap, const char *buf,
int wrcount, status, timeout; int wrcount, status, timeout;
for (wrcount=0; wrcount<count; ++wrcount) { for (wrcount=0; wrcount<count; ++wrcount) {
DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: %s i2c_write: writing %2.2X\n", DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
i2c_adap->name, buf[wrcount]&0xff)); buf[wrcount]&0xff));
i2c_outb(adap, buf[wrcount]); i2c_outb(adap, buf[wrcount]);
timeout = wait_for_pin(adap, &status); timeout = wait_for_pin(adap, &status);
if (timeout) { if (timeout) {
i2c_stop(adap); i2c_stop(adap);
printk(KERN_ERR "i2c-algo-pcf.o: %s i2c_write: " dev_err(&i2c_adap->dev, "i2c_write: error - timeout.\n");
"error - timeout.\n", i2c_adap->name);
return -EREMOTEIO; /* got a better one ?? */ return -EREMOTEIO; /* got a better one ?? */
} }
#ifndef STUB_I2C #ifndef STUB_I2C
if (status & I2C_PCF_LRB) { if (status & I2C_PCF_LRB) {
i2c_stop(adap); i2c_stop(adap);
printk(KERN_ERR "i2c-algo-pcf.o: %s i2c_write: " dev_err(&i2c_adap->dev, "i2c_write: error - no ack.\n");
"error - no ack.\n", i2c_adap->name);
return -EREMOTEIO; /* got a better one ?? */ return -EREMOTEIO; /* got a better one ?? */
} }
#endif #endif
...@@ -263,14 +263,14 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf, ...@@ -263,14 +263,14 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
if (wait_for_pin(adap, &status)) { if (wait_for_pin(adap, &status)) {
i2c_stop(adap); i2c_stop(adap);
printk(KERN_ERR "i2c-algo-pcf.o: pcf_readbytes timed out.\n"); dev_err(&i2c_adap->dev, "pcf_readbytes timed out.\n");
return (-1); return (-1);
} }
#ifndef STUB_I2C #ifndef STUB_I2C
if ((status & I2C_PCF_LRB) && (i != count)) { if ((status & I2C_PCF_LRB) && (i != count)) {
i2c_stop(adap); i2c_stop(adap);
printk(KERN_ERR "i2c-algo-pcf.o: i2c_read: i2c_inb, No ack.\n"); dev_err(&i2c_adap->dev, "i2c_read: i2c_inb, No ack.\n");
return (-1); return (-1);
} }
#endif #endif
...@@ -445,8 +445,7 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap) ...@@ -445,8 +445,7 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
struct i2c_algo_pcf_data *pcf_adap = adap->algo_data; struct i2c_algo_pcf_data *pcf_adap = adap->algo_data;
int rval; int rval;
DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: hw routines for %s registered.\n", DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));
adap->name));
/* register new adapter to i2c module... */ /* register new adapter to i2c module... */
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
/* $Id: i2c-core.c,v 1.95 2003/01/22 05:25:08 kmalkki Exp $ */ /* $Id: i2c-core.c,v 1.95 2003/01/22 05:25:08 kmalkki Exp $ */
/* #define DEBUG 1 */ /* needed to pick up the dev_dbg() calls */
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/errno.h> #include <linux/errno.h>
...@@ -82,9 +84,8 @@ int i2c_add_adapter(struct i2c_adapter *adap) ...@@ -82,9 +84,8 @@ int i2c_add_adapter(struct i2c_adapter *adap)
if (NULL == adapters[i]) if (NULL == adapters[i])
break; break;
if (I2C_ADAP_MAX == i) { if (I2C_ADAP_MAX == i) {
printk(KERN_WARNING dev_warn(&adap->dev,
" i2c-core.o: register_adapter(%s) - enlarge I2C_ADAP_MAX.\n", "register_adapter - enlarge I2C_ADAP_MAX.\n");
adap->name);
res = -ENOMEM; res = -ENOMEM;
goto out_unlock; goto out_unlock;
} }
...@@ -105,7 +106,6 @@ int i2c_add_adapter(struct i2c_adapter *adap) ...@@ -105,7 +106,6 @@ int i2c_add_adapter(struct i2c_adapter *adap)
if (adap->dev.parent == NULL) if (adap->dev.parent == NULL)
adap->dev.parent = &legacy_bus; adap->dev.parent = &legacy_bus;
sprintf(adap->dev.bus_id, "i2c-%d", i); sprintf(adap->dev.bus_id, "i2c-%d", i);
strcpy(adap->dev.name, "i2c controller");
device_register(&adap->dev); device_register(&adap->dev);
/* inform drivers of new adapters */ /* inform drivers of new adapters */
...@@ -116,8 +116,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) ...@@ -116,8 +116,7 @@ int i2c_add_adapter(struct i2c_adapter *adap)
drivers[j]->attach_adapter(adap); drivers[j]->attach_adapter(adap);
up(&core_lists); up(&core_lists);
DEB(printk(KERN_DEBUG "i2c-core.o: adapter %s registered as adapter %d.\n", DEB(dev_dbg(&adap->dev, "registered as adapter %d.\n", i));
adap->name,i));
out_unlock: out_unlock:
up(&core_lists); up(&core_lists);
...@@ -134,8 +133,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) ...@@ -134,8 +133,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
if (adap == adapters[i]) if (adap == adapters[i])
break; break;
if (I2C_ADAP_MAX == i) { if (I2C_ADAP_MAX == i) {
printk( KERN_WARNING "i2c-core.o: unregister_adapter adap [%s] not found.\n", dev_warn(&adap->dev, "unregister_adapter adap not found.\n");
adap->name);
res = -ENODEV; res = -ENODEV;
goto out_unlock; goto out_unlock;
} }
...@@ -148,9 +146,9 @@ int i2c_del_adapter(struct i2c_adapter *adap) ...@@ -148,9 +146,9 @@ int i2c_del_adapter(struct i2c_adapter *adap)
for (j = 0; j < I2C_DRIVER_MAX; j++) for (j = 0; j < I2C_DRIVER_MAX; j++)
if (drivers[j] && (drivers[j]->flags & I2C_DF_DUMMY)) if (drivers[j] && (drivers[j]->flags & I2C_DF_DUMMY))
if ((res = drivers[j]->attach_adapter(adap))) { if ((res = drivers[j]->attach_adapter(adap))) {
printk(KERN_WARNING "i2c-core.o: can't detach adapter %s " dev_warn(&adap->dev, "can't detach adapter"
"while detaching driver %s: driver not " "while detaching driver %s: driver not "
"detached!",adap->name,drivers[j]->name); "detached!", drivers[j]->name);
goto out_unlock; goto out_unlock;
} }
...@@ -164,10 +162,10 @@ int i2c_del_adapter(struct i2c_adapter *adap) ...@@ -164,10 +162,10 @@ int i2c_del_adapter(struct i2c_adapter *adap)
* must be deleted, as this would cause invalid states. * must be deleted, as this would cause invalid states.
*/ */
if ((res=client->driver->detach_client(client))) { if ((res=client->driver->detach_client(client))) {
printk(KERN_ERR "i2c-core.o: adapter %s not " dev_err(&adap->dev, "adapter not "
"unregistered, because client at " "unregistered, because client at "
"address %02x can't be detached. ", "address %02x can't be detached. ",
adap->name, client->addr); client->addr);
goto out_unlock; goto out_unlock;
} }
} }
...@@ -180,7 +178,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) ...@@ -180,7 +178,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
adapters[i] = NULL; adapters[i] = NULL;
DEB(printk(KERN_DEBUG "i2c-core.o: adapter unregistered: %s\n",adap->name)); DEB(dev_dbg(&adap->dev, "adapter unregistered\n"));
out_unlock: out_unlock:
up(&core_lists); up(&core_lists);
...@@ -272,8 +270,7 @@ int i2c_del_driver(struct i2c_driver *driver) ...@@ -272,8 +270,7 @@ int i2c_del_driver(struct i2c_driver *driver)
struct i2c_adapter *adap = adapters[k]; struct i2c_adapter *adap = adapters[k];
if (adap == NULL) /* skip empty entries. */ if (adap == NULL) /* skip empty entries. */
continue; continue;
DEB2(printk(KERN_DEBUG "i2c-core.o: examining adapter %s:\n", DEB2(dev_dbg(&adap->dev, "examining adapter\n"));
adap->name));
if (driver->flags & I2C_DF_DUMMY) { if (driver->flags & I2C_DF_DUMMY) {
/* DUMMY drivers do not register their clients, so we have to /* DUMMY drivers do not register their clients, so we have to
* use a trick here: we call driver->attach_adapter to * use a trick here: we call driver->attach_adapter to
...@@ -281,11 +278,10 @@ int i2c_del_driver(struct i2c_driver *driver) ...@@ -281,11 +278,10 @@ int i2c_del_driver(struct i2c_driver *driver)
* this or hell will break loose... * this or hell will break loose...
*/ */
if ((res = driver->attach_adapter(adap))) { if ((res = driver->attach_adapter(adap))) {
printk(KERN_WARNING "i2c-core.o: while unregistering " dev_warn(&adap->dev, "while unregistering "
"dummy driver %s, adapter %s could " "dummy driver %s, adapter could "
"not be detached properly; driver " "not be detached properly; driver "
"not unloaded!",driver->name, "not unloaded!",driver->name);
adap->name);
goto out_unlock; goto out_unlock;
} }
} else { } else {
...@@ -295,20 +291,17 @@ int i2c_del_driver(struct i2c_driver *driver) ...@@ -295,20 +291,17 @@ int i2c_del_driver(struct i2c_driver *driver)
client->driver == driver) { client->driver == driver) {
DEB2(printk(KERN_DEBUG "i2c-core.o: " DEB2(printk(KERN_DEBUG "i2c-core.o: "
"detaching client %s:\n", "detaching client %s:\n",
client->name)); client->dev.name));
if ((res = driver-> if ((res = driver->detach_client(client))) {
detach_client(client))) dev_err(&adap->dev, "while "
{
printk(KERN_ERR "i2c-core.o: while "
"unregistering driver " "unregistering driver "
"`%s', the client at " "`%s', the client at "
"address %02x of " "address %02x of "
"adapter `%s' could not " "adapter could not "
"be detached; driver " "be detached; driver "
"not unloaded!", "not unloaded!",
driver->name, driver->name,
client->addr, client->addr);
adap->name);
goto out_unlock; goto out_unlock;
} }
} }
...@@ -362,7 +355,7 @@ int i2c_attach_client(struct i2c_client *client) ...@@ -362,7 +355,7 @@ int i2c_attach_client(struct i2c_client *client)
printk(KERN_WARNING printk(KERN_WARNING
" i2c-core.o: attach_client(%s) - enlarge I2C_CLIENT_MAX.\n", " i2c-core.o: attach_client(%s) - enlarge I2C_CLIENT_MAX.\n",
client->name); client->dev.name);
out_unlock_list: out_unlock_list:
up(&adapter->list); up(&adapter->list);
...@@ -374,19 +367,26 @@ int i2c_attach_client(struct i2c_client *client) ...@@ -374,19 +367,26 @@ int i2c_attach_client(struct i2c_client *client)
if (adapter->client_register) { if (adapter->client_register) {
if (adapter->client_register(client)) { if (adapter->client_register(client)) {
printk(KERN_DEBUG dev_warn(&adapter->dev, "warning: client_register "
"i2c-core.o: warning: client_register seems " "seems to have failed for client %02x\n",
"to have failed for client %02x at adapter %s\n", client->addr);
client->addr, adapter->name);
} }
} }
DEB(printk(KERN_DEBUG DEB(dev_dbg(&adapter->dev, "client [%s] registered to adapter "
"i2c-core.o: client [%s] registered to adapter [%s] " "(pos. %d).\n", client->dev.name, i));
"(pos. %d).\n", client->name, adapter->name, i));
if (client->flags & I2C_CLIENT_ALLOW_USE) if (client->flags & I2C_CLIENT_ALLOW_USE)
client->usage_count = 0; client->usage_count = 0;
client->dev.parent = &client->adapter->dev;
client->dev.driver = &client->driver->driver;
client->dev.bus = &i2c_bus_type;
snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), "i2c_dev_%d", i);
printk("registering %s\n", client->dev.bus_id);
device_register(&client->dev);
return 0; return 0;
} }
...@@ -404,7 +404,7 @@ int i2c_detach_client(struct i2c_client *client) ...@@ -404,7 +404,7 @@ int i2c_detach_client(struct i2c_client *client)
if (res) { if (res) {
printk(KERN_ERR printk(KERN_ERR
"i2c-core.o: client_unregister [%s] failed, " "i2c-core.o: client_unregister [%s] failed, "
"client not detached", client->name); "client not detached", client->dev.name);
goto out; goto out;
} }
} }
...@@ -419,10 +419,11 @@ int i2c_detach_client(struct i2c_client *client) ...@@ -419,10 +419,11 @@ int i2c_detach_client(struct i2c_client *client)
printk(KERN_WARNING printk(KERN_WARNING
" i2c-core.o: unregister_client [%s] not found\n", " i2c-core.o: unregister_client [%s] not found\n",
client->name); client->dev.name);
res = -ENODEV; res = -ENODEV;
out_unlock: out_unlock:
device_unregister(&client->dev);
up(&adapter->list); up(&adapter->list);
out: out:
return res; return res;
...@@ -531,7 +532,7 @@ static ssize_t i2cproc_bus_read(struct file *file, char *buf, ...@@ -531,7 +532,7 @@ static ssize_t i2cproc_bus_read(struct file *file, char *buf,
client = adapters[i]->clients[order[j]]; client = adapters[i]->clients[order[j]];
len += sprintf(kbuf+len,"%02x\t%-32s\t%-32s\n", len += sprintf(kbuf+len,"%02x\t%-32s\t%-32s\n",
client->addr, client->addr,
client->name, client->dev.name,
client->driver->name); client->driver->name);
} }
len = len - file->f_pos; len = len - file->f_pos;
...@@ -579,7 +580,7 @@ static int bus_i2c_show(struct seq_file *s, void *p) ...@@ -579,7 +580,7 @@ static int bus_i2c_show(struct seq_file *s, void *p)
seq_printf(s, "dummy "); seq_printf(s, "dummy ");
seq_printf(s, "\t%-32s\t%-32s\n", seq_printf(s, "\t%-32s\t%-32s\n",
adapter->name, adapter->algo->name); adapter->dev.name, adapter->algo->name);
} }
up(&core_lists); up(&core_lists);
...@@ -675,7 +676,7 @@ static void __exit i2c_exit(void) ...@@ -675,7 +676,7 @@ static void __exit i2c_exit(void)
bus_unregister(&i2c_bus_type); bus_unregister(&i2c_bus_type);
} }
module_init(i2c_init); subsys_initcall(i2c_init);
module_exit(i2c_exit); module_exit(i2c_exit);
/* ---------------------------------------------------- /* ----------------------------------------------------
...@@ -688,8 +689,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg msgs[],int num) ...@@ -688,8 +689,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg msgs[],int num)
int ret; int ret;
if (adap->algo->master_xfer) { if (adap->algo->master_xfer) {
DEB2(printk(KERN_DEBUG "i2c-core.o: master_xfer: %s with %d msgs.\n", DEB2(dev_dbg(&adap->dev, "master_xfer: with %d msgs.\n", num));
adap->name,num));
down(&adap->bus); down(&adap->bus);
ret = adap->algo->master_xfer(adap,msgs,num); ret = adap->algo->master_xfer(adap,msgs,num);
...@@ -697,8 +697,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg msgs[],int num) ...@@ -697,8 +697,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg msgs[],int num)
return ret; return ret;
} else { } else {
printk(KERN_ERR "i2c-core.o: I2C adapter %04x: I2C level transfers not supported\n", dev_err(&adap->dev, "I2C level transfers not supported\n");
adap->id);
return -ENOSYS; return -ENOSYS;
} }
} }
...@@ -715,8 +714,8 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count) ...@@ -715,8 +714,8 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count)
msg.len = count; msg.len = count;
(const char *)msg.buf = buf; (const char *)msg.buf = buf;
DEB2(printk(KERN_DEBUG "i2c-core.o: master_send: writing %d bytes on %s.\n", DEB2(dev_dbg(&client->adapter->dev, "master_send: writing %d bytes.\n",
count,client->adapter->name)); count));
down(&adap->bus); down(&adap->bus);
ret = adap->algo->master_xfer(adap,&msg,1); ret = adap->algo->master_xfer(adap,&msg,1);
...@@ -745,8 +744,8 @@ int i2c_master_recv(struct i2c_client *client, char *buf ,int count) ...@@ -745,8 +744,8 @@ int i2c_master_recv(struct i2c_client *client, char *buf ,int count)
msg.len = count; msg.len = count;
msg.buf = buf; msg.buf = buf;
DEB2(printk(KERN_DEBUG "i2c-core.o: master_recv: reading %d bytes on %s.\n", DEB2(dev_dbg(&client->adapter->dev, "master_recv: reading %d bytes.\n",
count,client->adapter->name)); count));
down(&adap->bus); down(&adap->bus);
ret = adap->algo->master_xfer(adap,&msg,1); ret = adap->algo->master_xfer(adap,&msg,1);
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
/* $Id: i2c-dev.c,v 1.53 2003/01/21 08:08:16 kmalkki Exp $ */ /* $Id: i2c-dev.c,v 1.53 2003/01/21 08:08:16 kmalkki Exp $ */
/* If you want debugging uncomment: */
/* #define DEBUG 1 */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/fs.h> #include <linux/fs.h>
...@@ -41,10 +44,6 @@ ...@@ -41,10 +44,6 @@
#include <linux/i2c-dev.h> #include <linux/i2c-dev.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
/* If you want debugging uncomment: */
/* #define DEBUG */
/* struct file_operations changed too often in the 2.1 series for nice code */ /* struct file_operations changed too often in the 2.1 series for nice code */
static ssize_t i2cdev_read (struct file *file, char *buf, size_t count, static ssize_t i2cdev_read (struct file *file, char *buf, size_t count,
...@@ -87,7 +86,9 @@ static struct i2c_driver i2cdev_driver = { ...@@ -87,7 +86,9 @@ static struct i2c_driver i2cdev_driver = {
}; };
static struct i2c_client i2cdev_client_template = { static struct i2c_client i2cdev_client_template = {
.dev = {
.name = "I2C /dev entry", .name = "I2C /dev entry",
},
.id = 1, .id = 1,
.addr = -1, .addr = -1,
.driver = &i2cdev_driver, .driver = &i2cdev_driver,
...@@ -386,11 +387,11 @@ int i2cdev_attach_adapter(struct i2c_adapter *adap) ...@@ -386,11 +387,11 @@ int i2cdev_attach_adapter(struct i2c_adapter *adap)
char name[12]; char name[12];
if ((i = i2c_adapter_id(adap)) < 0) { if ((i = i2c_adapter_id(adap)) < 0) {
printk(KERN_DEBUG "i2c-dev.o: Unknown adapter ?!?\n"); dev_dbg(&adap->dev, "Unknown adapter ?!?\n");
return -ENODEV; return -ENODEV;
} }
if (i >= I2CDEV_ADAPS_MAX) { if (i >= I2CDEV_ADAPS_MAX) {
printk(KERN_DEBUG "i2c-dev.o: Adapter number too large?!? (%d)\n",i); dev_dbg(&adap->dev, "Adapter number too large?!? (%d)\n",i);
return -ENODEV; return -ENODEV;
} }
...@@ -401,14 +402,12 @@ int i2cdev_attach_adapter(struct i2c_adapter *adap) ...@@ -401,14 +402,12 @@ int i2cdev_attach_adapter(struct i2c_adapter *adap)
DEVFS_FL_DEFAULT, I2C_MAJOR, i, DEVFS_FL_DEFAULT, I2C_MAJOR, i,
S_IFCHR | S_IRUSR | S_IWUSR, S_IFCHR | S_IRUSR | S_IWUSR,
&i2cdev_fops, NULL); &i2cdev_fops, NULL);
printk(KERN_DEBUG "i2c-dev.o: Registered '%s' as minor %d\n",adap->name,i); dev_dbg(&adap->dev, "Registered as minor %d\n", i);
} else { } else {
/* This is actually a detach_adapter call! */ /* This is actually a detach_adapter call! */
devfs_remove("i2c/%d", i); devfs_remove("i2c/%d", i);
i2cdev_adaps[i] = NULL; i2cdev_adaps[i] = NULL;
#ifdef DEBUG dev_dbg(&adap->dev, "Adapter unregistered\n");
printk(KERN_DEBUG "i2c-dev.o: Adapter unregistered: %s\n",adap->name);
#endif
} }
return 0; return 0;
......
...@@ -175,9 +175,11 @@ static struct i2c_algo_pcf_data pcf_isa_data = { ...@@ -175,9 +175,11 @@ 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, .owner = THIS_MODULE,
.name = "PCF8584 ISA adapter",
.id = I2C_HW_P_ELEK, .id = I2C_HW_P_ELEK,
.algo_data = &pcf_isa_data, .algo_data = &pcf_isa_data,
.dev = {
.name = "PCF8584 ISA adapter",
},
}; };
static int __init i2c_pcfisa_init(void) static int __init i2c_pcfisa_init(void)
......
...@@ -129,9 +129,11 @@ static struct i2c_algo_bit_data bit_elv_data = { ...@@ -129,9 +129,11 @@ static struct i2c_algo_bit_data bit_elv_data = {
static struct i2c_adapter bit_elv_ops = { static struct i2c_adapter bit_elv_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "ELV Parallel port adaptor",
.id = I2C_HW_B_ELV, .id = I2C_HW_B_ELV,
.algo_data = &bit_elv_data, .algo_data = &bit_elv_data,
.dev = {
.name = "ELV Parallel port adaptor",
},
}; };
static int __init i2c_bitelv_init(void) static int __init i2c_bitelv_init(void)
...@@ -148,7 +150,7 @@ static int __init i2c_bitelv_init(void) ...@@ -148,7 +150,7 @@ static int __init i2c_bitelv_init(void)
return -ENODEV; return -ENODEV;
} }
} else { } else {
bit_elv_ops.data=(void*)base; i2c_set_adapdata(&bit_elv_ops, (void *)base);
if (bit_elv_init()==0) { if (bit_elv_init()==0) {
if(i2c_bit_add_bus(&bit_elv_ops) < 0) if(i2c_bit_add_bus(&bit_elv_ops) < 0)
return -ENODEV; return -ENODEV;
......
...@@ -151,8 +151,10 @@ static struct i2c_algo_bit_data bit_lp_data2 = { ...@@ -151,8 +151,10 @@ static struct i2c_algo_bit_data bit_lp_data2 = {
static struct i2c_adapter bit_lp_ops = { static struct i2c_adapter bit_lp_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "Philips Parallel port adapter",
.id = I2C_HW_B_LP, .id = I2C_HW_B_LP,
.dev = {
.name = "Philips Parallel port adapter",
},
}; };
static void i2c_parport_attach (struct parport *port) static void i2c_parport_attach (struct parport *port)
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
This driver puts entries in /proc/sys/dev/sensors for each I2C device This driver puts entries in /proc/sys/dev/sensors for each I2C device
*/ */
/* #define DEBUG 1 */
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -581,9 +583,9 @@ int i2c_detect(struct i2c_adapter *adapter, ...@@ -581,9 +583,9 @@ int i2c_detect(struct i2c_adapter *adapter,
is_isa ? SENSORS_ISA_BUS : i2c_adapter_id(adapter); is_isa ? SENSORS_ISA_BUS : i2c_adapter_id(adapter);
/* Forget it if we can't probe using SMBUS_QUICK */ /* Forget it if we can't probe using SMBUS_QUICK */
if ((!is_isa) if ((!is_isa) &&
&& !i2c_check_functionality(adapter, !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK))
I2C_FUNC_SMBUS_QUICK)) return -1; return -1;
for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) { for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) {
/* XXX: WTF is going on here??? */ /* XXX: WTF is going on here??? */
...@@ -594,31 +596,14 @@ int i2c_detect(struct i2c_adapter *adapter, ...@@ -594,31 +596,14 @@ int i2c_detect(struct i2c_adapter *adapter,
/* If it is in one of the force entries, we don't do any /* If it is in one of the force entries, we don't do any
detection at all */ detection at all */
found = 0; found = 0;
for (i = 0; for (i = 0; !found && (this_force = address_data->forces + i, this_force->force); i++) {
!found for (j = 0; !found && (this_force->force[j] != SENSORS_I2C_END); j += 2) {
&& (this_force = if ( ((adapter_id == this_force->force[j]) ||
address_data->forces + i, this_force->force); i++) { ((this_force->force[j] == SENSORS_ANY_I2C_BUS) && !is_isa)) &&
for (j = 0; (addr == this_force->force[j + 1]) ) {
!found dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", adapter_id, addr);
&& (this_force->force[j] != SENSORS_I2C_END); if ((err = found_proc(adapter, addr, 0, this_force->kind)))
j += 2) { return err;
if (
((adapter_id == this_force->force[j])
||
((this_force->
force[j] == SENSORS_ANY_I2C_BUS)
&& !is_isa))
&& (addr == this_force->force[j + 1])) {
#ifdef DEBUG
printk
(KERN_DEBUG "i2c-proc.o: found force parameter for adapter %d, addr %04x\n",
adapter_id, addr);
#endif
if (
(err =
found_proc(adapter, addr, 0,
this_force->
kind))) return err;
found = 1; found = 1;
} }
} }
...@@ -628,42 +613,22 @@ int i2c_detect(struct i2c_adapter *adapter, ...@@ -628,42 +613,22 @@ int i2c_detect(struct i2c_adapter *adapter,
/* If this address is in one of the ignores, we can forget about it /* If this address is in one of the ignores, we can forget about it
right now */ right now */
for (i = 0; for (i = 0; !found && (address_data->ignore[i] != SENSORS_I2C_END); i += 2) {
!found if ( ((adapter_id == address_data->ignore[i]) ||
&& (address_data->ignore[i] != SENSORS_I2C_END); ((address_data->ignore[i] == SENSORS_ANY_I2C_BUS) &&
i += 2) { !is_isa)) &&
if ( (addr == address_data->ignore[i + 1])) {
((adapter_id == address_data->ignore[i]) dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, addr %04x\n", adapter_id, addr);
||
((address_data->
ignore[i] == SENSORS_ANY_I2C_BUS)
&& !is_isa))
&& (addr == address_data->ignore[i + 1])) {
#ifdef DEBUG
printk
(KERN_DEBUG "i2c-proc.o: found ignore parameter for adapter %d, "
"addr %04x\n", adapter_id, addr);
#endif
found = 1; found = 1;
} }
} }
for (i = 0; for (i = 0; !found && (address_data->ignore_range[i] != SENSORS_I2C_END); i += 3) {
!found if ( ((adapter_id == address_data->ignore_range[i]) ||
&& (address_data->ignore_range[i] != SENSORS_I2C_END); ((address_data-> ignore_range[i] == SENSORS_ANY_I2C_BUS) &
i += 3) { !is_isa)) &&
if ( (addr >= address_data->ignore_range[i + 1]) &&
((adapter_id == address_data->ignore_range[i]) (addr <= address_data->ignore_range[i + 2])) {
|| dev_dbg(&adapter->dev, "found ignore_range parameter for adapter %d, addr %04x\n", adapter_id, addr);
((address_data->
ignore_range[i] ==
SENSORS_ANY_I2C_BUS) & !is_isa))
&& (addr >= address_data->ignore_range[i + 1])
&& (addr <= address_data->ignore_range[i + 2])) {
#ifdef DEBUG
printk
(KERN_DEBUG "i2c-proc.o: found ignore_range parameter for adapter %d, "
"addr %04x\n", adapter_id, addr);
#endif
found = 1; found = 1;
} }
} }
...@@ -673,68 +638,31 @@ int i2c_detect(struct i2c_adapter *adapter, ...@@ -673,68 +638,31 @@ int i2c_detect(struct i2c_adapter *adapter,
/* Now, we will do a detection, but only if it is in the normal or /* Now, we will do a detection, but only if it is in the normal or
probe entries */ probe entries */
if (is_isa) { if (is_isa) {
for (i = 0; for (i = 0; !found && (address_data->normal_isa[i] != SENSORS_ISA_END); i += 1) {
!found
&& (address_data->normal_isa[i] !=
SENSORS_ISA_END); i += 1) {
if (addr == address_data->normal_isa[i]) { if (addr == address_data->normal_isa[i]) {
#ifdef DEBUG dev_dbg(&adapter->dev, "found normal isa entry for adapter %d, addr %04x\n", adapter_id, addr);
printk
(KERN_DEBUG "i2c-proc.o: found normal isa entry for adapter %d, "
"addr %04x\n", adapter_id,
addr);
#endif
found = 1; found = 1;
} }
} }
for (i = 0; for (i = 0; !found && (address_data->normal_isa_range[i] != SENSORS_ISA_END); i += 3) {
!found if ((addr >= address_data->normal_isa_range[i]) &&
&& (address_data->normal_isa_range[i] != (addr <= address_data->normal_isa_range[i + 1]) &&
SENSORS_ISA_END); i += 3) { ((addr - address_data->normal_isa_range[i]) % address_data->normal_isa_range[i + 2] == 0)) {
if ((addr >= dev_dbg(&adapter->dev, "found normal isa_range entry for adapter %d, addr %04x", adapter_id, addr);
address_data->normal_isa_range[i])
&& (addr <=
address_data->normal_isa_range[i + 1])
&&
((addr -
address_data->normal_isa_range[i]) %
address_data->normal_isa_range[i + 2] ==
0)) {
#ifdef DEBUG
printk
(KERN_DEBUG "i2c-proc.o: found normal isa_range entry for adapter %d, "
"addr %04x", adapter_id, addr);
#endif
found = 1; found = 1;
} }
} }
} else { } else {
for (i = 0; for (i = 0; !found && (address_data->normal_i2c[i] != SENSORS_I2C_END); i += 1) {
!found && (address_data->normal_i2c[i] !=
SENSORS_I2C_END); i += 1) {
if (addr == address_data->normal_i2c[i]) { if (addr == address_data->normal_i2c[i]) {
found = 1; found = 1;
#ifdef DEBUG dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x", adapter_id, addr);
printk
(KERN_DEBUG "i2c-proc.o: found normal i2c entry for adapter %d, "
"addr %02x", adapter_id, addr);
#endif
} }
} }
for (i = 0; for (i = 0; !found && (address_data->normal_i2c_range[i] != SENSORS_I2C_END); i += 2) {
!found if ((addr >= address_data->normal_i2c_range[i]) &&
&& (address_data->normal_i2c_range[i] != (addr <= address_data->normal_i2c_range[i + 1])) {
SENSORS_I2C_END); i += 2) { dev_dbg(&adapter->dev, "found normal i2c_range entry for adapter %d, addr %04x\n", adapter_id, addr);
if ((addr >=
address_data->normal_i2c_range[i])
&& (addr <=
address_data->normal_i2c_range[i + 1]))
{
#ifdef DEBUG
printk
(KERN_DEBUG "i2c-proc.o: found normal i2c_range entry for adapter %d, "
"addr %04x\n", adapter_id, addr);
#endif
found = 1; found = 1;
} }
} }
...@@ -747,30 +675,17 @@ int i2c_detect(struct i2c_adapter *adapter, ...@@ -747,30 +675,17 @@ int i2c_detect(struct i2c_adapter *adapter,
((address_data-> ((address_data->
probe[i] == SENSORS_ANY_I2C_BUS) & !is_isa)) probe[i] == SENSORS_ANY_I2C_BUS) & !is_isa))
&& (addr == address_data->probe[i + 1])) { && (addr == address_data->probe[i + 1])) {
#ifdef DEBUG dev_dbg(&adapter->dev, "found probe parameter for adapter %d, addr %04x\n", adapter_id, addr);
printk
(KERN_DEBUG "i2c-proc.o: found probe parameter for adapter %d, "
"addr %04x\n", adapter_id, addr);
#endif
found = 1; found = 1;
} }
} }
for (i = 0; !found && for (i = 0; !found && (address_data->probe_range[i] != SENSORS_I2C_END); i += 3) {
(address_data->probe_range[i] != SENSORS_I2C_END); if ( ((adapter_id == address_data->probe_range[i]) ||
i += 3) { ((address_data->probe_range[i] == SENSORS_ANY_I2C_BUS) & !is_isa)) &&
if ( (addr >= address_data->probe_range[i + 1]) &&
((adapter_id == address_data->probe_range[i]) (addr <= address_data->probe_range[i + 2])) {
||
((address_data->probe_range[i] ==
SENSORS_ANY_I2C_BUS) & !is_isa))
&& (addr >= address_data->probe_range[i + 1])
&& (addr <= address_data->probe_range[i + 2])) {
found = 1; found = 1;
#ifdef DEBUG dev_dbg(&adapter->dev, "found probe_range parameter for adapter %d, addr %04x\n", adapter_id, addr);
printk
(KERN_DEBUG "i2c-proc.o: found probe_range parameter for adapter %d, "
"addr %04x\n", adapter_id, addr);
#endif
} }
} }
if (!found) if (!found)
...@@ -779,8 +694,7 @@ int i2c_detect(struct i2c_adapter *adapter, ...@@ -779,8 +694,7 @@ int i2c_detect(struct i2c_adapter *adapter,
/* OK, so we really should examine this address. First check /* OK, so we really should examine this address. First check
whether there is some client here at all! */ whether there is some client here at all! */
if (is_isa || if (is_isa ||
(i2c_smbus_xfer (i2c_smbus_xfer (adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0))
(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0))
if ((err = found_proc(adapter, addr, 0, -1))) if ((err = found_proc(adapter, addr, 0, -1)))
return err; return err;
} }
......
...@@ -114,9 +114,11 @@ static struct i2c_algo_bit_data bit_velle_data = { ...@@ -114,9 +114,11 @@ static struct i2c_algo_bit_data bit_velle_data = {
static struct i2c_adapter bit_velle_ops = { static struct i2c_adapter bit_velle_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "Velleman K8000",
.id = I2C_HW_B_VELLE, .id = I2C_HW_B_VELLE,
.algo_data = &bit_velle_data, .algo_data = &bit_velle_data,
.dev = {
.name = "Velleman K8000",
},
}; };
static int __init i2c_bitvelle_init(void) static int __init i2c_bitvelle_init(void)
......
...@@ -140,8 +140,7 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) ...@@ -140,8 +140,7 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
switch (iface->state) { switch (iface->state) {
case state_idle: case state_idle:
printk(KERN_WARNING NAME ": %s, interrupt in idle state\n", dev_warn(&iface->adapter.dev, "interrupt in idle state\n",);
iface->adapter.name);
break; break;
case state_address: case state_address:
...@@ -226,8 +225,8 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) ...@@ -226,8 +225,8 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
return; return;
error: error:
printk(KERN_ERR NAME ": %s, %s in state %s\n", iface->adapter.name, dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg,
errmsg, scx200_acb_state_name[iface->state]); scx200_acb_state_name[iface->state]);
iface->state = state_idle; iface->state = state_idle;
iface->result = -EIO; iface->result = -EIO;
...@@ -236,8 +235,8 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) ...@@ -236,8 +235,8 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
static void scx200_acb_timeout(struct scx200_acb_iface *iface) static void scx200_acb_timeout(struct scx200_acb_iface *iface)
{ {
printk(KERN_ERR NAME ": %s, timeout in state %s\n", dev_err(&iface->adapter.dev, "timeout in state %s\n",
iface->adapter.name, scx200_acb_state_name[iface->state]); scx200_acb_state_name[iface->state]);
iface->state = state_idle; iface->state = state_idle;
iface->result = -EIO; iface->result = -EIO;
...@@ -290,7 +289,7 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, ...@@ -290,7 +289,7 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter,
char rw, u8 command, int size, char rw, u8 command, int size,
union i2c_smbus_data *data) union i2c_smbus_data *data)
{ {
struct scx200_acb_iface *iface = adapter->data; struct scx200_acb_iface *iface = i2c_get_adapdata(adapter);
int len; int len;
u8 *buffer; u8 *buffer;
u16 cur_word; u16 cur_word;
...@@ -331,13 +330,12 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, ...@@ -331,13 +330,12 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter,
size, address, command, len, rw == I2C_SMBUS_READ); size, address, command, len, rw == I2C_SMBUS_READ);
if (!len && rw == I2C_SMBUS_READ) { if (!len && rw == I2C_SMBUS_READ) {
printk(KERN_WARNING NAME ": %s, zero length read\n", dev_warn(&adapter->dev, "zero length read\n");
adapter->name);
return -EINVAL; return -EINVAL;
} }
if (len && !buffer) { if (len && !buffer) {
printk(KERN_WARNING NAME ": %s, nonzero length but no buffer\n", adapter->name); dev_warn(&adapter->dev, "nonzero length but no buffer\n");
return -EFAULT; return -EFAULT;
} }
...@@ -457,18 +455,18 @@ static int __init scx200_acb_create(int base, int index) ...@@ -457,18 +455,18 @@ static int __init scx200_acb_create(int base, int index)
memset(iface, 0, sizeof(*iface)); memset(iface, 0, sizeof(*iface));
adapter = &iface->adapter; adapter = &iface->adapter;
adapter->data = iface; i2c_set_adapdata(adapter, iface);
sprintf(adapter->name, "SCx200 ACB%d", index); snprintf(adapter->dev.name, DEVICE_NAME_SIZE, "SCx200 ACB%d", index);
adapter->owner = THIS_MODULE; adapter->owner = THIS_MODULE;
adapter->id = I2C_ALGO_SMBUS; adapter->id = I2C_ALGO_SMBUS;
adapter->algo = &scx200_acb_algorithm; adapter->algo = &scx200_acb_algorithm;
init_MUTEX(&iface->sem); init_MUTEX(&iface->sem);
sprintf(description, "NatSemi SCx200 ACCESS.bus [%s]", adapter->name); snprintf(description, sizeof(description), "NatSemi SCx200 ACCESS.bus [%s]", adapter->dev.name);
if (request_region(base, 8, description) == 0) { if (request_region(base, 8, description) == 0) {
printk(KERN_ERR NAME ": %s, can't allocate io 0x%x-0x%x\n", dev_err(&adapter->dev, "can't allocate io 0x%x-0x%x\n",
adapter->name, base, base + 8-1); base, base + 8-1);
rc = -EBUSY; rc = -EBUSY;
goto errout; goto errout;
} }
...@@ -476,14 +474,14 @@ static int __init scx200_acb_create(int base, int index) ...@@ -476,14 +474,14 @@ static int __init scx200_acb_create(int base, int index)
rc = scx200_acb_probe(iface); rc = scx200_acb_probe(iface);
if (rc) { if (rc) {
printk(KERN_WARNING NAME ": %s, probe failed\n", adapter->name); dev_warn(&adapter->dev, "probe failed\n");
goto errout; goto errout;
} }
scx200_acb_reset(iface); scx200_acb_reset(iface);
if (i2c_add_adapter(adapter) < 0) { if (i2c_add_adapter(adapter) < 0) {
printk(KERN_ERR NAME ": %s, failed to register\n", adapter->name); dev_err(&adapter->dev, "failed to register\n");
rc = -ENODEV; rc = -ENODEV;
goto errout; goto errout;
} }
......
...@@ -156,7 +156,6 @@ extern struct bus_type i2c_bus_type; ...@@ -156,7 +156,6 @@ extern struct bus_type i2c_bus_type;
* function is mainly used for lookup & other admin. functions. * function is mainly used for lookup & other admin. functions.
*/ */
struct i2c_client { struct i2c_client {
char name[32];
int id; int id;
unsigned int flags; /* div., see below */ unsigned int flags; /* div., see below */
unsigned int addr; /* chip address - NOTE: 7bit */ unsigned int addr; /* chip address - NOTE: 7bit */
...@@ -167,11 +166,21 @@ struct i2c_client { ...@@ -167,11 +166,21 @@ struct i2c_client {
alignment considerations */ alignment considerations */
struct i2c_adapter *adapter; /* the adapter we sit on */ struct i2c_adapter *adapter; /* the adapter we sit on */
struct i2c_driver *driver; /* and our access routines */ struct i2c_driver *driver; /* and our access routines */
void *data; /* for the clients */
int usage_count; /* How many accesses currently */ int usage_count; /* How many accesses currently */
/* to the client */ /* to the client */
struct device dev; /* the device structure */
}; };
#define to_i2c_client(d) container_of(d, struct i2c_client, dev)
static inline void *i2c_get_clientdata (struct i2c_client *dev)
{
return dev_get_drvdata (&dev->dev);
}
static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
{
return dev_set_drvdata (&dev->dev, data);
}
/* /*
* The following structs are for those who like to implement new bus drivers: * The following structs are for those who like to implement new bus drivers:
...@@ -210,7 +219,6 @@ struct i2c_algorithm { ...@@ -210,7 +219,6 @@ struct i2c_algorithm {
*/ */
struct i2c_adapter { struct i2c_adapter {
struct module *owner; struct module *owner;
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 */
...@@ -220,11 +228,6 @@ struct i2c_adapter { ...@@ -220,11 +228,6 @@ struct i2c_adapter {
int (*client_register)(struct i2c_client *); int (*client_register)(struct i2c_client *);
int (*client_unregister)(struct i2c_client *); int (*client_unregister)(struct i2c_client *);
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 i2c_ioctl call */
/* data fields that are valid for all devices */ /* data fields that are valid for all devices */
struct semaphore bus; struct semaphore bus;
struct semaphore list; struct semaphore list;
...@@ -243,6 +246,16 @@ struct i2c_adapter { ...@@ -243,6 +246,16 @@ struct i2c_adapter {
}; };
#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
static inline void *i2c_get_adapdata (struct i2c_adapter *dev)
{
return dev_get_drvdata (&dev->dev);
}
static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
{
return dev_set_drvdata (&dev->dev, data);
}
/*flags for the driver struct: */ /*flags for the driver struct: */
#define I2C_DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */ #define I2C_DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */
#define I2C_DF_DUMMY 0x02 /* do not connect any clients */ #define I2C_DF_DUMMY 0x02 /* do not connect any clients */
......
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