All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: Mark instantiated device nodes with OF_POPULATE
@ 2015-01-15 18:33 Pantelis Antoniou
       [not found] ` <1421346798-17148-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 36+ messages in thread
From: Pantelis Antoniou @ 2015-01-15 18:33 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Guenter Roeck, Matt Porter, Greg Kroah-Hartman, Grant Likely,
	Rob Herring, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Pantelis Antoniou,
	Pantelis Antoniou

Mark (and unmark) device nodes with the POPULATE flag as appropriate.
This is required to avoid multi probing when using I2C and device
overlays containing a mux.
This patch is also more careful with the release of the adapter device
which caused a deadlock with muxes, and does not break the build
on !OF since the node flag accessors are not defined then.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
---
 drivers/i2c/i2c-core.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 39d25a8..1d44e3a 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1122,6 +1122,10 @@ EXPORT_SYMBOL_GPL(i2c_new_device);
  */
 void i2c_unregister_device(struct i2c_client *client)
 {
+#if IS_ENABLED(CONFIG_OF_DYNAMIC)
+	if (client->dev.of_node)
+		of_node_clear_flag(client->dev.of_node, OF_POPULATED);
+#endif
 	device_unregister(&client->dev);
 }
 EXPORT_SYMBOL_GPL(i2c_unregister_device);
@@ -1441,8 +1445,11 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
 
 	dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
 
-	for_each_available_child_of_node(adap->dev.of_node, node)
+	for_each_available_child_of_node(adap->dev.of_node, node) {
+		if (of_node_test_and_set_flag(node, OF_POPULATED))
+			continue;
 		of_i2c_register_device(adap, node);
+	}
 }
 
 static int of_dev_node_match(struct device *dev, void *data)
@@ -1976,6 +1983,11 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
 		if (adap == NULL)
 			return NOTIFY_OK;	/* not for us */
 
+		if (of_node_test_and_set_flag(rd->dn, OF_POPULATED)) {
+			put_device(&adap->dev);
+			return NOTIFY_OK;
+		}
+
 		client = of_i2c_register_device(adap, rd->dn);
 		put_device(&adap->dev);
 
@@ -1986,6 +1998,10 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
 		}
 		break;
 	case OF_RECONFIG_CHANGE_REMOVE:
+		/* already depopulated? */
+		if (!of_node_check_flag(rd->dn, OF_POPULATED))
+			return NOTIFY_OK;
+
 		/* find our device by node */
 		client = of_find_i2c_device_by_node(rd->dn);
 		if (client == NULL)
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 36+ messages in thread
* [PATCH] i2c: Mark instantiated device nodes with OF_POPULATE
@ 2015-01-24  7:16 Pantelis Antoniou
       [not found] ` <1422083789-18905-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 36+ messages in thread
From: Pantelis Antoniou @ 2015-01-24  7:16 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Guenter Roeck, Matt Porter, Greg Kroah-Hartman, Grant Likely,
	Rob Herring, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Pantelis Antoniou,
	Pantelis Antoniou

Mark (and unmark) device nodes with the POPULATE flag as appropriate.
This is required to avoid multi probing when using I2C and device
overlays containing a mux.
This patch is also more careful with the release of the adapter device
which caused a deadlock with muxes, and does not break the build
on !OF since the node flag accessors are not defined then.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
---
 drivers/i2c/i2c-core.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 39d25a8..8c32ee3 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1122,6 +1122,8 @@ EXPORT_SYMBOL_GPL(i2c_new_device);
  */
 void i2c_unregister_device(struct i2c_client *client)
 {
+	if (client->dev.of_node)
+		of_node_clear_flag(client->dev.of_node, OF_POPULATED);
 	device_unregister(&client->dev);
 }
 EXPORT_SYMBOL_GPL(i2c_unregister_device);
@@ -1441,8 +1443,11 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
 
 	dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
 
-	for_each_available_child_of_node(adap->dev.of_node, node)
+	for_each_available_child_of_node(adap->dev.of_node, node) {
+		if (of_node_test_and_set_flag(node, OF_POPULATED))
+			continue;
 		of_i2c_register_device(adap, node);
+	}
 }
 
 static int of_dev_node_match(struct device *dev, void *data)
@@ -1976,6 +1981,11 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
 		if (adap == NULL)
 			return NOTIFY_OK;	/* not for us */
 
