public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 2.6.28-rc5] i2c:  remove i2c_adapter.clist_lock
@ 2008-11-20 22:38 David Brownell
       [not found] ` <200811201438.08788.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: David Brownell @ 2008-11-20 22:38 UTC (permalink / raw)
  To: Linux-I2C

From: David Brownell <dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>

Move list add/remove operations now protected by i2c_adapter.clist_lock
into the driver model probe() and remove() calls, where driver model
locking protects them.  This is a minor code and data shrink.

Note that the adapter "child list" is still protected inconsistently;
this patch just simplifies locking, and makes this list more directly
mirror the one maintained by the driver model.  Removing this list may
need to wait until the legacy I2C driver binding model is removed.

Signed-off-by: David Brownell <dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/i2c/i2c-core.c |   17 ++++-------------
 include/linux/i2c.h    |    1 -
 2 files changed, 4 insertions(+), 14 deletions(-)

--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -116,6 +116,8 @@ static int i2c_device_probe(struct devic
 	status = driver->probe(client, i2c_match_id(driver->id_table, client));
 	if (status)
 		client->driver = NULL;
+	else
+		list_add_tail(&client->list, &client->adapter->clients);
 	return status;
 }
 
@@ -125,6 +127,8 @@ static int i2c_device_remove(struct devi
 	struct i2c_driver	*driver;
 	int			status;
 
+	list_del(&client->list);
+
 	if (!dev->driver)
 		return 0;
 
@@ -315,10 +319,6 @@ void i2c_unregister_device(struct i2c_cl
 		}
 	}
 
-	mutex_lock(&adapter->clist_lock);
-	list_del(&client->list);
-	mutex_unlock(&adapter->clist_lock);
-
 	device_unregister(&client->dev);
 }
 EXPORT_SYMBOL_GPL(i2c_unregister_device);
@@ -445,7 +445,6 @@ static int i2c_register_adapter(struct i
 		return -EAGAIN;
 
 	mutex_init(&adap->bus_lock);
-	mutex_init(&adap->clist_lock);
 	INIT_LIST_HEAD(&adap->clients);
 
 	mutex_lock(&core_lock);
@@ -851,10 +850,6 @@ int i2c_attach_client(struct i2c_client 
 	if (res)
 		goto out_err;
 
-	mutex_lock(&adapter->clist_lock);
-	list_add_tail(&client->list, &adapter->clients);
-	mutex_unlock(&adapter->clist_lock);
-
 	dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n",
 		client->name, client->dev.bus_id);
 
@@ -890,10 +885,6 @@ int i2c_detach_client(struct i2c_client 
 		}
 	}
 
-	mutex_lock(&adapter->clist_lock);
-	list_del(&client->list);
-	mutex_unlock(&adapter->clist_lock);
-
 	init_completion(&client->released);
 	device_unregister(&client->dev);
 	wait_for_completion(&client->released);
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -359,7 +359,6 @@ struct i2c_adapter {
 	/* data fields that are valid for all devices	*/
 	u8 level; 			/* nesting level for lockdep */
 	struct mutex bus_lock;
-	struct mutex clist_lock;
 
 	int timeout;
 	int retries;

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-11-25 11:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-20 22:38 [patch 2.6.28-rc5] i2c: remove i2c_adapter.clist_lock David Brownell
     [not found] ` <200811201438.08788.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-11-25  9:12   ` Jean Delvare
     [not found]     ` <20081125101203.58e3f032-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-11-25 10:24       ` David Brownell
     [not found]         ` <200811250224.01610.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-11-25 11:01           ` Jean Delvare
     [not found]             ` <20081125120100.6581f394-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-11-25 11:27               ` David Brownell
     [not found]                 ` <200811250327.08464.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-11-25 11:54                   ` Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox