devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
To: Pantelis Antoniou
	<pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
	Matt Porter <matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Greg Kroah-Hartman
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	Grant Likely
	<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
	Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Pantelis Antoniou
	<panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
Subject: Re: [PATCH] i2c: Mark instantiated device nodes with OF_POPULATE
Date: Thu, 15 Jan 2015 10:55:45 -0800	[thread overview]
Message-ID: <20150115185545.GA20251@roeck-us.net> (raw)
In-Reply-To: <1421346798-17148-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>

On Thu, Jan 15, 2015 at 08:33:18PM +0200, Pantelis Antoniou wrote:
> 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)

Hi Pantelis,

I thought I read a note somewhere a couple of days ago suggesting that
CONFIG_OF_DYNAMIC would go away soon. Also, of_node_clear_flag is defined
in #ifdef CONFIG_OF, and AFAICS none of the other callers set OF_POPULATED
in the context of CONFIG_OF_DYNAMIC. Given that, wouldn't it be better
to use CONFIG_OF ?

Thanks,
Guenter

> +	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
> 

  parent reply	other threads:[~2015-01-15 18:55 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
     [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150115185545.GA20251@roeck-us.net \
    --to=linux-0h96xk9xttrk1umjsbkqmq@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
    --cc=panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org \
    --cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).