Re: [PATCH] gpiolib: Disallow identical line names in the same chip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> Cc: Johan Hovold <johan@xxxxxxxxxx>
> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
> ---
> 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



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux