From: Ryan Mallon <ryan@bluewatersys.com>
To: arm kernel <linux-arm-kernel@lists.arm.linux.org.uk>,
dbrownell@users.sourceforge.net, linux-kernel@vger.kernel.org
Subject: [RFC PATCH] Use gpiochip label for sysfs entries
Date: Tue, 24 Mar 2009 09:42:46 +1300 [thread overview]
Message-ID: <49C7F446.50803@bluewatersys.com> (raw)
At least on the ep93xx, the gpio banks have names (A, B, etc), which are
used for gpiochip->label. However, banks C and F are swapped which makes
the names of the gpiochip directories in /sys/class/gpio confusing. For
many SoC chips, it would be useful to have the gpio label on the sysfs
entries.
The following patch registers the gpiochip devices using
gpiochip->label. If label is not set, or the registration fails, it
falls back to using gpiochip->base.
Signed-off-by: Ryan Mallon <ryan@bluewatersys.com>
---
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 42fb2fd..698481c 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -536,7 +536,7 @@ EXPORT_SYMBOL_GPL(gpio_unexport);
static int gpiochip_export(struct gpio_chip *chip)
{
int status;
- struct device *dev;
+ struct device *dev = NULL;
/* Many systems register gpio chips for SOC support very early,
* before driver model support is available. In those cases we
@@ -546,10 +546,16 @@ static int gpiochip_export(struct gpio_chip *chip)
if (!gpio_class.p)
return 0;
- /* use chip->base for the ID; it's already known to be unique */
mutex_lock(&sysfs_lock);
- dev = device_create(&gpio_class, chip->dev, MKDEV(0, 0), chip,
- "gpiochip%d", chip->base);
+ if (chip->label)
+ /* Attempt to register the device using the gpiochip label */
+ dev = device_create(&gpio_class, chip->dev, MKDEV(0, 0), chip,
+ "gpiochip-%s", chip->label);
+
+ if (!dev)
+ /* Use chip->base for the ID; it's already known to be unique */
+ dev = device_create(&gpio_class, chip->dev, MKDEV(0, 0), chip,
+ "gpiochip%d", chip->base);
if (dev) {
status = sysfs_create_group(&dev->kobj,
&gpiochip_attr_group);
reply other threads:[~2009-03-23 20:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=49C7F446.50803@bluewatersys.com \
--to=ryan@bluewatersys.com \
--cc=dbrownell@users.sourceforge.net \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-kernel@vger.kernel.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