From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/4] gpio/mxc: specify gpio base for device tree probe
Date: Sun, 5 Aug 2012 14:01:26 +0800 [thread overview]
Message-ID: <1344146488-9496-2-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1344146488-9496-1-git-send-email-shawn.guo@linaro.org>
Currently, unlike the non-DT probe where the gpio base is specified
with pdev->id, the DT probe uses the base dynamically allocated by
gpio core, which uses a completely different numbering scheme. This
causes two issues to user space applications which access sysfs entry
/sys/class/gpio/gpioN.
* It breaks the compatibility with user space applications between
non-DT and DT kernels.
* It's not intuitive and sometimes hard for users to map the Linux
gpio number to the actual hardware pin.
Use alias to identify the gpio port/bank, and then the gpio base
can be specified with port id to solve above issues. If alias is not
defined in device tree, the base number dynamically allocated by gpio
core will be used.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/gpio/gpio-mxc.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 76e8cda..80f44bb 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -465,7 +465,8 @@ static int __devinit mxc_gpio_probe(struct platform_device *pdev)
goto out_iounmap;
port->bgc.gc.to_irq = mxc_gpio_to_irq;
- port->bgc.gc.base = pdev->id * 32;
+ port->bgc.gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
+ pdev->id * 32;
err = gpiochip_add(&port->bgc.gc);
if (err)
--
1.7.5.4
next prev parent reply other threads:[~2012-08-05 6:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-05 6:01 [PATCH 1/4] gpio/mxc: remove redundant shadow variables initialization Shawn Guo
2012-08-05 6:01 ` Shawn Guo [this message]
2012-08-05 9:47 ` [PATCH 2/4] gpio/mxc: specify gpio base for device tree probe Linus Walleij
2012-08-06 14:12 ` Uwe Kleine-König
2012-08-05 6:01 ` [PATCH 3/4] gpio/mxs: " Shawn Guo
2012-08-05 9:48 ` Linus Walleij
2012-08-06 13:51 ` Shawn Guo
2012-08-07 6:56 ` Linus Walleij
2012-08-05 6:01 ` [PATCH 4/4] ARM: dts: imx: add alias for gpio Shawn Guo
2012-08-05 9:49 ` Linus Walleij
2012-08-05 9:45 ` [PATCH 1/4] gpio/mxc: remove redundant shadow variables initialization Linus Walleij
2012-08-06 11:38 ` Dirk Behme
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=1344146488-9496-2-git-send-email-shawn.guo@linaro.org \
--to=shawn.guo@linaro.org \
--cc=linux-arm-kernel@lists.infradead.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).