aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpio/gpiolib.c7
-rw-r--r--include/asm-generic/gpio.h5
2 files changed, 11 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 42fb2fd24c0c..83c3fe3a136b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -438,6 +438,7 @@ int gpio_export(unsigned gpio, bool direction_may_change)
438 unsigned long flags; 438 unsigned long flags;
439 struct gpio_desc *desc; 439 struct gpio_desc *desc;
440 int status = -EINVAL; 440 int status = -EINVAL;
441 char *ioname = NULL;
441 442
442 /* can't export until sysfs is available ... */ 443 /* can't export until sysfs is available ... */
443 if (!gpio_class.p) { 444 if (!gpio_class.p) {
@@ -461,11 +462,14 @@ int gpio_export(unsigned gpio, bool direction_may_change)
461 } 462 }
462 spin_unlock_irqrestore(&gpio_lock, flags); 463 spin_unlock_irqrestore(&gpio_lock, flags);
463 464
465 if (desc->chip->names && desc->chip->names[gpio - desc->chip->base])
466 ioname = desc->chip->names[gpio - desc->chip->base];
467
464 if (status == 0) { 468 if (status == 0) {
465 struct device *dev; 469 struct device *dev;
466 470
467 dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0), 471 dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0),
468 desc, "gpio%d", gpio); 472 desc, ioname ? ioname : "gpio%d", gpio);
469 if (dev) { 473 if (dev) {
470 if (direction_may_change) 474 if (direction_may_change)
471 status = sysfs_create_group(&dev->kobj, 475 status = sysfs_create_group(&dev->kobj,
@@ -513,6 +517,7 @@ void gpio_unexport(unsigned gpio)
513 mutex_lock(&sysfs_lock); 517 mutex_lock(&sysfs_lock);
514 518
515 desc = &gpio_desc[gpio]; 519 desc = &gpio_desc[gpio];
520
516 if (test_bit(FLAG_EXPORT, &desc->flags)) { 521 if (test_bit(FLAG_EXPORT, &desc->flags)) {
517 struct device *dev = NULL; 522 struct device *dev = NULL;
518 523
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 81797ec9ab29..d6c379dc64fa 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -55,6 +55,10 @@ struct module;
55 * handled is (base + ngpio - 1). 55 * handled is (base + ngpio - 1).
56 * @can_sleep: flag must be set iff get()/set() methods sleep, as they 56 * @can_sleep: flag must be set iff get()/set() methods sleep, as they
57 * must while accessing GPIO expander chips over I2C or SPI 57 * must while accessing GPIO expander chips over I2C or SPI
58 * @names: if set, must be an array of strings to use as alternative
59 * names for the GPIOs in this chip. Any entry in the array
60 * may be NULL if there is no alias for the GPIO, however the
61 * array must be @ngpio entries long.
58 * 62 *
59 * A gpio_chip can help platforms abstract various sources of GPIOs so 63 * A gpio_chip can help platforms abstract various sources of GPIOs so
60 * they can all be accessed through a common programing interface. 64 * they can all be accessed through a common programing interface.
@@ -92,6 +96,7 @@ struct gpio_chip {
92 struct gpio_chip *chip); 96 struct gpio_chip *chip);
93 int base; 97 int base;
94 u16 ngpio; 98 u16 ngpio;
99 char **names;
95 unsigned can_sleep:1; 100 unsigned can_sleep:1;
96 unsigned exported:1; 101 unsigned exported:1;
97}; 102};