+		if (of_node_test_and_set_flag(rd->dn, OF_POPULATED)) {
+			put_device(&adap->dev);
+			return NOTIFY_OK;
+		}
+
 		client = of_i2c_register_device(adap, rd->dn);
 		put_device(&adap->dev);
 
@@ -1986,6 +1996,10 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
 		}
 		break;
 	case OF_RECONFIG_CHANGE_REMOVE:
+		/* already depopulated? */
+		if (!of_node_check_flag(rd->dn, OF_POPULATED))
+			return NOTIFY_OK;
+
 		/* find our device by node */
 		client = of_find_i2c_device_by_node(rd->dn);
 		if (client == NULL)
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 36+ messages in thread
* [PATCH] i2c: Mark instantiated device nodes with OF_POPULATE
@ 2015-01-15 16:33 Pantelis Antoniou
       [not found] ` <1421339635-16039-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 36+ messages in thread
From: Pantelis Antoniou @ 2015-01-15 16:33 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Guenter Roeck, Matt Porter, Greg Kroah-Hartman, Grant Likely,
	Rob Herring, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Pantelis Antoniou,
	Pantelis Antoniou

Mark (and unmark) device nodes with the POPULATE flag as appropriate.
This is required to avoid multi probing when using I2C and device
overlays containing a mux.
This patch is also more careful with the release of the adapter device
which caused a deadlock with muxes.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
---
 drivers/i2c/i2c-core.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 39d25a8..8c32ee3 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1122,6 +1122,8 @@ EXPORT_SYMBOL_GPL(i2c_new_device);
  */
 void i2c_unregister_device(struct i2c_client *client)
 {
+	if (client->dev.of_node)
+		of_node_clear_flag(client->dev.of_node, OF_POPULATED);
 	device_unregister(&client->dev);
 }
 EXPORT_SYMBOL_GPL(i2c_unregister_device);
@@ -1441,8 +1443,11 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
 
 	dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
 
-	for_each_available_child_of_node(adap->dev.of_node, node)
+	for_each_available_child_of_node(adap->dev.of_node, node) {
+		if (of_node_test_and_set_flag(node, OF_POPULATED))
+			continue;
 		of_i2c_register_device(adap, node);
+	}
 }
 
 static int of_dev_node_match(struct device *dev, void *data)
@@ -1976,6 +1981,11 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
 		if (adap == NULL)
 			return NOTIFY_OK;	/* not for us */
 
+		if (of_node_test_and_set_flag(rd->dn, OF_POPULATED)) {
+			put_device(&adap->dev);
+			return NOTIFY_OK;
+		}
+
 		client = of_i2c_register_device(adap, rd->dn);
 		put_device(&adap->dev);
 
@@ -1986,6 +1996,10 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
 		}
 		break;
 	case OF_RECONFIG_CHANGE_REMOVE:
+		/* already depopulated? */
+		if (!of_node_check_flag(rd->dn, OF_POPULATED))
+			return NOTIFY_OK;
+
 		/* find our device by node */
 		client = of_find_i2c_device_by_node(rd->dn);
 		if (client == NULL)
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 36+ messages in thread
* [PATCH] i2c: Mark instantiated device nodes with OF_POPULATE
@ 2015-01-12 17:01 Pantelis Antoniou
       [not found] ` <1421082094-10267-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 36+ messages in thread
From: Pantelis Antoniou @ 2015-01-12 17:01 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Guenter Roeck, Matt Porter, Greg Kroah-Hartman, Grant Likely,
	Rob Herring, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Pantelis Antoniou,
	Pantelis Antoniou

Mark (and unmark) device nodes with the POPULATE flag as appropriate.
This is required to avoid multi probing when using I2C and device
overlays containing a mux.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
---
 drivers/i2c/i2c-core.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index e020a16..afc189c 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1122,6 +1122,8 @@ EXPORT_SYMBOL_GPL(i2c_new_device);
  */
 void i2c_unregister_device(struct i2c_client *client)
 {
+	if (client->dev.of_node)
+		of_node_clear_flag(client->dev.of_node, OF_POPULATED);
 	device_unregister(&client->dev);
 }
 EXPORT_SYMBOL_GPL(i2c_unregister_device);
@@ -1441,8 +1443,11 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
 
 	dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
 
-	for_each_available_child_of_node(adap->dev.of_node, node)
+	for_each_available_child_of_node(adap->dev.of_node, node) {
+		if (of_node_test_and_set_flag(node, OF_POPULATED))
+			continue;
 		of_i2c_register_device(adap, node);
+	}
 }
 
 static int of_dev_node_match(struct device *dev, void *data)
