[<prev] [next>] [day] [month] [year] [list]
Message-ID: <49C7F446.50803@bluewatersys.com>
Date: Tue, 24 Mar 2009 09:42:46 +1300
From: Ryan Mallon <ryan@...ewatersys.com>
To: arm kernel <linux-arm-kernel@...ts.arm.linux.org.uk>,
dbrownell@...rs.sourceforge.net, linux-kernel@...r.kernel.org
Subject: [RFC PATCH] Use gpiochip label for sysfs entries
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@...ewatersys.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);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists