[PATCH, v1 0/1] gpio: aspeed: Add gpio base address reading

STALE2020d

4 messages, 3 authors, 2021-01-18 · open the first message on its own page

[PATCH, v1 0/1] gpio: aspeed: Add gpio base address reading

From: Hongwei Zhang <hidden>
Date: 2021-01-13 23:19:25

Dear Reviewer,

Add gpio base address reading in the driver; in old code, it just
returns -1 to gpio->chip.base. In this patch, the code first try to
read base address from of_property_read_u32(), if it fails, then
return -1.

Hongwei Zhang (1):
  gpio: aspeed: Add gpio base address reading

 drivers/gpio/gpio-aspeed.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

[PATCH, v1 1/1] gpio: aspeed: Add gpio base address reading

From: Hongwei Zhang <hidden>
Date: 2021-01-13 23:11:03

Add gpio base address reading in the driver; in old code, it just
returns -1 to gpio->chip.base.

Fixes: 7ee2d5b4d4340353 ("ARM: dts: nuvoton: Add Fii Kudo system")
Signed-off-by: Hongwei Zhang <redacted>
---
 drivers/gpio/gpio-aspeed.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
index d07bf2c3f136..4ebe4c40154c 100644
--- a/drivers/gpio/gpio-aspeed.c
+++ b/drivers/gpio/gpio-aspeed.c
@@ -1140,7 +1140,7 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
 	const struct of_device_id *gpio_id;
 	struct aspeed_gpio *gpio;
 	int rc, i, banks, err;
-	u32 ngpio;
+	u32 ngpio, base;
 
 	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
 	if (!gpio)
@@ -1179,7 +1179,10 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
 	gpio->chip.set = aspeed_gpio_set;
 	gpio->chip.set_config = aspeed_gpio_set_config;
 	gpio->chip.label = dev_name(&pdev->dev);
-	gpio->chip.base = -1;
+	err = of_property_read_u32(pdev->dev.of_node, "base", &base);
+	gpio->chip.base = (u16) base;
+	if (err)
+		gpio->chip.base = -1;
 
 	/* Allocate a cache of the output registers */
 	banks = DIV_ROUND_UP(gpio->chip.ngpio, 32);
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH, v1 1/1] gpio: aspeed: Add gpio base address reading

From: Andrew Jeffery <hidden>
Date: 2021-01-14 01:50:22

Hello,

On Thu, 14 Jan 2021, at 09:08, Hongwei Zhang wrote:
Add gpio base address reading in the driver; in old code, it just
returns -1 to gpio->chip.base.
Why do you want to do this? It feels hacky. The base address only affects the 
legacy sysfs number-space, and even then if you're using the sysfs interface 
you can discover the base address for a specific gpiochip via the associated 
attribute. For example:

# cat /sys/bus/platform/devices/1e780000.gpio/gpio/gpiochip*/base
816

I feel that you should instead be changing your userspace not to assume a fixed 
value.

Finally, the base value is a linux-specific thing and doesn't belong in the 
devicetree, and if it did, you would also need to update the devicetree binding 
in Documentation/.

Cheers,

Andrew

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH, v1 1/1] gpio: aspeed: Add gpio base address reading

From: Linus Walleij <hidden>
Date: 2021-01-18 14:44:39

On Wed, Jan 13, 2021 at 11:38 PM Hongwei Zhang [off-list ref] wrote:
Add gpio base address reading in the driver; in old code, it just
returns -1 to gpio->chip.base.

Fixes: 7ee2d5b4d4340353 ("ARM: dts: nuvoton: Add Fii Kudo system")
Signed-off-by: Hongwei Zhang <redacted>
NAK, sorry.

We never allow the device tree to specify this.

First, it is a Linux-only base so it would have to be a
"linux,..." property.

Even if it is a Linux-only property, it is a bad idea.

Only people using sysfs should have any need to specify global
GPIO numbers. Don't use sysfs. Use the GPIO character device
instead. See further:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpio/TODO

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help