Commit 026526f5 authored by Jean Delvare's avatar Jean Delvare Committed by Jean Delvare

i2c: Drop redundant i2c_driver.list

i2c_driver.list is superfluous, this list duplicates the one
maintained by the driver core. Drop it.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Acked-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
parent 87c6c229
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include "i2c-core.h" #include "i2c-core.h"
static LIST_HEAD(drivers);
static DEFINE_MUTEX(core_lists); static DEFINE_MUTEX(core_lists);
static DEFINE_IDR(i2c_adapter_idr); static DEFINE_IDR(i2c_adapter_idr);
...@@ -320,11 +319,21 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter) ...@@ -320,11 +319,21 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter)
mutex_unlock(&__i2c_board_lock); mutex_unlock(&__i2c_board_lock);
} }
static int i2c_do_add_adapter(struct device_driver *d, void *data)
{
struct i2c_driver *driver = to_i2c_driver(d);
struct i2c_adapter *adap = data;
if (driver->attach_adapter) {
/* We ignore the return code; if it fails, too bad */
driver->attach_adapter(adap);
}
return 0;
}
static int i2c_register_adapter(struct i2c_adapter *adap) static int i2c_register_adapter(struct i2c_adapter *adap)
{ {
int res = 0; int res = 0, dummy;
struct list_head *item;
struct i2c_driver *driver;
mutex_init(&adap->bus_lock); mutex_init(&adap->bus_lock);
mutex_init(&adap->clist_lock); mutex_init(&adap->clist_lock);
...@@ -355,12 +364,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap) ...@@ -355,12 +364,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
i2c_scan_static_board_info(adap); i2c_scan_static_board_info(adap);
/* let legacy drivers scan this bus for matching devices */ /* let legacy drivers scan this bus for matching devices */
list_for_each(item,&drivers) { dummy = bus_for_each_drv(&i2c_bus_type, NULL, adap,
driver = list_entry(item, struct i2c_driver, list); i2c_do_add_adapter);
if (driver->attach_adapter)
/* We ignore the return code; if it fails, too bad */
driver->attach_adapter(adap);
}
out_unlock: out_unlock:
mutex_unlock(&core_lists); mutex_unlock(&core_lists);
...@@ -460,6 +465,21 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adap) ...@@ -460,6 +465,21 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adap)
} }
EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter); EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter);
static int i2c_do_del_adapter(struct device_driver *d, void *data)
{
struct i2c_driver *driver = to_i2c_driver(d);
struct i2c_adapter *adapter = data;
int res;
if (!driver->detach_adapter)
return 0;
res = driver->detach_adapter(adapter);
if (res)
dev_err(&adapter->dev, "detach_adapter failed (%d) "
"for driver [%s]\n", res, driver->driver.name);
return res;
}
/** /**
* i2c_del_adapter - unregister I2C adapter * i2c_del_adapter - unregister I2C adapter
* @adap: the adapter being unregistered * @adap: the adapter being unregistered
...@@ -471,7 +491,6 @@ EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter); ...@@ -471,7 +491,6 @@ EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter);
int i2c_del_adapter(struct i2c_adapter *adap) int i2c_del_adapter(struct i2c_adapter *adap)
{ {
struct list_head *item, *_n; struct list_head *item, *_n;
struct i2c_driver *driver;
struct i2c_client *client; struct i2c_client *client;
int res = 0; int res = 0;
...@@ -485,16 +504,11 @@ int i2c_del_adapter(struct i2c_adapter *adap) ...@@ -485,16 +504,11 @@ int i2c_del_adapter(struct i2c_adapter *adap)
goto out_unlock; goto out_unlock;
} }
list_for_each(item,&drivers) { /* Tell drivers about this removal */
driver = list_entry(item, struct i2c_driver, list); res = bus_for_each_drv(&i2c_bus_type, NULL, adap,
if (driver->detach_adapter) i2c_do_del_adapter);
if ((res = driver->detach_adapter(adap))) { if (res)
dev_err(&adap->dev, "detach_adapter failed " goto out_unlock;
"for driver [%s]\n",
driver->driver.name);
goto out_unlock;
}
}
/* detach any active clients. This must be done first, because /* detach any active clients. This must be done first, because
* it can fail; in which case we give up. */ * it can fail; in which case we give up. */
...@@ -577,7 +591,6 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) ...@@ -577,7 +591,6 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
mutex_lock(&core_lists); mutex_lock(&core_lists);
list_add_tail(&driver->list,&drivers);
pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name);
/* legacy drivers scan i2c busses directly */ /* legacy drivers scan i2c busses directly */
...@@ -647,7 +660,6 @@ void i2c_del_driver(struct i2c_driver *driver) ...@@ -647,7 +660,6 @@ void i2c_del_driver(struct i2c_driver *driver)
unregister: unregister:
driver_unregister(&driver->driver); driver_unregister(&driver->driver);
list_del(&driver->list);
pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
mutex_unlock(&core_lists); mutex_unlock(&core_lists);
......
...@@ -140,7 +140,6 @@ struct i2c_driver { ...@@ -140,7 +140,6 @@ struct i2c_driver {
int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
struct device_driver driver; struct device_driver driver;
struct list_head list;
}; };
#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
......
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