From: Hongwei Zhang <hongweiz@ami.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>,
<linux-gpio@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-aspeed@lists.ozlabs.org>, <linux-kernel@vger.kernel.org>,
<openbmc@lists.ozlabs.org>
Cc: Hongwei Zhang <hongweiz@ami.com>
Subject: [PATCH, v1 1/1] gpio: aspeed: Add gpio base address reading
Date: Wed, 13 Jan 2021 17:38:08 -0500 [thread overview]
Message-ID: <20210113223808.31626-2-hongweiz@ami.com> (raw)
In-Reply-To: <20210113223808.31626-1-hongweiz@ami.com>
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 <hongweiz@ami.com>
---
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
WARNING: multiple messages have this Message-ID (diff)
From: Hongwei Zhang <hongweiz@ami.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-aspeed@lists.ozlabs.org, linux-gpio@vger.kernel.org,
Andrew Jeffery <andrew@aj.id.au>,
openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
Hongwei Zhang <hongweiz@ami.com>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH, v1 1/1] gpio: aspeed: Add gpio base address reading
Date: Fri, 5 Feb 2021 11:34:50 -0500 [thread overview]
Message-ID: <20210113223808.31626-2-hongweiz@ami.com> (raw)
Message-ID: <20210205163450.A8GC_2DhCjIlBYmBqN_lDNtc3fvnfD3oVr4i7baK3LM@z> (raw)
In-Reply-To: <20210113223808.31626-1-hongweiz@ami.com>
> On Wed, Jan 13, 2021 at 11:38 PM Hongwei Zhang <hongweiz@ami.com> 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 <hongweiz@ami.com>
>
> 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
Hi Linus,
Thanks for your review and advice.
--Hongwei
WARNING: multiple messages have this Message-ID (diff)
From: Hongwei Zhang <hongweiz@ami.com>
To: Andrew Jeffery <andrew@aj.id.au>
Cc: linux-aspeed@lists.ozlabs.org, linux-gpio@vger.kernel.org,
Linus Walleij <linus.walleij@linaro.org>,
linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
Hongwei Zhang <hongweiz@ami.com>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH, v1 1/1] gpio: aspeed: Add gpio base address reading
Date: Fri, 5 Feb 2021 11:34:51 -0500 [thread overview]
Message-ID: <20210113223808.31626-2-hongweiz@ami.com> (raw)
Message-ID: <20210205163451.OfORZ8dVmNpt8aEZgkDb-O9cyAw2iieya3-lxKMbduc@z> (raw)
In-Reply-To: <20210113223808.31626-1-hongweiz@ami.com>
> 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
Hi Andrew,
Thanks for your review and advice.
--Hongwei
next prev parent reply other threads:[~2021-01-13 22:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-13 22:38 [PATCH, v1 0/1] gpio: aspeed: Add gpio base address reading Hongwei Zhang
2021-01-13 22:38 ` Hongwei Zhang [this message]
2021-01-14 0:27 ` [PATCH, v1 1/1] " Andrew Jeffery
2021-01-18 14:40 ` Linus Walleij
2021-02-05 16:34 ` Hongwei Zhang
2021-02-05 16:34 ` Hongwei Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210113223808.31626-2-hongweiz@ami.com \
--to=hongweiz@ami.com \
--cc=andrew@aj.id.au \
--cc=bgolaszewski@baylibre.com \
--cc=joel@jms.id.au \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=openbmc@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).