All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Johan Hovold <johan@kernel.org>
Subject: Re: [PATCH] gpiolib: Disallow identical line names in the same chip
Date: Mon, 14 Dec 2020 10:29:14 +0100	[thread overview]
Message-ID: <X9cwahptmETQ5lkL@localhost> (raw)
In-Reply-To: <20201212003447.238474-1-linus.walleij@linaro.org>

On Sat, Dec 12, 2020 at 01:34:47AM +0100, Linus Walleij wrote:
> We need to make this namespace hierarchical: at least do not
> allow two lines on the same chip to have the same name, this
> is just too much flexibility. If we name a line on a chip,
> name it uniquely on that chip.
> 
> I don't know what happens if we just apply this, I *hope* there
> are not a lot of systems out there breaking this simple and
> intuitive rule.
> 
> As a side effect, this makes the device tree naming code
> scream a bit if names are not globally unique.
> 
> I think there are not super-many device trees out there naming
> their lines so let's fix this before the problem becomes
> widespread.
> 
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Johan Hovold <johan@kernel.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> This may be just the first step in tightening this up.
> Googling gives at hand that the colission warning doesn't
> happen much so we might go as far as to say the name can
> be required to be globally unique, but that creates a flat
> namespace so I don't know if that is desireable.
> ---
>  drivers/gpio/gpiolib.c | 34 ++++++++++++++++++++++++++--------
>  1 file changed, 26 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 5ce0c14c637b..be4b3e9032b2 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -330,11 +330,9 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name)
>  
>  /*
>   * Take the names from gc->names and assign them to their GPIO descriptors.
> - * Warn if a name is already used for a GPIO line on a different GPIO chip.
>   *
> - * Note that:
> - *   1. Non-unique names are still accepted,
> - *   2. Name collisions within the same GPIO chip are not reported.
> + * - Fail if a name is already used for a GPIO line on the same chip.
> + * - Allow names to not be globally unique but warn about it.

As I mentioned earlier, the not-globally unique warning only makes sense
for cases where all names comes from something like devicetree, and we
shouldn't warn if we plug in two identical USB devices that provide
default line names.

Not sure it's even warranted to warn even if those default names collide
with the names provided in devicetree. Perhaps best to just drop the
flat-namespace assumption entirely and make sure gpiolib and the
userspace library can handle that.

Johan

  parent reply	other threads:[~2020-12-14  9:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-12  0:34 [PATCH] gpiolib: Disallow identical line names in the same chip Linus Walleij
2020-12-12  9:23 ` Geert Uytterhoeven
2020-12-12 12:51   ` Linus Walleij
2020-12-14  9:23     ` Johan Hovold
2020-12-13 15:00 ` Andy Shevchenko
2020-12-14  8:45   ` Bartosz Golaszewski
2020-12-14  9:17 ` Linus Walleij
2020-12-14  9:29 ` Johan Hovold [this message]
2020-12-14 22:39   ` Linus Walleij
2020-12-15  8:24     ` 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=X9cwahptmETQ5lkL@localhost \
    --to=johan@kernel.org \
    --cc=bgolaszewski@baylibre.com \
    --cc=geert+renesas@glider.be \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.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 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.