diff mbox series

[1/3,v5] gpio: pcf857x: Name instance after dev_name()

Message ID 20210615145903.634565-1-linus.walleij@linaro.org
State Superseded
Headers show
Series [1/3,v5] gpio: pcf857x: Name instance after dev_name() | expand

Commit Message

Linus Walleij June 15, 2021, 2:59 p.m. UTC
Put the label on this gpio_chip from the dev_name() instead of
the client name.

The client name will be pcf8574 etc for all instances even if
there are several chips on a system.

This manifests on the DaVinci DM6467 (non-devicetree) which
will contain 3 different pcf8574 devices that as a result cannot
be told apart because they are all named "pcf8574", affecting
the GPIO descriptor tables which need a unique label per chip.

By passing in .dev_name in the struct i2c_board_info we can
explicitly name each instance and use that to discern the chips
when using board files.

Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
ChangeLog ->v5:
- New patch to deal with the chip label
---
 drivers/gpio/gpio-pcf857x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.31.1

Comments

Bartosz Golaszewski June 22, 2021, 12:58 p.m. UTC | #1
On Tue, Jun 15, 2021 at 5:01 PM Linus Walleij <linus.walleij@linaro.org> wrote:
>

> Put the label on this gpio_chip from the dev_name() instead of

> the client name.

>

> The client name will be pcf8574 etc for all instances even if

> there are several chips on a system.

>

> This manifests on the DaVinci DM6467 (non-devicetree) which

> will contain 3 different pcf8574 devices that as a result cannot

> be told apart because they are all named "pcf8574", affecting

> the GPIO descriptor tables which need a unique label per chip.

>

> By passing in .dev_name in the struct i2c_board_info we can

> explicitly name each instance and use that to discern the chips

> when using board files.

>

> Cc: Sekhar Nori <nsekhar@ti.com>

> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

> ---

> ChangeLog ->v5:

> - New patch to deal with the chip label

> ---

>  drivers/gpio/gpio-pcf857x.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

> diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c

> index b7568ee33696..2271ec86e414 100644

> --- a/drivers/gpio/gpio-pcf857x.c

> +++ b/drivers/gpio/gpio-pcf857x.c

> @@ -311,7 +311,7 @@ static int pcf857x_probe(struct i2c_client *client,

>         if (status < 0)

>                 goto fail;

>

> -       gpio->chip.label = client->name;

> +       gpio->chip.label = dev_name(&client->dev);

>

>         gpio->client = client;

>         i2c_set_clientdata(client, gpio);

> --

> 2.31.1

>


This makes sense but the i2c names are often not very descriptive. How
about adding a DEVID_AUTO/DEVID_NONE like mechanism to GPIO labels?
Nvmem has a thing like that precisely because labels can repeat.

Bart
Linus Walleij June 24, 2021, 11:52 p.m. UTC | #2
On Tue, Jun 22, 2021 at 2:58 PM Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> This makes sense but the i2c names are often not very descriptive. How

> about adding a DEVID_AUTO/DEVID_NONE like mechanism to GPIO labels?

> Nvmem has a thing like that precisely because labels can repeat.


Yeah :/ it feels like the subsystem should name the device properly
though. Like we're solving someone elses problem.

In this case the other patches provides .names in the I2C
board info so that the dev_name() ends up something
like "i2c-u2" and "i2c-u15". The u2 and u15 are common
names for components on a board so from an electronic point
of view that naming makes for good topology.

Yours,
Linus Walleij
Bartosz Golaszewski June 25, 2021, 10:25 a.m. UTC | #3
On Fri, Jun 25, 2021 at 1:52 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>

> On Tue, Jun 22, 2021 at 2:58 PM Bartosz Golaszewski

> <bgolaszewski@baylibre.com> wrote:

>

> > This makes sense but the i2c names are often not very descriptive. How

> > about adding a DEVID_AUTO/DEVID_NONE like mechanism to GPIO labels?

> > Nvmem has a thing like that precisely because labels can repeat.

>

> Yeah :/ it feels like the subsystem should name the device properly

> though. Like we're solving someone elses problem.

>

> In this case the other patches provides .names in the I2C

> board info so that the dev_name() ends up something

> like "i2c-u2" and "i2c-u15". The u2 and u15 are common

> names for components on a board so from an electronic point

> of view that naming makes for good topology.

>


Right. Alright, Sekhar can I take just this patch and you take the
ones for davinci?

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c
index b7568ee33696..2271ec86e414 100644
--- a/drivers/gpio/gpio-pcf857x.c
+++ b/drivers/gpio/gpio-pcf857x.c
@@ -311,7 +311,7 @@  static int pcf857x_probe(struct i2c_client *client,
 	if (status < 0)
 		goto fail;
 
-	gpio->chip.label = client->name;
+	gpio->chip.label = dev_name(&client->dev);
 
 	gpio->client = client;
 	i2c_set_clientdata(client, gpio);