summaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2009-06-19 16:58:19 +0200
committerJean Delvare <khali@linux-fr.org>2009-06-19 16:58:19 +0200
commite549c2b54dd90a056d6824b885d438b7437874f0 (patch)
tree45da005101a1587c18b41f4ad572458e08b95099 /drivers/i2c
parent1e40ac12dab22d98d0178e87364cf4e36862809c (diff)
i2c: Kill the redundant client list
We used to maintain our own per-adapter list of i2c clients, but this is redundant with what the driver core does, and no longer needed. Just drop the redundant list. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: David Brownell <dbrownell@users.sourceforge.net>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-core.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 95fb997b41e..b1fd00d9a5c 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -276,10 +276,6 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
if (status)
goto out_err;
- mutex_lock(&adap->clist_lock);
- list_add_tail(&client->list, &adap->clients);
- mutex_unlock(&adap->clist_lock);
-
dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n",
client->name, dev_name(&client->dev));
@@ -301,12 +297,6 @@ EXPORT_SYMBOL_GPL(i2c_new_device);
*/
void i2c_unregister_device(struct i2c_client *client)
{
- struct i2c_adapter *adapter = client->adapter;
-
- mutex_lock(&adapter->clist_lock);
- list_del(&client->list);
- mutex_unlock(&adapter->clist_lock);
-
device_unregister(&client->dev);
}
EXPORT_SYMBOL_GPL(i2c_unregister_device);
@@ -432,8 +422,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
return -EAGAIN;
mutex_init(&adap->bus_lock);
- mutex_init(&adap->clist_lock);
- INIT_LIST_HEAD(&adap->clients);
mutex_lock(&core_lock);
@@ -583,6 +571,14 @@ static int i2c_do_del_adapter(struct device_driver *d, void *data)
return res;
}
+static int __unregister_client(struct device *dev, void *dummy)
+{
+ struct i2c_client *client = i2c_verify_client(dev);
+ if (client)
+ i2c_unregister_device(client);
+ return 0;
+}
+
/**
* i2c_del_adapter - unregister I2C adapter
* @adap: the adapter being unregistered
@@ -593,7 +589,6 @@ static int i2c_do_del_adapter(struct device_driver *d, void *data)
*/
int i2c_del_adapter(struct i2c_adapter *adap)
{
- struct i2c_client *client, *_n;
int res = 0;
mutex_lock(&core_lock);
@@ -612,10 +607,9 @@ int i2c_del_adapter(struct i2c_adapter *adap)
if (res)
goto out_unlock;
- /* Detach any active clients */
- list_for_each_entry_safe_reverse(client, _n, &adap->clients, list) {
- i2c_unregister_device(client);
- }
+ /* Detach any active clients. This can't fail, thus we do not
+ checking the returned value. */
+ res = device_for_each_child(&adap->dev, NULL, __unregister_client);
/* clean up the sysfs representation */
init_completion(&adap->dev_released);