Skip to contentSkip to conversation

i2c: Prevent client usage count breakage

PATCH New Jean Delvare 1 participant 1 message Mar 26, 2006 I2C

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: Prevent client usage count breakage

Hi Greg,

While working on the i2c chip probing stuff, I noticed the following problem. Right now, no driver in the kernel tree seem to have hit it, but let's fix it before any does. Can you please enqueue this patch for 2.6.17?

Thanks.

* * * * *
Content-Disposition: inline; filename=i2c-core-init-usage-count-before-calling-client-register.patch

The i2c clients usage count should be initialized before calling an adapter's client_register method, else calling i2c_use_client from within this method breaks the count.

Signed-off-by Jean Delvare <khali at linux-fr.org>
---
 drivers/i2c/i2c-core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/i2c-core.c +2 -2
@@ -403,6 +403,8 @@
 	list_add_tail(&client->list,&adapter->clients);
 	mutex_unlock(&adapter->clist_lock);
 	
+	client->usage_count = 0;
+
 	if (adapter->client_register)  {
 		if (adapter->client_register(client))  {
 			dev_dbg(&adapter->dev, "client_register "
@@ -411,8 +413,6 @@
 		}
 	}
 
-	client->usage_count = 0;
-
 	client->dev.parent = &client->adapter->dev;
 	client->dev.driver = &client->driver->driver;
 	client->dev.bus = &i2c_bus_type;
Signature · 1 line
Jean Delvare