Commit 35d8b2e6 authored by Laurent Riffard's avatar Laurent Riffard Committed by Greg Kroah-Hartman

[PATCH] i2c: Drop i2c_driver.{owner,name}, 1 of 11

We should use the i2c_driver.driver's .name and .owner fields
instead of the i2c_driver's ones.

This patch updates the core of the i2c drivers: it removes .name and
.owner fields from the struct i2c_device and modify various
functions to use struct device fields instead.
Signed-off-by: default avatarLaurent Riffard <laurent.riffard@free.fr>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 482c788d
...@@ -92,8 +92,6 @@ int i2c_isa_add_driver(struct i2c_driver *driver) ...@@ -92,8 +92,6 @@ int i2c_isa_add_driver(struct i2c_driver *driver)
int res; int res;
/* Add the driver to the list of i2c drivers in the driver core */ /* Add the driver to the list of i2c drivers in the driver core */
driver->driver.name = driver->name;
driver->driver.owner = driver->owner;
driver->driver.bus = &i2c_bus_type; driver->driver.bus = &i2c_bus_type;
driver->driver.probe = i2c_isa_device_probe; driver->driver.probe = i2c_isa_device_probe;
driver->driver.remove = i2c_isa_device_remove; driver->driver.remove = i2c_isa_device_remove;
...@@ -124,7 +122,7 @@ int i2c_isa_del_driver(struct i2c_driver *driver) ...@@ -124,7 +122,7 @@ int i2c_isa_del_driver(struct i2c_driver *driver)
if ((res = driver->detach_client(client))) { if ((res = driver->detach_client(client))) {
dev_err(&isa_adapter.dev, "Failed, driver " dev_err(&isa_adapter.dev, "Failed, driver "
"%s not unregistered!\n", "%s not unregistered!\n",
driver->name); driver->driver.name);
return res; return res;
} }
} }
......
...@@ -235,7 +235,8 @@ int i2c_del_adapter(struct i2c_adapter *adap) ...@@ -235,7 +235,8 @@ int i2c_del_adapter(struct i2c_adapter *adap)
if (driver->detach_adapter) if (driver->detach_adapter)
if ((res = driver->detach_adapter(adap))) { if ((res = driver->detach_adapter(adap))) {
dev_err(&adap->dev, "detach_adapter failed " dev_err(&adap->dev, "detach_adapter failed "
"for driver [%s]\n", driver->name); "for driver [%s]\n",
driver->driver.name);
goto out_unlock; goto out_unlock;
} }
} }
...@@ -295,8 +296,6 @@ int i2c_add_driver(struct i2c_driver *driver) ...@@ -295,8 +296,6 @@ int i2c_add_driver(struct i2c_driver *driver)
down(&core_lists); down(&core_lists);
/* add the driver to the list of i2c drivers in the driver core */ /* add the driver to the list of i2c drivers in the driver core */
driver->driver.owner = driver->owner;
driver->driver.name = driver->name;
driver->driver.bus = &i2c_bus_type; driver->driver.bus = &i2c_bus_type;
driver->driver.probe = i2c_device_probe; driver->driver.probe = i2c_device_probe;
driver->driver.remove = i2c_device_remove; driver->driver.remove = i2c_device_remove;
...@@ -306,7 +305,7 @@ int i2c_add_driver(struct i2c_driver *driver) ...@@ -306,7 +305,7 @@ int i2c_add_driver(struct i2c_driver *driver)
goto out_unlock; goto out_unlock;
list_add_tail(&driver->list,&drivers); list_add_tail(&driver->list,&drivers);
pr_debug("i2c-core: driver [%s] registered\n", driver->name); pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name);
/* now look for instances of driver on our adapters */ /* now look for instances of driver on our adapters */
if (driver->attach_adapter) { if (driver->attach_adapter) {
...@@ -344,7 +343,8 @@ int i2c_del_driver(struct i2c_driver *driver) ...@@ -344,7 +343,8 @@ int i2c_del_driver(struct i2c_driver *driver)
if (driver->detach_adapter) { if (driver->detach_adapter) {
if ((res = driver->detach_adapter(adap))) { if ((res = driver->detach_adapter(adap))) {
dev_err(&adap->dev, "detach_adapter failed " dev_err(&adap->dev, "detach_adapter failed "
"for driver [%s]\n", driver->name); "for driver [%s]\n",
driver->driver.name);
goto out_unlock; goto out_unlock;
} }
} else { } else {
...@@ -368,7 +368,7 @@ int i2c_del_driver(struct i2c_driver *driver) ...@@ -368,7 +368,7 @@ int i2c_del_driver(struct i2c_driver *driver)
driver_unregister(&driver->driver); driver_unregister(&driver->driver);
list_del(&driver->list); list_del(&driver->list);
pr_debug("i2c-core: driver [%s] unregistered\n", driver->name); pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
out_unlock: out_unlock:
up(&core_lists); up(&core_lists);
...@@ -473,10 +473,10 @@ int i2c_detach_client(struct i2c_client *client) ...@@ -473,10 +473,10 @@ int i2c_detach_client(struct i2c_client *client)
static int i2c_inc_use_client(struct i2c_client *client) static int i2c_inc_use_client(struct i2c_client *client)
{ {
if (!try_module_get(client->driver->owner)) if (!try_module_get(client->driver->driver.owner))
return -ENODEV; return -ENODEV;
if (!try_module_get(client->adapter->owner)) { if (!try_module_get(client->adapter->owner)) {
module_put(client->driver->owner); module_put(client->driver->driver.owner);
return -ENODEV; return -ENODEV;
} }
...@@ -485,7 +485,7 @@ static int i2c_inc_use_client(struct i2c_client *client) ...@@ -485,7 +485,7 @@ static int i2c_inc_use_client(struct i2c_client *client)
static void i2c_dec_use_client(struct i2c_client *client) static void i2c_dec_use_client(struct i2c_client *client)
{ {
module_put(client->driver->owner); module_put(client->driver->driver.owner);
module_put(client->adapter->owner); module_put(client->adapter->owner);
} }
...@@ -524,14 +524,14 @@ void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg) ...@@ -524,14 +524,14 @@ void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg)
down(&adap->clist_lock); down(&adap->clist_lock);
list_for_each(item,&adap->clients) { list_for_each(item,&adap->clients) {
client = list_entry(item, struct i2c_client, list); client = list_entry(item, struct i2c_client, list);
if (!try_module_get(client->driver->owner)) if (!try_module_get(client->driver->driver.owner))
continue; continue;
if (NULL != client->driver->command) { if (NULL != client->driver->command) {
up(&adap->clist_lock); up(&adap->clist_lock);
client->driver->command(client,cmd,arg); client->driver->command(client,cmd,arg);
down(&adap->clist_lock); down(&adap->clist_lock);
} }
module_put(client->driver->owner); module_put(client->driver->driver.owner);
} }
up(&adap->clist_lock); up(&adap->clist_lock);
} }
......
...@@ -481,8 +481,10 @@ static int i2cdev_command(struct i2c_client *client, unsigned int cmd, ...@@ -481,8 +481,10 @@ static int i2cdev_command(struct i2c_client *client, unsigned int cmd,
} }
static struct i2c_driver i2cdev_driver = { static struct i2c_driver i2cdev_driver = {
.driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "dev_driver", .name = "dev_driver",
},
.id = I2C_DRIVERID_I2CDEV, .id = I2C_DRIVERID_I2CDEV,
.attach_adapter = i2cdev_attach_adapter, .attach_adapter = i2cdev_attach_adapter,
.detach_adapter = i2cdev_detach_adapter, .detach_adapter = i2cdev_detach_adapter,
......
...@@ -105,11 +105,12 @@ extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, ...@@ -105,11 +105,12 @@ extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
* A driver is capable of handling one or more physical devices present on * A driver is capable of handling one or more physical devices present on
* I2C adapters. This information is used to inform the driver of adapter * I2C adapters. This information is used to inform the driver of adapter
* events. * events.
*
* The driver.owner field should be set to the module owner of this driver.
* The driver.name field should be set to the name of this driver.
*/ */
struct i2c_driver { struct i2c_driver {
struct module *owner;
char name[32];
int id; int id;
unsigned int class; unsigned int class;
......
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