Linux SPI subsystem development
 help / color / mirror / Atom feed
From: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Cc: Michael Fiore <mfjord02-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Pantelis Antoniou
	<pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>,
	Frank Rowand
	<frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-spi <linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: Dynamically adding SPI buses (was: Re: [PATCH v8 0/8] Device Tree Overlays - 8th time's the charm)
Date: Fri, 27 Nov 2015 13:24:41 +0000	[thread overview]
Message-ID: <20151127132441.GS1929@sirena.org.uk> (raw)
In-Reply-To: <CAMuHMdUPa6YMa98v+qXMnxeMZ41AKFY1ni12rJewSEnqSB7TRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1980 bytes --]

On Fri, Nov 27, 2015 at 02:06:41PM +0100, Geert Uytterhoeven wrote:

> (replaying to an old mail, as I'm seeing the exact same behavior with current
>  overlay code)

I don't seem to have this mail...  I'm not even sure that mailing list
archive does (at least

   http://thread.gmane.org/gmane.linux.kernel.spi.devel/18597

anyway).

> When adding an SPI master device node to DT, or changing its status to "okay",
> of_register_spi_devices() will scan for SPI slaves, and will add all of them.
> Later, the notifier kicks:

>     static int of_spi_notify(struct notifier_block *nb, unsigned long action,
>                              void *arg)
>     {
>             ...
> 
>             case OF_RECONFIG_CHANGE_ADD:
>                     master = of_find_spi_master_by_node(rd->dn->parent);
>                     if (master == NULL)
>                             return NOTIFY_OK;       /* not for us */
> 
>                     spi = of_register_spi_device(master, rd->dn);

> Woops, this fails, as the device has been added before!
> Should the code just check for the existence of the SPI slave first, or would
> that cause problems when just modifying an existing SPI slave node in DT?

Looking at the I2C code it seems like it's using
of_node_test_and_set_flag() to check for OF_POPULATED before
instantiating, doing that manually in every place where it might
instantiate a device and manually clearing when deinstantiating.

I have to say I don't entirely understand the logic behind how this
stuff is supposed to work, it's confusing to me why we have separate
dynamic and static instantiation paths in the first place or why this is
open coded in the buses.  It seems like a more robust thing here is to
always use the dynamic path even on static instantiation, or to move it
more into the driver core.

Ideally I'd like to see the I2C code factored out into the DT core but
otherwise probably we have to cut'n'paste it.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  parent reply	other threads:[~2015-11-27 13:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-27 13:06 Dynamically adding SPI buses (was: Re: [PATCH v8 0/8] Device Tree Overlays - 8th time's the charm) Geert Uytterhoeven
     [not found] ` <CAMuHMdUPa6YMa98v+qXMnxeMZ41AKFY1ni12rJewSEnqSB7TRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-11-27 13:24   ` Mark Brown [this message]
     [not found]     ` <20151127132441.GS1929-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-11-29  9:47       ` Geert Uytterhoeven

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=20151127132441.GS1929@sirena.org.uk \
    --to=broonie-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mfjord02-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@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