mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gpio: max730x: implement get_direction()
@ 2026-07-29  9:56 Christophe Leroy (CS GROUP)
  2026-07-29  9:56 ` [PATCH] powerpc: implement get_direction() in cpm2 Christophe Leroy (CS GROUP)
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-07-29  9:56 UTC (permalink / raw)
  To: RAGUENES Jean Noel, Michael Ellerman, Nicholas Piggin,
	Madhavan Srinivasan
  Cc: Christophe Leroy (CS GROUP), linux-kernel, linuxppc-dev

The lack of get_direction() callback in this driver causes GPIOLIB to
emit a warning. Implement it.

Fixes: e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")
Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
---
 drivers/gpio/gpio-max730x.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/gpio/gpio-max730x.c b/drivers/gpio/gpio-max730x.c
index 84c7c2dca822..117a9dbff9c0 100644
--- a/drivers/gpio/gpio-max730x.c
+++ b/drivers/gpio/gpio-max730x.c
@@ -160,6 +160,31 @@ static int max7301_set(struct gpio_chip *chip, unsigned int offset, int value)
 	return ret;
 }
 
+static int max7301_get_direction(struct gpio_chip *chip, unsigned offset)
+{
+	struct max7301 *ts = container_of(chip, struct max7301, chip);
+	u8 *config;
+	u8 offset_bits;
+	int ret;
+
+	/* First 4 pins are unused in the controller */
+	offset += 4;
+	offset_bits = (offset & 3) << 1;
+
+	config = &ts->port_config[offset >> 2];
+
+	mutex_lock(&ts->lock);
+
+	if (*config & (PIN_CONFIG_OUT << offset_bits))
+		ret = GPIO_LINE_DIRECTION_OUT;
+	else
+		ret = GPIO_LINE_DIRECTION_IN;
+
+	mutex_unlock(&ts->lock);
+
+	return ret;
+}
+
 int __max730x_probe(struct max7301 *ts)
 {
 	struct device *dev = ts->dev;
@@ -189,6 +214,7 @@ int __max730x_probe(struct max7301 *ts)
 	ts->chip.get = max7301_get;
 	ts->chip.direction_output = max7301_direction_output;
 	ts->chip.set = max7301_set;
+	ts->chip.get_direction = max7301_get_direction;
 
 	ts->chip.ngpio = PIN_NUMBER;
 	ts->chip.can_sleep = true;
-- 
2.54.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] powerpc: implement get_direction() in cpm2
  2026-07-29  9:56 [PATCH] gpio: max730x: implement get_direction() Christophe Leroy (CS GROUP)
@ 2026-07-29  9:56 ` Christophe Leroy (CS GROUP)
  2026-07-29 12:05   ` Bartosz Golaszewski
  2026-08-03  6:57   ` Madhavan Srinivasan
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-07-29  9:56 UTC (permalink / raw)
  To: RAGUENES Jean Noel, Linus Walleij, Bartosz Golaszewski
  Cc: Christophe Leroy (CS GROUP), linux-kernel, linuxppc-dev, linux-gpio

The lack of get_direction() callback in this driver causes GPIOLIB to
emit a warning. Implement it.

Fixes: e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")
Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
---
 arch/powerpc/sysdev/cpm_common.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c
index 07ea605ab0e6..b5d200e3ad68 100644
--- a/arch/powerpc/sysdev/cpm_common.c
+++ b/arch/powerpc/sysdev/cpm_common.c
@@ -181,6 +181,18 @@ static int cpm2_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio)
 	return 0;
 }
 
