public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] Use gpiochip label for sysfs entries
@ 2009-03-23 20:42 Ryan Mallon
  0 siblings, 0 replies; only message in thread
From: Ryan Mallon @ 2009-03-23 20:42 UTC (permalink / raw)
  To: arm kernel, dbrownell, linux-kernel

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);


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-23 20:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-23 20:42 [RFC PATCH] Use gpiochip label for sysfs entries Ryan Mallon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox