diff mbox series

drivers: iio: dac: ad5592r: add gpio_chip names

Message ID 20221117090130.51702-1-antoniu.miclaus@analog.com (mailing list archive)
State Accepted
Headers show
Series drivers: iio: dac: ad5592r: add gpio_chip names | expand

Commit Message

Miclaus, Antoniu Nov. 17, 2022, 9:01 a.m. UTC
Add array of explicit gpio names for the `gpiochip` structure of
ad5592r, mainly for debug purposes.

Since the gpios are configurable via the dts, generic names are
used.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
 drivers/iio/dac/ad5592r-base.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Jonathan Cameron Nov. 23, 2022, 8:48 p.m. UTC | #1
On Thu, 17 Nov 2022 11:01:30 +0200
Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:

> Add array of explicit gpio names for the `gpiochip` structure of
> ad5592r, mainly for debug purposes.
Can you give an example of when this is more useful than the offset?
(which I'm assuming is also available when debugging?)

Jonathan

> 
> Since the gpios are configurable via the dts, generic names are
> used.
> 
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> ---
>  drivers/iio/dac/ad5592r-base.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
> index 7a9b5fc1e579..076bc9ecfb49 100644
> --- a/drivers/iio/dac/ad5592r-base.c
> +++ b/drivers/iio/dac/ad5592r-base.c
> @@ -124,6 +124,10 @@ static int ad5592r_gpio_request(struct gpio_chip *chip, unsigned offset)
>  	return 0;
>  }
>  
> +static const char * const ad5592r_gpio_names[] = {
> +	"GPIO0", "GPIO1", "GPIO2", "GPIO3", "GPIO4", "GPIO5", "GPIO6", "GPIO7",
> +};
> +
>  static int ad5592r_gpio_init(struct ad5592r_state *st)
>  {
>  	if (!st->gpio_map)
> @@ -140,6 +144,7 @@ static int ad5592r_gpio_init(struct ad5592r_state *st)
>  	st->gpiochip.set = ad5592r_gpio_set;
>  	st->gpiochip.request = ad5592r_gpio_request;
>  	st->gpiochip.owner = THIS_MODULE;
> +	st->gpiochip.names = ad5592r_gpio_names;
>  
>  	mutex_init(&st->gpio_lock);
>
Jonathan Cameron Jan. 28, 2023, 6:03 p.m. UTC | #2
On Wed, 23 Nov 2022 20:48:32 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Thu, 17 Nov 2022 11:01:30 +0200
> Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:
> 
> > Add array of explicit gpio names for the `gpiochip` structure of
> > ad5592r, mainly for debug purposes.  
> Can you give an example of when this is more useful than the offset?
> (which I'm assuming is also available when debugging?)
> 
> Jonathan

This one is still outstanding in patchwork.

Antoniu, if you want this to be applied please address the question above.

Thanks,

Jonathan

> 
> > 
> > Since the gpios are configurable via the dts, generic names are
> > used.
> > 
> > Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> > ---
> >  drivers/iio/dac/ad5592r-base.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
> > index 7a9b5fc1e579..076bc9ecfb49 100644
> > --- a/drivers/iio/dac/ad5592r-base.c
> > +++ b/drivers/iio/dac/ad5592r-base.c
> > @@ -124,6 +124,10 @@ static int ad5592r_gpio_request(struct gpio_chip *chip, unsigned offset)
> >  	return 0;
> >  }
> >  
> > +static const char * const ad5592r_gpio_names[] = {
> > +	"GPIO0", "GPIO1", "GPIO2", "GPIO3", "GPIO4", "GPIO5", "GPIO6", "GPIO7",
> > +};
> > +
> >  static int ad5592r_gpio_init(struct ad5592r_state *st)
> >  {
> >  	if (!st->gpio_map)
> > @@ -140,6 +144,7 @@ static int ad5592r_gpio_init(struct ad5592r_state *st)
> >  	st->gpiochip.set = ad5592r_gpio_set;
> >  	st->gpiochip.request = ad5592r_gpio_request;
> >  	st->gpiochip.owner = THIS_MODULE;
> > +	st->gpiochip.names = ad5592r_gpio_names;
> >  
> >  	mutex_init(&st->gpio_lock);
> >    
>
Miclaus, Antoniu Feb. 1, 2023, 1:11 p.m. UTC | #3
--
Antoniu Miclăuş

> -----Original Message-----
> From: Jonathan Cameron <jic23@kernel.org>
> Sent: Wednesday, November 23, 2022 10:49 PM
> To: Miclaus, Antoniu <Antoniu.Miclaus@analog.com>
> Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] drivers: iio: dac: ad5592r: add gpio_chip names
> 
> [External]
> 
> On Thu, 17 Nov 2022 11:01:30 +0200
> Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:
> 
> > Add array of explicit gpio names for the `gpiochip` structure of
> > ad5592r, mainly for debug purposes.
> Can you give an example of when this is more useful than the offset?
> (which I'm assuming is also available when debugging?)
> 
> Jonathan
> 
Hello Jonathan,

I guess this patch is not mandatory. It is a gpio_chip structure member that was left unpopulated.
Also, I think it is nice to see explicitly the gpios under cat /sys/kernel/debug/gpio alongside the others.
This is the current output when trying to debug on a rpi (without the patch applied):

analog@analog:~ $ sudo cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-57, parent: platform/fe200000.gpio, pinctrl-bcm2711:
 gpio-0   (ID_SDA              )
 gpio-1   (ID_SCL              )
 gpio-2   (SDA1                )
 gpio-3   (SCL1                )
 gpio-4   (GPIO_GCLK           )
 gpio-5   (GPIO5               )
 gpio-6   (GPIO6               )
....
gpiochip2: GPIOs 496-503, parent: spi/spi0.0, spi0.0, can sleep:

gpiochip1: GPIOs 504-511, parent: platform/soc:firmware:gpio, raspberrypi-exp-gpio, can sleep:
 gpio-504 (BT_ON               )
 gpio-505 (WL_ON               )
 gpio-506 (PWR_LED_OFF         |led1                ) out lo ACTIVE LOW
 gpio-507 (GLOBAL_RESET        )
 gpio-508 (VDD_SD_IO_SEL       |vdd-sd-io           ) out hi
 gpio-509 (CAM_GPIO            |power_ctrl          ) out lo
 gpio-510 (SD_PWR_ON           |sd_vcc_reg          ) out hi
 gpio-511 (SD_OC_N             )

The gpiochip2, corresponding to ad5592r has no explicit gpios, due to the fact that the
gpio names were assigned.

Regards,
> >
> > Since the gpios are configurable via the dts, generic names are
> > used.
> >
> > Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> > ---
> >  drivers/iio/dac/ad5592r-base.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
> > index 7a9b5fc1e579..076bc9ecfb49 100644
> > --- a/drivers/iio/dac/ad5592r-base.c
> > +++ b/drivers/iio/dac/ad5592r-base.c
> > @@ -124,6 +124,10 @@ static int ad5592r_gpio_request(struct gpio_chip
> *chip, unsigned offset)
> >  	return 0;
> >  }
> >
> > +static const char * const ad5592r_gpio_names[] = {
> > +	"GPIO0", "GPIO1", "GPIO2", "GPIO3", "GPIO4", "GPIO5", "GPIO6",
> "GPIO7",
> > +};
> > +
> >  static int ad5592r_gpio_init(struct ad5592r_state *st)
> >  {
> >  	if (!st->gpio_map)
> > @@ -140,6 +144,7 @@ static int ad5592r_gpio_init(struct ad5592r_state
> *st)
> >  	st->gpiochip.set = ad5592r_gpio_set;
> >  	st->gpiochip.request = ad5592r_gpio_request;
> >  	st->gpiochip.owner = THIS_MODULE;
> > +	st->gpiochip.names = ad5592r_gpio_names;
> >
> >  	mutex_init(&st->gpio_lock);
> >
Jonathan Cameron Feb. 5, 2023, 3:02 p.m. UTC | #4
On Wed, 1 Feb 2023 13:11:30 +0000
"Miclaus, Antoniu" <Antoniu.Miclaus@analog.com> wrote:

> --
> Antoniu Miclăuş
> 
> > -----Original Message-----
> > From: Jonathan Cameron <jic23@kernel.org>
> > Sent: Wednesday, November 23, 2022 10:49 PM
> > To: Miclaus, Antoniu <Antoniu.Miclaus@analog.com>
> > Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org
> > Subject: Re: [PATCH] drivers: iio: dac: ad5592r: add gpio_chip names
> > 
> > [External]
> > 
> > On Thu, 17 Nov 2022 11:01:30 +0200
> > Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:
> >   
> > > Add array of explicit gpio names for the `gpiochip` structure of
> > > ad5592r, mainly for debug purposes.  
> > Can you give an example of when this is more useful than the offset?
> > (which I'm assuming is also available when debugging?)
> > 
> > Jonathan
> >   
> Hello Jonathan,
> 
> I guess this patch is not mandatory. It is a gpio_chip structure member that was left unpopulated.
> Also, I think it is nice to see explicitly the gpios under cat /sys/kernel/debug/gpio alongside the others.
> This is the current output when trying to debug on a rpi (without the patch applied):
> 
> analog@analog:~ $ sudo cat /sys/kernel/debug/gpio
> gpiochip0: GPIOs 0-57, parent: platform/fe200000.gpio, pinctrl-bcm2711:
>  gpio-0   (ID_SDA              )
>  gpio-1   (ID_SCL              )
>  gpio-2   (SDA1                )
>  gpio-3   (SCL1                )
>  gpio-4   (GPIO_GCLK           )
>  gpio-5   (GPIO5               )
>  gpio-6   (GPIO6               )
> ....
> gpiochip2: GPIOs 496-503, parent: spi/spi0.0, spi0.0, can sleep:
> 
> gpiochip1: GPIOs 504-511, parent: platform/soc:firmware:gpio, raspberrypi-exp-gpio, can sleep:
>  gpio-504 (BT_ON               )
>  gpio-505 (WL_ON               )
>  gpio-506 (PWR_LED_OFF         |led1                ) out lo ACTIVE LOW
>  gpio-507 (GLOBAL_RESET        )
>  gpio-508 (VDD_SD_IO_SEL       |vdd-sd-io           ) out hi
>  gpio-509 (CAM_GPIO            |power_ctrl          ) out lo
>  gpio-510 (SD_PWR_ON           |sd_vcc_reg          ) out hi
>  gpio-511 (SD_OC_N             )
> 
> The gpiochip2, corresponding to ad5592r has no explicit gpios, due to the fact that the
> gpio names were assigned.

Thanks for the info.

Applied to the togreg branch of iio.git and pushed out as testing for 0-day
to poke at it an see if we missed anything.

We are a bit tight timing wise, so this might end up in next cycle.

Jonathan

> 
> Regards,
> > >
> > > Since the gpios are configurable via the dts, generic names are
> > > used.
> > >
> > > Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> > > ---
> > >  drivers/iio/dac/ad5592r-base.c | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > >
> > > diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
> > > index 7a9b5fc1e579..076bc9ecfb49 100644
> > > --- a/drivers/iio/dac/ad5592r-base.c
> > > +++ b/drivers/iio/dac/ad5592r-base.c
> > > @@ -124,6 +124,10 @@ static int ad5592r_gpio_request(struct gpio_chip  
> > *chip, unsigned offset)  
> > >  	return 0;
> > >  }
> > >
> > > +static const char * const ad5592r_gpio_names[] = {
> > > +	"GPIO0", "GPIO1", "GPIO2", "GPIO3", "GPIO4", "GPIO5", "GPIO6",  
> > "GPIO7",  
> > > +};
> > > +
> > >  static int ad5592r_gpio_init(struct ad5592r_state *st)
> > >  {
> > >  	if (!st->gpio_map)
> > > @@ -140,6 +144,7 @@ static int ad5592r_gpio_init(struct ad5592r_state  
> > *st)  
> > >  	st->gpiochip.set = ad5592r_gpio_set;
> > >  	st->gpiochip.request = ad5592r_gpio_request;
> > >  	st->gpiochip.owner = THIS_MODULE;
> > > +	st->gpiochip.names = ad5592r_gpio_names;
> > >
> > >  	mutex_init(&st->gpio_lock);
> > >  
>
diff mbox series

Patch

diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
index 7a9b5fc1e579..076bc9ecfb49 100644
--- a/drivers/iio/dac/ad5592r-base.c
+++ b/drivers/iio/dac/ad5592r-base.c
@@ -124,6 +124,10 @@  static int ad5592r_gpio_request(struct gpio_chip *chip, unsigned offset)
 	return 0;
 }
 
+static const char * const ad5592r_gpio_names[] = {
+	"GPIO0", "GPIO1", "GPIO2", "GPIO3", "GPIO4", "GPIO5", "GPIO6", "GPIO7",
+};
+
 static int ad5592r_gpio_init(struct ad5592r_state *st)
 {
 	if (!st->gpio_map)
@@ -140,6 +144,7 @@  static int ad5592r_gpio_init(struct ad5592r_state *st)
 	st->gpiochip.set = ad5592r_gpio_set;
 	st->gpiochip.request = ad5592r_gpio_request;
 	st->gpiochip.owner = THIS_MODULE;
+	st->gpiochip.names = ad5592r_gpio_names;
 
 	mutex_init(&st->gpio_lock);