@@ -1976,6 +1981,9 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
 		if (adap == NULL)
 			return NOTIFY_OK;	/* not for us */
 
+		if (of_node_test_and_set_flag(rd->dn, OF_POPULATED))
+			return NOTIFY_OK;
+
 		client = of_i2c_register_device(adap, rd->dn);
 		put_device(&adap->dev);
 
@@ -1986,6 +1994,11 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
 		}
 		break;
 	case OF_RECONFIG_CHANGE_REMOVE:
+
+		/* already depopulated? */
+		if (!of_node_check_flag(rd->dn, OF_POPULATED))
+			return NOTIFY_OK;
+
 		/* find our device by node */
 		client = of_find_i2c_device_by_node(rd->dn);
 		if (client == NULL)
-- 
1.7.12

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

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

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-15 18:33 [PATCH] i2c: Mark instantiated device nodes with OF_POPULATE Pantelis Antoniou
     [not found] ` <1421346798-17148-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-01-15 18:55   ` Guenter Roeck
     [not found]     ` <20150115185545.GA20251-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2015-01-15 19:12       ` Pantelis Antoniou
     [not found]         ` <18134341-FA1D-4ED6-8ED3-E4BF8F90B47E-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-01-15 19:23           ` Guenter Roeck
2015-01-15 21:24   ` Rob Herring
2015-01-22 14:48   ` Wolfram Sang
2015-01-22 14:58     ` Rob Herring
     [not found]       ` <CAL_JsqKEBYwX=5zgWbdVRxm-H-sFiDa9rAp26BvuKNECoNW=uQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-22 15:02         ` Wolfram Sang
2015-01-22 23:09           ` Rob Herring
     [not found]             ` <CAL_JsqKYvcec=xWQM7_Dgrr5zmkefXqGCQvHwJ+uxNgfiv7fcw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-24  4:26               ` Wolfram Sang
2015-01-24  7:16                 ` Pantelis Antoniou
     [not found]                   ` <DEFFB75F-347B-43F9-98E5-BBD019276A37-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-01-26 15:55                     ` Wolfram Sang
2015-01-26 19:27                       ` Rob Herring
     [not found]                         ` <CAL_JsqL9m-r3aJhiwSY61xXG9CbkHfD7RqrbNG=mBJnGD_-YPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-26 19:45                           ` Wolfram Sang
2015-01-29 22:45                             ` Wolfram Sang
  -- strict thread matches above, loose matches on Subject: below --
2015-01-24  7:16 Pantelis Antoniou
     [not found] ` <1422083789-18905-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-04-22  7:40   ` Wolfram Sang
2015-05-06 17:51     ` Kevin Hilman
     [not found]       ` <CAMAWPa-HMhJK9UzwfaMPe-MO=4mzjvC=nRwPX-pbab_fb3YZ9A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-06 18:37         ` Wolfram Sang
2015-05-06 18:39           ` Pantelis Antoniou
     [not found]             ` <A4E060DB-2799-4BF5-9CA6-DE53B7DF9A30-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-06-10  5:40               ` Wolfram Sang
2015-06-10 12:42                 ` Rob Herring
     [not found]                   ` <CAL_Jsq+xTZy3QsdaXieR8LSVEJfSeehtcytZLOyt7ghTZ=Bcxw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-10 12:49                     ` Wolfram Sang
2015-06-10 13:51                       ` Pantelis Antoniou
     [not found]                         ` <B9EA0BC3-56D8-4676-BEFC-734EC1FE6649-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-06-10 14:08                           ` Wolfram Sang
2015-06-10 14:10                             ` Pantelis Antoniou
     [not found]                               ` <041469A7-65F2-4C33-AD67-0B0CE4DEDD75-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-06-10 14:31                                 ` Rob Herring
2015-06-10 14:18                             ` Rob Herring
2015-07-09 20:29           ` Wolfram Sang
2015-01-15 16:33 Pantelis Antoniou
     [not found] ` <1421339635-16039-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-01-15 17:35   ` Wolfram Sang
2015-01-15 18:32     ` Pantelis Antoniou
2015-01-12 17:01 Pantelis Antoniou
     [not found] ` <1421082094-10267-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-01-13 12:05   ` Wolfram Sang
2015-01-13 12:08     ` Pantelis Antoniou
2015-01-13 15:12   ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.