linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] platform: cznic: turris-omnia-mcu: Use new GPIO line value setter callbacks
@ 2025-06-18 12:43 Marek Behún
  2025-06-18 13:20 ` Bartosz Golaszewski
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Behún @ 2025-06-18 12:43 UTC (permalink / raw)
  To: linux-gpio
  Cc: Marek Behún, Linus Walleij, Bartosz Golaszewski,
	linux-kernel, linux-arm-kernel, Andy Shevchenko

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Marek Behún <kabel@kernel.org>
---
 .../platform/cznic/turris-omnia-mcu-gpio.c    | 35 ++++++++++++-------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/platform/cznic/turris-omnia-mcu-gpio.c b/drivers/platform/cznic/turris-omnia-mcu-gpio.c
index c2df24ea8686..57c229d70ead 100644
--- a/drivers/platform/cznic/turris-omnia-mcu-gpio.c
+++ b/drivers/platform/cznic/turris-omnia-mcu-gpio.c
@@ -439,27 +439,28 @@ static int omnia_gpio_get_multiple(struct gpio_chip *gc, unsigned long *mask,
 	return 0;
 }
 
-static void omnia_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
+static int omnia_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
 {
 	const struct omnia_gpio *gpio = &omnia_gpios[offset];
 	struct omnia_mcu *mcu = gpiochip_get_data(gc);
 	u16 val, mask;
 
 	if (!gpio->ctl_cmd)
-		return;
+		return -ENOTSUPP;
 
 	mask = BIT(gpio->ctl_bit);
 	val = value ? mask : 0;
 
-	omnia_ctl_cmd(mcu, gpio->ctl_cmd, val, mask);
+	return omnia_ctl_cmd(mcu, gpio->ctl_cmd, val, mask);
 }
 
-static void omnia_gpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
-				    unsigned long *bits)
+static int omnia_gpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
+				   unsigned long *bits)
 {
 	unsigned long ctl = 0, ctl_mask = 0, ext_ctl = 0, ext_ctl_mask = 0;
 	struct omnia_mcu *mcu = gpiochip_get_data(gc);
 	unsigned int i;
+	int err;
 
 	for_each_set_bit(i, mask, ARRAY_SIZE(omnia_gpios)) {
 		unsigned long *field, *field_mask;
@@ -488,13 +489,21 @@ static void omnia_gpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
 
 	guard(mutex)(&mcu->lock);
 
-	if (ctl_mask)
-		omnia_ctl_cmd_locked(mcu, OMNIA_CMD_GENERAL_CONTROL,
-				     ctl, ctl_mask);
+	if (ctl_mask) {
+		err = omnia_ctl_cmd_locked(mcu, OMNIA_CMD_GENERAL_CONTROL,
+					   ctl, ctl_mask);
+		if (err)
+			return err;
+	}
+
+	if (ext_ctl_mask) {
+		err = omnia_ctl_cmd_locked(mcu, OMNIA_CMD_EXT_CONTROL,
+					   ext_ctl, ext_ctl_mask);
+		if (err)
+			return err;
+	}
 
-	if (ext_ctl_mask)
-		omnia_ctl_cmd_locked(mcu, OMNIA_CMD_EXT_CONTROL,
-				     ext_ctl, ext_ctl_mask);
+	return 0;
 }
 
 static bool omnia_gpio_available(struct omnia_mcu *mcu,
@@ -1015,8 +1024,8 @@ int omnia_mcu_register_gpiochip(struct omnia_mcu *mcu)
 	mcu->gc.direction_output = omnia_gpio_direction_output;
 	mcu->gc.get = omnia_gpio_get;
 	mcu->gc.get_multiple = omnia_gpio_get_multiple;
-	mcu->gc.set = omnia_gpio_set;
-	mcu->gc.set_multiple = omnia_gpio_set_multiple;
+	mcu->gc.set_rv = omnia_gpio_set;
+	mcu->gc.set_multiple_rv = omnia_gpio_set_multiple;
 	mcu->gc.init_valid_mask = omnia_gpio_init_valid_mask;
 	mcu->gc.can_sleep = true;
 	mcu->gc.names = omnia_mcu_gpio_names;
-- 
2.49.0



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

* Re: [PATCH] platform: cznic: turris-omnia-mcu: Use new GPIO line value setter callbacks
  2025-06-18 12:43 [PATCH] platform: cznic: turris-omnia-mcu: Use new GPIO line value setter callbacks Marek Behún
@ 2025-06-18 13:20 ` Bartosz Golaszewski
  2025-06-18 18:47   ` Marek Behún
  0 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2025-06-18 13:20 UTC (permalink / raw)
  To: Marek Behún
  Cc: linux-gpio, Linus Walleij, linux-kernel, linux-arm-kernel,
	Andy Shevchenko

On Wed, Jun 18, 2025 at 2:43 PM Marek Behún <kabel@kernel.org> wrote:
>
> struct gpio_chip now has callbacks for setting line values that return
> an integer, allowing to indicate failures. Convert the driver to using
> them.
>
> Signed-off-by: Marek Behún <kabel@kernel.org>
> ---

What's going on with this patch? I sent it a few days ago, now you
just resent it without changes. Who should pick it up?

Bart


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

* Re: [PATCH] platform: cznic: turris-omnia-mcu: Use new GPIO line value setter callbacks
  2025-06-18 13:20 ` Bartosz Golaszewski