+static int cpm2_gpio32_get_direction(struct gpio_chip *gc, unsigned int gpio)
+{
+	struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(gc);
+	struct cpm2_ioports __iomem *iop = cpm2_gc->regs;
+	u32 pin_mask = 1 << (31 - gpio);
+
+	if (in_be32(&iop->dir) & pin_mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
+}
+
 int cpm2_gpiochip_add32(struct device *dev)
 {
 	struct device_node *np = dev->of_node;
@@ -199,6 +211,7 @@ int cpm2_gpiochip_add32(struct device *dev)
 	gc->ngpio = 32;
 	gc->direction_input = cpm2_gpio32_dir_in;
 	gc->direction_output = cpm2_gpio32_dir_out;
+	gc->get_direction = cpm2_gpio32_get_direction;
 	gc->get = cpm2_gpio32_get;
 	gc->set = cpm2_gpio32_set;
 	gc->parent = dev;
-- 
2.54.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc: implement get_direction() in cpm2
  2026-07-29  9:56 ` [PATCH] powerpc: implement get_direction() in cpm2 Christophe Leroy (CS GROUP)
@ 2026-07-29 12:05   ` Bartosz Golaszewski
  2026-08-03  6:57   ` Madhavan Srinivasan
  1 sibling, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-07-29 12:05 UTC (permalink / raw)
  To: Christophe Leroy (CS GROUP)
  Cc: linux-kernel, linuxppc-dev, linux-gpio, RAGUENES Jean Noel,
	Linus Walleij, Bartosz Golaszewski

On Wed, 29 Jul 2026 11:56:48 +0200, "Christophe Leroy (CS GROUP)"
<chleroy@kernel.org> said:
> The lack of get_direction() callback in this driver causes GPIOLIB to
> emit a warning. Implement it.
>
> Fixes: e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")
> Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
> ---
>  arch/powerpc/sysdev/cpm_common.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c
> index 07ea605ab0e6..b5d200e3ad68 100644
> --- a/arch/powerpc/sysdev/cpm_common.c
> +++ b/arch/powerpc/sysdev/cpm_common.c
> @@ -181,6 +181,18 @@ static int cpm2_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio)
>  	return 0;
>  }
>
> +static int cpm2_gpio32_get_direction(struct gpio_chip *gc, unsigned int gpio)
> +{
> +	struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(gc);
> +	struct cpm2_ioports __iomem *iop = cpm2_gc->regs;
> +	u32 pin_mask = 1 << (31 - gpio);
> +
> +	if (in_be32(&iop->dir) & pin_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
> +}
> +
>  int cpm2_gpiochip_add32(struct device *dev)
>  {
>  	struct device_node *np = dev->of_node;
> @@ -199,6 +211,7 @@ int cpm2_gpiochip_add32(struct device *dev)
>  	gc->ngpio = 32;
>  	gc->direction_input = cpm2_gpio32_dir_in;
>  	gc->direction_output = cpm2_gpio32_dir_out;
> +	gc->get_direction = cpm2_gpio32_get_direction;
>  	gc->get = cpm2_gpio32_get;
>  	gc->set = cpm2_gpio32_set;
>  	gc->parent = dev;
> --
> 2.54.0
>
>

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc: implement get_direction() in cpm2
  2026-07-29  9:56 ` [PATCH] powerpc: implement get_direction() in cpm2 Christophe Leroy (CS GROUP)
  2026-07-29 12:05   ` Bartosz Golaszewski
@ 2026-08-03  6:57   ` Madhavan Srinivasan
  1 sibling, 0 replies; 4+ messages in thread
From: Madhavan Srinivasan @ 2026-08-03  6:57 UTC (permalink / raw)
  To: RAGUENES Jean Noel, Linus Walleij, Bartosz Golaszewski,
	Christophe Leroy (CS GROUP)
  Cc: linux-kernel, linuxppc-dev, linux-gpio

On Wed, 29 Jul 2026 11:56:48 +0200, Christophe Leroy (CS GROUP) wrote:
> The lack of get_direction() callback in this driver causes GPIOLIB to
> emit a warning. Implement it.
> 
> 

Applied to powerpc/next.

[1/1] powerpc: implement get_direction() in cpm2
      https://git.kernel.org/powerpc/c/ca16219e9babc874349a6ac307d56523871a9137

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-03  6:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-29  9:56 [PATCH] gpio: max730x: implement get_direction() Christophe Leroy (CS GROUP)
2026-07-29  9:56 ` [PATCH] powerpc: implement get_direction() in cpm2 Christophe Leroy (CS GROUP)
2026-07-29 12:05   ` Bartosz Golaszewski
2026-08-03  6:57   ` Madhavan Srinivasan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®