diff mbox series

[3/5] gpio: ppc44x: fold __ppc44x_gpio_set() into ppc44x_gpio_dir_out()

Message ID 20261104215959.24035-4-rosenp@gmail.com
State New
Headers show
Series gpio: ppc44x: assorted cleanups | expand

Commit Message

Rosen Penev Nov. 4, 2026, 9:59 p.m. UTC
__ppc44x_gpio_set() has a single caller, and it looks up the driver
data that the caller already has. Open-code it in the direction_output
callback, with a comment explaining why gpio_generic_chip_set() can't
be used there: the generic setter takes the chip lock, which is already
held at that point.

While at it, drop the pr_debug(); gpiolib's tracepoints already report
direction and value changes.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/gpio/gpio-ppc44x.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

Comments

Bartosz Golaszewski Nov. 9, 2026, 9:02 a.m. UTC | #1
On Wed, Nov 04, 2026 at 01:59:57PM -0800, Rosen Penev wrote:
> __ppc44x_gpio_set() has a single caller, and it looks up the driver
> data that the caller already has. Open-code it in the direction_output
> callback, with a comment explaining why gpio_generic_chip_set() can't
> be used there: the generic setter takes the chip lock, which is already
> held at that point.
> 
> While at it, drop the pr_debug(); gpiolib's tracepoints already report
> direction and value changes.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
 
Sigh... This is really just churn...

I'll take it with the rest of the series as sashiko doesn't seem to
complain but this time would be better spent elsewhere. If you like
fixing bugs, I can assign you a number of GPIO bugs sashiko found.

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-ppc44x.c b/drivers/gpio/gpio-ppc44x.c
index b3cbc832cf24..20b3e9ce48e8 100644
--- a/drivers/gpio/gpio-ppc44x.c
+++ b/drivers/gpio/gpio-ppc44x.c
@@ -85,20 +85,6 @@  static void ppc44x_gpio_select_gpio(struct ppc44x_gpio __iomem *regs,
  * There are a maximum of 32 gpios in each gpio controller.
  */
 
-static inline void
-__ppc44x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
-{
-	struct ppc44x_gpio_chip *chip = gpiochip_get_data(gc);
-	struct gpio_generic_chip *gen_gc = &chip->chip;
-
-	if (val)
-		gen_gc->sdata |= GPIO_MASK(gpio);
-	else
-		gen_gc->sdata &= ~GPIO_MASK(gpio);
-
-	gpio_generic_write_reg(gen_gc, gen_gc->reg_set, gen_gc->sdata);
-}
-
 static int ppc44x_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 {
 	struct ppc44x_gpio_chip *chip = gpiochip_get_data(gc);
@@ -128,8 +114,16 @@  ppc44x_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 
 	guard(gpio_generic_lock_irqsave)(gen_gc);
 
-	/* First set initial value */
-	__ppc44x_gpio_set(gc, gpio, val);
+	/*
+	 * First set the initial value. This can't use gpio_generic_chip_set()
+	 * as the generic setter takes the chip lock, which is already held.
+	 */
+	if (val)
+		gen_gc->sdata |= GPIO_MASK(gpio);
+	else
+		gen_gc->sdata &= ~GPIO_MASK(gpio);
+
+	gpio_generic_write_reg(gen_gc, gen_gc->reg_set, gen_gc->sdata);
 
 	/* Disable open-drain function */
 	ppc44x_clrbits32(&regs->odr, GPIO_MASK(gpio));
@@ -140,8 +134,6 @@  ppc44x_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 
 	ppc44x_gpio_select_gpio(regs, gpio);
 
-	pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
-
 	return 0;
 }