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

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®