linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c-core: fix for dep-lock validator
@ 2012-09-05 12:04 Michael Lawnick
       [not found] ` <50473FC9.6000203-Mmb7MZpHnFY@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Lawnick @ 2012-09-05 12:04 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA, khali-PUYAD+kWke1g9hUCZPvPmw

If kernel is compiled with CONFIG_PROVE_LOCKING the
validator raises an error when a multiplexer is removed
via sysfs and sub-clients are connected to it. This is a
false positive.
Documentation/lockdep-design.txt recommends to handle this
via calls to mutex_lock_nested()

Signed-off-by: Michael Lawnick <ml.lawnick-Mmb7MZpHnFY@public.gmane.org>
Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org
---
Documentation originally recommends to use an enum.
This is not applicable for a tree with unlimited depth.
This is why I use the adapter id which is expected
to be unique and monotonic increasing with the depth of
the tree.

--- linux/drivers/i2c/i2c-core.c.dist	2012-09-05 09:46:50.000000000 +0200
+++ linux/drivers/i2c/i2c-core.c	2012-09-05 09:56:58.000000000 +0200
@@ -628,7 +628,7 @@ i2c_sysfs_delete_device(struct device *d

 	/* Make sure the device was added through sysfs */
 	res = -ENOENT;
-	mutex_lock(&adap->userspace_clients_lock);
+	mutex_lock_nested(&adap->userspace_clients_lock, i2c_adapter_id(adap));
 	list_for_each_entry_safe(client, next, &adap->userspace_clients,
 				 detected) {
 		if (client->addr == addr) {
@@ -936,7 +936,7 @@ int i2c_del_adapter(struct i2c_adapter *
 		return res;

 	/* Remove devices instantiated from sysfs */
-	mutex_lock(&adap->userspace_clients_lock);
+	mutex_lock_nested(&adap->userspace_clients_lock, i2c_adapter_id(adap));
 	list_for_each_entry_safe(client, next, &adap->userspace_clients,
 				 detected) {
 		dev_dbg(&adap->dev, "Removing %s at 0x%x\n", client->name,

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

end of thread, other threads:[~2012-09-07 20:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-05 12:04 [PATCH] i2c-core: fix for dep-lock validator Michael Lawnick
     [not found] ` <50473FC9.6000203-Mmb7MZpHnFY@public.gmane.org>
2012-09-07 13:00   ` Michael Lawnick
     [not found]     ` <5049F005.2040300-Mmb7MZpHnFY@public.gmane.org>
2012-09-07 13:28       ` Jean Delvare
     [not found]         ` <20120907152840.4de537b3-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-09-07 13:58           ` Michael Lawnick
     [not found]             ` <5049FD7E.9080709-Mmb7MZpHnFY@public.gmane.org>
2012-09-07 14:20               ` Jean Delvare
     [not found]                 ` <20120907162032.140f0419-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-09-07 18:07                   ` Jean Delvare
2012-09-07 20:51   ` Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).