Skip to contentSkip to conversation

gpio: mt7621: Assign base field in gpio_chip

PATCH In review Reto Schneider 2 participants 4 messages Jun 13, 2021 1 message not in the archive

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

PATCH 1/1 gpio: mt7621: Assign base field in gpio_chip

From: Reto Schneider <[email protected]>

This is needed for gpiochip_sysfs_register() to properly export /sys/class/gpio/gpiochip{0,32,64}.

Without this fix, the field base in gpio_device remains at its initialization value, which is -1. This causes gpiochip_add_data_with_key() to call gpiochip_find_base(), which in turn dynamically determines the base to be at ARCH_NR_GPIOS - 32/64/96, resulting in gpiochip{480,448,416}.

Detected/fixed/tested on a MediaTek MT7688 based GARDENA smart gateway.

---

 drivers/gpio/gpio-mt7621.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpio-mt7621.c +1 -0
index 82fb20dca53a..403d64cd65a6 100644
@@ -234,6 +234,7 @@ mediatek_gpio_bank_probe(struct device *dev,
 		return ret;
 	}
 
+	rg->chip.base = rg->bank * MTK_BANK_WIDTH;
 	rg->chip.of_gpio_n_cells = 2;
 	rg->chip.of_xlate = mediatek_gpio_xlate;
 	rg->chip.label = devm_kasprintf(dev, GFP_KERNEL, "%s-bank%d",
Signature · 1 line
2.30.2

A message that is not in the archive (sent off-list or not yet received): CAHp75Vc5LRRLc-1A5W4BVQ3QQx-+4Y5CUjG3ksosVdPEecEyqA@mail.gmail.com

#2 lore raw

Hi Andy,

Quoted 3 lines · Andy Shevchenko

It smells like a fixing non-existing bug. Yes, I understand that there is some custom hardware with custom firmware which is using Linux kernel with some never upstreamed patches. On top of this sysfs interface is deprecated for already a few years and shouldn’t be considered as 1st class citizen.

That’s said, if there is no Fixes tag provided with clear point that _at some point_ it was like this in upstream, I would tend to NAK this patch.

I did some digging and indeed, it turned out that I used the pre-mainline GPIO driver from OpenWRT even on Kernel 4.19 (for which the current driver already got mainlined).

Surely do agree on not breaking the interface in mainline, and the NAK.

Sorry for wasting your time!

Kind regards,
Reto

#3 lore raw
Quoted 3 lines · Reto Schneider

I did some digging and indeed, it turned out that I used the pre-mainline GPIO driver from OpenWRT even on Kernel 4.19 (for which the current driver already got mainlined).

Hm isn't OpenWrt switched to the mainline driver?

Another thing we should do is to add libgpiod to the OpenWrt base distribution so as to encourage people to use the character device ABI.

Yours,
Linus Walleij