@ 2025-06-18 18:47   ` Marek Behún
  2025-06-18 18:54     ` Marek Behún
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Behún @ 2025-06-18 18:47 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Marek Behún, linux-gpio, Linus Walleij, linux-kernel,
	linux-arm-kernel, Andy Shevchenko

On Wed, Jun 18, 2025 at 03:20:15PM +0200, Bartosz Golaszewski wrote:
> On Wed, Jun 18, 2025 at 2:43 PM Marek Behún <kabel@kernel.org> wrote:
> >
> > struct gpio_chip now has callbacks for setting line values that return
> > an integer, allowing to indicate failures. Convert the driver to using
> > them.
> >
> > Signed-off-by: Marek Behún <kabel@kernel.org>
> > ---
> 
> What's going on with this patch? I sent it a few days ago, now you
> just resent it without changes. Who should pick it up?

I didn't see any patch for this driver, only for gpio-moxtet (for which
I sent R-b). Did I overlook it?

Marek


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

* Re: [PATCH] platform: cznic: turris-omnia-mcu: Use new GPIO line value setter callbacks
  2025-06-18 18:47   ` Marek Behún
@ 2025-06-18 18:54     ` Marek Behún
  2025-06-18 20:30       ` Bartosz Golaszewski
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Behún @ 2025-06-18 18:54 UTC (permalink / raw)
  To: Marek Behún
  Cc: Bartosz Golaszewski, linux-gpio, Linus Walleij, linux-kernel,
	linux-arm-kernel, Andy Shevchenko

On Wed, Jun 18, 2025 at 08:47:33PM +0200, Marek Behún wrote:
> On Wed, Jun 18, 2025 at 03:20:15PM +0200, Bartosz Golaszewski wrote:
> > On Wed, Jun 18, 2025 at 2:43 PM Marek Behún <kabel@kernel.org> wrote:
> > >
> > > struct gpio_chip now has callbacks for setting line values that return
> > > an integer, allowing to indicate failures. Convert the driver to using
> > > them.
> > >
> > > Signed-off-by: Marek Behún <kabel@kernel.org>
> > > ---
> > 
> > What's going on with this patch? I sent it a few days ago, now you
> > just resent it without changes. Who should pick it up?
> 
> I didn't see any patch for this driver, only for gpio-moxtet (for which
> I sent R-b). Did I overlook it?

OMG I see it now. Sorry.

There is one difference, though. Your change makes omnia_gpio_set() return
-EINVAL on a GPIO that does not support output direction. I put -ENOTSUPP
there, since -ENOTSUPP is also returned by direction_input() and
direction_output() methods in this case.

I don't know if -EINVAL or -ENOTSUPP is more consistent, though. Feel free
to apply your version (you can also add my R-b tag).

Marek


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

* Re: [PATCH] platform: cznic: turris-omnia-mcu: Use new GPIO line value setter callbacks
  2025-06-18 18:54     ` Marek Behún
@ 2025-06-18 20:30       ` Bartosz Golaszewski
  0 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2025-06-18 20:30 UTC (permalink / raw)
  To: Marek Behún
  Cc: linux-gpio, Linus Walleij, linux-kernel, linux-arm-kernel,
	Andy Shevchenko

On Wed, Jun 18, 2025 at 8:54 PM Marek Behún <kabel@kernel.org> wrote:
>
> On Wed, Jun 18, 2025 at 08:47:33PM +0200, Marek Behún wrote:
> > On Wed, Jun 18, 2025 at 03:20:15PM +0200, Bartosz Golaszewski wrote:
> > > On Wed, Jun 18, 2025 at 2:43 PM Marek Behún <kabel@kernel.org> wrote:
> > > >
> > > > struct gpio_chip now has callbacks for setting line values that return
> > > > an integer, allowing to indicate failures. Convert the driver to using
> > > > them.
> > > >
> > > > Signed-off-by: Marek Behún <kabel@kernel.org>
> > > > ---
> > >
> > > What's going on with this patch? I sent it a few days ago, now you
> > > just resent it without changes. Who should pick it up?
> >
> > I didn't see any patch for this driver, only for gpio-moxtet (for which
> > I sent R-b). Did I overlook it?
>
> OMG I see it now. Sorry.
>
> There is one difference, though. Your change makes omnia_gpio_set() return
> -EINVAL on a GPIO that does not support output direction. I put -ENOTSUPP
> there, since -ENOTSUPP is also returned by direction_input() and
> direction_output() methods in this case.
>
> I don't know if -EINVAL or -ENOTSUPP is more consistent, though. Feel free
> to apply your version (you can also add my R-b tag).
>
> Marek

I don't care that much, I can take this one but please leave an
official Acked-by in that case.

Bart


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

end of thread, other threads:[~2025-06-18 20:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-18 12:43 [PATCH] platform: cznic: turris-omnia-mcu: Use new GPIO line value setter callbacks Marek Behún
2025-06-18 13:20 ` Bartosz Golaszewski
2025-06-18 18:47   ` Marek Behún
2025-06-18 18:54     ` Marek Behún
2025-06-18 20:30       ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).