Re: [PATCH] gpio: Ignore gpio names with empty strings

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

 



On Wed, Oct 10, 2018 at 5:03 PM Brandon Maier
<brandon.maier@xxxxxxxxxxxxxxxxxxx> wrote:
> On Wed, Oct 10, 2018 at 4:12 AM, Linus Walleij <linus.walleij@xxxxxxxxxx> wrote:
>
> > Isn't the real problem that they should be passing NULL
> > rather than "" empty string for line names?
>
> In our case, we are using the gpio_chip->names in place of
> gpio-line-names. Because Xilinx's drivers/gpio/gpio-xilinx allocates
> multiple gpio_chips under a single devicetree node, gpio-line-names
> won't work. This is the same problem mentioned in Hedges Alexander's
> port of gpio-xilinx[1]. I worked around this by adding a
> gpio-line-names-2 that the second chip grabs and passes in through
> gpio_chip->names.
>
> This patch seemed appropriate because the intent of an "empty string"
> in gpio-line-names is to be an unset gpio name. It would also prevent
> name collisions from happening if we added name collision detection to
> gpio-line-names. But if it's better to leave this as-is, I could
> modify our code to replace "" -> NULL in gpio-xilinx.

I think it is better to modify callers to pass NULL rather than ""
to fix this.

The reason is that it is very clear for a reader of the code that
you do not want to name a line if it is just NULL. It has a certain
elegance to it. (IMO)

Yours,
Linus Walleij



[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