From: David Brownell Subject: i2c: Other i2c drivers stop using i2c_adapter.dev Update various I2C drivers and algorithms so they stop referencing the soon-to-be-gone i2c_adapter.dev; they were using it for messages. Also do the same for the i2c core. Signed-off-by: David Brownell Signed-off-by: Jean Delvare --- drivers/i2c/algos/i2c-algo-bit.c | 8 +++- drivers/i2c/algos/i2c-algo-pca.c | 3 +- drivers/i2c/algos/i2c-algo-pcf.c | 17 ++++++---- drivers/i2c/chips/isp1301_omap.c | 8 +++- drivers/i2c/chips/tps65010.c | 6 ++- drivers/i2c/i2c-core.c | 68 ++++++++++++++++++++++---------------- drivers/i2c/i2c-dev.c | 11 +++--- 7 files changed, 73 insertions(+), 48 deletions(-) --- linux-2.6.20-rc3.orig/drivers/i2c/algos/i2c-algo-bit.c 2007-01-04 16:30:14.000000000 +0100 +++ linux-2.6.20-rc3/drivers/i2c/algos/i2c-algo-bit.c 2007-01-04 16:30:24.000000000 +0100 @@ -341,14 +341,16 @@ static int sendbytes(struct i2c_adapter while (count > 0) { c = *temp; - DEB2(dev_dbg(&i2c_adap->dev, "sendbytes: writing %2.2X\n", c&0xff)); + DEB2(dev_dbg(i2c_adap->class_dev.dev, + "sendbytes: writing %2.2X\n", c&0xff)); retval = i2c_outb(i2c_adap,c); if ((retval>0) || (nak_ok && (retval==0))) { /* ok or ignored NAK */ count--; temp++; wrcount++; } else { /* arbitration or no acknowledge */ - dev_err(&i2c_adap->dev, "sendbytes: error - bailout.\n"); + dev_err(i2c_adap->class_dev.dev, + "sendbytes: error - bailout\n"); i2c_stop(adap); return (retval<0)? retval : -EFAULT; /* got a better one ?? */ @@ -530,7 +532,7 @@ int i2c_bit_add_bus(struct i2c_adapter * return -ENODEV; } - DEB2(dev_dbg(&adap->dev, "hw routines registered.\n")); + DEB2(dev_dbg(adap->class_dev.dev, "hw routines registered\n")); /* register new adapter to i2c module... */ adap->algo = &i2c_bit_algo; --- linux-2.6.20-rc3.orig/drivers/i2c/algos/i2c-algo-pca.c 2007-01-04 16:30:14.000000000 +0100 +++ linux-2.6.20-rc3/drivers/i2c/algos/i2c-algo-pca.c 2007-01-04 16:30:24.000000000 +0100 @@ -193,7 +193,8 @@ static int pca_xfer(struct i2c_adapter * msleep(10); } if (state != 0xf8) { - dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state); + dev_dbg(i2c_adap->class_dev.dev, + "bus is not idle. status is %#04x\n", state); return -EIO; } --- linux-2.6.20-rc3.orig/drivers/i2c/algos/i2c-algo-pcf.c 2007-01-04 16:30:14.000000000 +0100 +++ linux-2.6.20-rc3/drivers/i2c/algos/i2c-algo-pcf.c 2007-01-04 16:30:24.000000000 +0100 @@ -239,7 +239,8 @@ static int pcf_sendbytes(struct i2c_adap int wrcount, status, timeout; for (wrcount=0; wrcountdev, "i2c_write: writing %2.2X\n", + DEB2(dev_dbg(i2c_adap->class_dev.dev, + "i2c_write: writing %2.2X\n", buf[wrcount]&0xff)); i2c_outb(adap, buf[wrcount]); timeout = wait_for_pin(adap, &status); @@ -249,13 +250,15 @@ static int pcf_sendbytes(struct i2c_adap return -EINTR; } i2c_stop(adap); - dev_err(&i2c_adap->dev, "i2c_write: error - timeout.\n"); + dev_err(i2c_adap->class_dev.dev, + "i2c_write: error - timeout\n"); return -EREMOTEIO; /* got a better one ?? */ } #ifndef STUB_I2C if (status & I2C_PCF_LRB) { i2c_stop(adap); - dev_err(&i2c_adap->dev, "i2c_write: error - no ack.\n"); + dev_err(i2c_adap->class_dev.dev, + "i2c_write: error - no ack\n"); return -EREMOTEIO; /* got a better one ?? */ } #endif @@ -287,14 +290,16 @@ static int pcf_readbytes(struct i2c_adap return -EINTR; } i2c_stop(adap); - dev_err(&i2c_adap->dev, "pcf_readbytes timed out.\n"); + dev_err(i2c_adap->class_dev.dev, + "pcf_readbytes timed out\n"); return (-1); } #ifndef STUB_I2C if ((status & I2C_PCF_LRB) && (i != count)) { i2c_stop(adap); - dev_err(&i2c_adap->dev, "i2c_read: i2c_inb, No ack.\n"); + dev_err(i2c_adap->class_dev.dev, + "i2c_read: i2c_inb, no ack\n"); return (-1); } #endif @@ -471,7 +476,7 @@ int i2c_pcf_add_bus(struct i2c_adapter * struct i2c_algo_pcf_data *pcf_adap = adap->algo_data; int rval; - DEB2(dev_dbg(&adap->dev, "hw routines registered.\n")); + DEB2(dev_dbg(adap->class_dev.dev, "hw routines registered\n")); /* register new adapter to i2c module... */ adap->algo = &pcf_algo; --- linux-2.6.20-rc3.orig/drivers/i2c/chips/isp1301_omap.c 2007-01-04 16:30:14.000000000 +0100 +++ linux-2.6.20-rc3/drivers/i2c/chips/isp1301_omap.c 2007-01-04 16:30:24.000000000 +0100 @@ -1511,13 +1511,14 @@ static int isp1301_probe(struct i2c_adap if (kind < 0) { status = isp1301_get_u16(isp, ISP1301_VENDOR_ID); if (status != I2C_VENDOR_ID_PHILIPS) { - dev_dbg(&bus->dev, "addr %d not philips id: %d\n", + dev_dbg(bus->class_dev.dev, + "addr %d not philips id: %d\n", address, status); goto fail1; } status = isp1301_get_u16(isp, ISP1301_PRODUCT_ID); if (status != I2C_PRODUCT_ID_PHILIPS_1301) { - dev_dbg(&bus->dev, "%d not isp1301, %d\n", + dev_dbg(bus->class_dev.dev, "%d not isp1301, %d\n", address, status); goto fail1; } @@ -1525,7 +1526,8 @@ static int isp1301_probe(struct i2c_adap status = i2c_attach_client(i2c); if (status < 0) { - dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n", + dev_dbg(bus->class_dev.dev, + "can't attach %s to device %d, err %d\n", DRIVER_NAME, address, status); fail1: kfree(isp); --- linux-2.6.20-rc3.orig/drivers/i2c/chips/tps65010.c 2007-01-04 16:30:14.000000000 +0100 +++ linux-2.6.20-rc3/drivers/i2c/chips/tps65010.c 2007-01-04 16:30:24.000000000 +0100 @@ -499,7 +499,8 @@ tps65010_probe(struct i2c_adapter *bus, unsigned long irqflags; if (the_tps) { - dev_dbg(&bus->dev, "only one %s for now\n", DRIVER_NAME); + pr_debug("%s: only one device supported for now\n", + DRIVER_NAME); return 0; } @@ -517,7 +518,8 @@ tps65010_probe(struct i2c_adapter *bus, status = i2c_attach_client(&tps->client); if (status < 0) { - dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n", + dev_dbg(bus->class_dev.dev, + "can't attach %s to device %d, err %d\n", DRIVER_NAME, address, status); goto fail1; } --- linux-2.6.20-rc3.orig/drivers/i2c/i2c-core.c 2007-01-04 16:30:14.000000000 +0100 +++ linux-2.6.20-rc3/drivers/i2c/i2c-core.c 2007-01-04 16:30:24.000000000 +0100 @@ -217,7 +217,8 @@ int i2c_add_adapter(struct i2c_adapter * if (res) goto out_remove_name; - dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); + dev_dbg(adap->class_dev.dev, "adapter %s [%s] registered\n", + adap->class_dev.class_id, adap->name); /* inform drivers of new adapters */ list_for_each(item,&drivers) { @@ -246,6 +247,7 @@ out_list: int i2c_del_adapter(struct i2c_adapter *adap) { + struct device *dev = adap->class_dev.dev; struct list_head *item, *_n; struct i2c_adapter *adap_from_list; struct i2c_driver *driver; @@ -270,7 +272,7 @@ int i2c_del_adapter(struct i2c_adapter * driver = list_entry(item, struct i2c_driver, list); if (driver->detach_adapter) if ((res = driver->detach_adapter(adap))) { - dev_err(&adap->dev, "detach_adapter failed " + dev_err(dev, "detach_adapter failed " "for driver [%s]\n", driver->driver.name); goto out_unlock; @@ -283,7 +285,7 @@ int i2c_del_adapter(struct i2c_adapter * client = list_entry(item, struct i2c_client, list); if ((res=client->driver->detach_client(client))) { - dev_err(&adap->dev, "detach_client failed for client " + dev_err(dev, "detach_client failed for client " "[%s] at address 0x%02x\n", client->name, client->addr); goto out_unlock; @@ -305,7 +307,8 @@ int i2c_del_adapter(struct i2c_adapter * /* free dynamically allocated bus id */ idr_remove(&i2c_adapter_idr, adap->nr); - dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); + dev_dbg(dev, "adapter %s [%s] unregistered\n", + adap->class_dev.class_id, adap->name); out_unlock: mutex_unlock(&core_lists); @@ -366,10 +369,13 @@ int i2c_del_driver(struct i2c_driver *dr * afterwards. */ list_for_each(item1,&adapters) { + struct device *dev; + adap = list_entry(item1, struct i2c_adapter, list); + dev = adap->class_dev.dev; if (driver->detach_adapter) { if ((res = driver->detach_adapter(adap))) { - dev_err(&adap->dev, "detach_adapter failed " + dev_err(dev, "detach_adapter failed " "for driver [%s]\n", driver->driver.name); goto out_unlock; @@ -379,11 +385,11 @@ int i2c_del_driver(struct i2c_driver *dr client = list_entry(item2, struct i2c_client, list); if (client->driver != driver) continue; - dev_dbg(&adap->dev, "detaching client [%s] " + dev_dbg(dev, "detaching client [%s] " "at 0x%02x\n", client->name, client->addr); if ((res = driver->detach_client(client))) { - dev_err(&adap->dev, "detach_client " + dev_err(dev, "detach_client " "failed for client [%s] at " "0x%02x\n", client->name, client->addr); @@ -440,14 +446,15 @@ int i2c_attach_client(struct i2c_client client->usage_count = 0; - client->dev.parent = &client->adapter->dev; + client->dev.parent = adapter->class_dev.dev; client->dev.driver = &client->driver->driver; client->dev.bus = &i2c_bus_type; client->dev.release = &i2c_client_release; snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), "%d-%04x", i2c_adapter_id(adapter), client->addr); - dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", + dev_dbg(adapter->class_dev.dev, + "client [%s] registering with bus id %s\n", client->name, client->dev.bus_id); res = device_register(&client->dev); if (res) @@ -459,7 +466,7 @@ int i2c_attach_client(struct i2c_client if (adapter->client_register) { if (adapter->client_register(client)) { - dev_dbg(&adapter->dev, "client_register " + dev_dbg(adapter->class_dev.dev, "client_register " "failed for client [%s] at 0x%02x\n", client->name, client->addr); } @@ -473,7 +480,8 @@ out_unregister: wait_for_completion(&client->released); out_list: list_del(&client->list); - dev_err(&adapter->dev, "Failed to attach i2c client %s at 0x%02x " + dev_err(adapter->class_dev.dev, + "Failed to attach i2c client %s at 0x%02x " "(%d)\n", client->name, client->addr, res); out_unlock: mutex_unlock(&adapter->clist_lock); @@ -610,12 +618,13 @@ module_exit(i2c_exit); int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num) { + struct device *dev = adap->class_dev.dev; int ret; if (adap->algo->master_xfer) { #ifdef DEBUG for (ret = 0; ret < num; ret++) { - dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, " + dev_dbg(dev, "master_xfer[%d] %c, addr=0x%02x, " "len=%d\n", ret, msgs[ret].flags & I2C_M_RD ? 'R' : 'W', msgs[ret].addr, msgs[ret].len); } @@ -627,7 +636,7 @@ int i2c_transfer(struct i2c_adapter * ad return ret; } else { - dev_dbg(&adap->dev, "I2C level transfers not supported\n"); + dev_dbg(dev, "I2C transfers not supported\n"); return -ENOSYS; } } @@ -676,7 +685,8 @@ int i2c_control(struct i2c_client *clien int ret = 0; struct i2c_adapter *adap = client->adapter; - dev_dbg(&client->adapter->dev, "i2c ioctl, cmd: 0x%x, arg: %#lx\n", cmd, arg); + dev_dbg(adap->class_dev.dev, "i2c ioctl, cmd: 0x%x, arg: %#lx\n", + cmd, arg); switch (cmd) { case I2C_RETRIES: adap->retries = arg; @@ -699,12 +709,12 @@ int i2c_control(struct i2c_client *clien static int i2c_probe_address(struct i2c_adapter *adapter, int addr, int kind, int (*found_proc) (struct i2c_adapter *, int, int)) { + struct device *dev = adapter->class_dev.dev; int err; /* Make sure the address is valid */ if (addr < 0x03 || addr > 0x77) { - dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n", - addr); + dev_warn(dev, "Invalid probe address 0x%02x\n", addr); return -EINVAL; } @@ -733,8 +743,8 @@ static int i2c_probe_address(struct i2c_ err = 0; if (err) - dev_warn(&adapter->dev, "Client creation failed at 0x%x (%d)\n", - addr, err); + dev_warn(dev, "i2c_probe() callback failed at 0x%02x " + "(err %d)\n", addr, err); return err; } @@ -742,6 +752,7 @@ int i2c_probe(struct i2c_adapter *adapte struct i2c_client_address_data *address_data, int (*found_proc) (struct i2c_adapter *, int, int)) { + struct device *dev = adapter->class_dev.dev; int i, err; int adap_id = i2c_adapter_id(adapter); @@ -756,7 +767,7 @@ int i2c_probe(struct i2c_adapter *adapte i += 2) { if (forces[kind][i] == adap_id || forces[kind][i] == ANY_I2C_BUS) { - dev_dbg(&adapter->dev, "found force " + dev_dbg(dev, "found force " "parameter for adapter %d, " "addr 0x%02x, kind %d\n", adap_id, forces[kind][i + 1], @@ -777,7 +788,7 @@ int i2c_probe(struct i2c_adapter *adapte && address_data->normal_i2c[0] == I2C_CLIENT_END) return 0; - dev_warn(&adapter->dev, "SMBus Quick command not supported, " + dev_warn(dev, "SMBus Quick command not supported, " "can't probe for chips\n"); return -1; } @@ -787,7 +798,7 @@ int i2c_probe(struct i2c_adapter *adapte for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { if (address_data->probe[i] == adap_id || address_data->probe[i] == ANY_I2C_BUS) { - dev_dbg(&adapter->dev, "found probe parameter for " + dev_dbg(dev, "found probe parameter for " "adapter %d, addr 0x%02x\n", adap_id, address_data->probe[i + 1]); err = i2c_probe_address(adapter, @@ -809,7 +820,7 @@ int i2c_probe(struct i2c_adapter *adapte address_data->ignore[j] == ANY_I2C_BUS) && address_data->ignore[j + 1] == address_data->normal_i2c[i]) { - dev_dbg(&adapter->dev, "found ignore " + dev_dbg(dev, "found ignore " "parameter for adapter %d, " "addr 0x%02x\n", adap_id, address_data->ignore[j + 1]); @@ -820,7 +831,7 @@ int i2c_probe(struct i2c_adapter *adapte if (ignore) continue; - dev_dbg(&adapter->dev, "found normal entry for adapter %d, " + dev_dbg(dev, "found normal entry for adapter %d, " "addr 0x%02x\n", adap_id, address_data->normal_i2c[i]); err = i2c_probe_address(adapter, address_data->normal_i2c[i], @@ -1033,6 +1044,7 @@ static s32 i2c_smbus_xfer_emulated(struc }; int i; u8 partial_pec = 0; + struct device *dev = adapter->class_dev.dev; msgbuf0[0] = command; switch(size) { @@ -1076,13 +1088,13 @@ static s32 i2c_smbus_xfer_emulated(struc break; case I2C_SMBUS_BLOCK_DATA: if (read_write == I2C_SMBUS_READ) { - dev_err(&adapter->dev, "Block read not supported " + dev_err(dev, "Block read not supported " "under I2C emulation!\n"); return -1; } else { msg[0].len = data->block[0] + 2; if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 2) { - dev_err(&adapter->dev, "smbus_access called with " + dev_err(dev, "smbus_access called with " "invalid block write size (%d)\n", data->block[0]); return -1; @@ -1092,7 +1104,7 @@ static s32 i2c_smbus_xfer_emulated(struc } break; case I2C_SMBUS_BLOCK_PROC_CALL: - dev_dbg(&adapter->dev, "Block process call not supported " + dev_dbg(dev, "Block process call not supported " "under I2C emulation!\n"); return -1; case I2C_SMBUS_I2C_BLOCK_DATA: @@ -1101,7 +1113,7 @@ static s32 i2c_smbus_xfer_emulated(struc } else { msg[0].len = data->block[0] + 1; if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 1) { - dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with " + dev_err(dev, "i2c_smbus_xfer_emulated called with " "invalid block write size (%d)\n", data->block[0]); return -1; @@ -1111,7 +1123,7 @@ static s32 i2c_smbus_xfer_emulated(struc } break; default: - dev_err(&adapter->dev, "smbus_access called with invalid size (%d)\n", + dev_err(dev, "smbus_access called with invalid size (%d)\n", size); return -1; } --- linux-2.6.20-rc3.orig/drivers/i2c/i2c-dev.c 2007-01-04 16:30:14.000000000 +0100 +++ linux-2.6.20-rc3/drivers/i2c/i2c-dev.c 2007-01-04 16:30:24.000000000 +0100 @@ -166,8 +166,9 @@ static int i2cdev_ioctl(struct inode *in u8 __user **data_ptrs; int i,datasize,res; unsigned long funcs; + struct device *dev = client->adapter->class_dev.dev; - dev_dbg(&client->adapter->dev, "ioctl, cmd=0x%02x, arg=0x%02lx\n", + dev_dbg(dev, "ioctl, cmd=0x%02x, arg=0x%02lx\n", cmd, arg); switch ( cmd ) { @@ -286,7 +287,7 @@ static int i2cdev_ioctl(struct inode *in (data_arg.size != I2C_SMBUS_BLOCK_DATA) && (data_arg.size != I2C_SMBUS_I2C_BLOCK_DATA) && (data_arg.size != I2C_SMBUS_BLOCK_PROC_CALL)) { - dev_dbg(&client->adapter->dev, + dev_dbg(dev, "size out of range (%x) in ioctl I2C_SMBUS.\n", data_arg.size); return -EINVAL; @@ -295,7 +296,7 @@ static int i2cdev_ioctl(struct inode *in so the check is valid if size==I2C_SMBUS_QUICK too. */ if ((data_arg.read_write != I2C_SMBUS_READ) && (data_arg.read_write != I2C_SMBUS_WRITE)) { - dev_dbg(&client->adapter->dev, + dev_dbg(dev, "read_write out of range (%x) in ioctl I2C_SMBUS.\n", data_arg.read_write); return -EINVAL; @@ -314,7 +315,7 @@ static int i2cdev_ioctl(struct inode *in data_arg.size, NULL); if (data_arg.data == NULL) { - dev_dbg(&client->adapter->dev, + dev_dbg(dev, "data is NULL pointer in ioctl I2C_SMBUS.\n"); return -EINVAL; } @@ -414,7 +415,7 @@ static int i2cdev_attach_adapter(struct return PTR_ERR(i2c_dev); /* register this i2c device with the driver core */ - i2c_dev->dev = device_create(i2c_dev_class, &adap->dev, + i2c_dev->dev = device_create(i2c_dev_class, adap->class_dev.dev, MKDEV(I2C_MAJOR, adap->nr), "i2c-%d", adap->nr); if (IS_ERR(i2c_dev->dev)) {