Skip to contentSkip to conversation

gpio: pxa: stop reading gpio_chip::base in direction callbacks

PATCH Applied Areeb Ul Haq Mirza 2 participants 2 messages Sep 24 – Sep 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: pxa: stop reading gpio_chip::base in direction callbacks

__gpio_is_inverted() identifies GPIO86-89 on PXA26x by comparing its argument against hardware line numbers, and its other callers pass the hardware index from irqd_to_hwirq(). The direction_input() and direction_output() callbacks instead pass chip->base + offset.

Pass the offset directly, which is the same conversion that commit 566e684e70cb ("gpio: pxa: use new pinctrl GPIO helpers") made for the pinctrl calls in these functions.

No functional change: the driver never sets chip->base, which stays zero because struct pxa_gpio_chip is allocated with devm_kzalloc(). This removes a dependency on gpio_chip::base,
as tracked in drivers/gpio/TODO.

---
Compile-tested only (arm64, COMPILE_TEST, W=1 and sparse clean).

 drivers/gpio/gpio-pxa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-pxa.c +2 -2
index 2b5da973f51f..3ff21e899278 100644
@@ -268,7 +268,7 @@ static int pxa_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 	spin_lock_irqsave(&gpio_lock, flags);
 
 	value = readl_relaxed(base + GPDR_OFFSET);
-	if (__gpio_is_inverted(chip->base + offset))
+	if (__gpio_is_inverted(offset))
 		value |= mask;
 	else
 		value &= ~mask;
@@ -297,7 +297,7 @@ static int pxa_gpio_direction_output(struct gpio_chip *chip,
 	spin_lock_irqsave(&gpio_lock, flags);
 
 	tmp = readl_relaxed(base + GPDR_OFFSET);
-	if (__gpio_is_inverted(chip->base + offset))
+	if (__gpio_is_inverted(offset))
 		tmp &= ~mask;
 	else
 		tmp |= mask;

base-commit: cee9395acd8043be0644b25c34bfa86623f2b935

Signature · 1 line
2.43.0
#1 lore raw
Quoted 10 lines · Areeb Ul Haq Mirza

__gpio_is_inverted() identifies GPIO86-89 on PXA26x by comparing its argument against hardware line numbers, and its other callers pass the hardware index from irqd_to_hwirq(). The direction_input() and direction_output() callbacks instead pass chip->base + offset.

Pass the offset directly, which is the same conversion that commit 566e684e70cb ("gpio: pxa: use new pinctrl GPIO helpers") made for the pinctrl calls in these functions.

[...]

Applied, thanks!

[1/1] gpio: pxa: stop reading gpio_chip::base in direction callbacks

      https://git.kernel.org/brgl/c/c4e74a7058b573617f142e07b4b5bc9eee04f4c8

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>