diff options
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 42fb2fd24c0c..51a8d4103be5 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -69,20 +69,24 @@ static inline void desc_set_label(struct gpio_desc *d, const char *label) | |||
69 | * those calls have no teeth) we can't avoid autorequesting. This nag | 69 | * those calls have no teeth) we can't avoid autorequesting. This nag |
70 | * message should motivate switching to explicit requests... so should | 70 | * message should motivate switching to explicit requests... so should |
71 | * the weaker cleanup after faults, compared to gpio_request(). | 71 | * the weaker cleanup after faults, compared to gpio_request(). |
72 | * | ||
73 | * NOTE: the autorequest mechanism is going away; at this point it's | ||
74 | * only "legal" in the sense that (old) code using it won't break yet, | ||
75 | * but instead only triggers a WARN() stack dump. | ||
72 | */ | 76 | */ |
73 | static int gpio_ensure_requested(struct gpio_desc *desc, unsigned offset) | 77 | static int gpio_ensure_requested(struct gpio_desc *desc, unsigned offset) |
74 | { | 78 | { |
75 | if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) { | 79 | const struct gpio_chip *chip = desc->chip; |
76 | struct gpio_chip *chip = desc->chip; | 80 | const int gpio = chip->base + offset; |
77 | int gpio = chip->base + offset; | ||
78 | 81 | ||
82 | if (WARN(test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0, | ||
83 | "autorequest GPIO-%d\n", gpio)) { | ||
79 | if (!try_module_get(chip->owner)) { | 84 | if (!try_module_get(chip->owner)) { |
80 | pr_err("GPIO-%d: module can't be gotten \n", gpio); | 85 | pr_err("GPIO-%d: module can't be gotten \n", gpio); |
81 | clear_bit(FLAG_REQUESTED, &desc->flags); | 86 | clear_bit(FLAG_REQUESTED, &desc->flags); |
82 | /* lose */ | 87 | /* lose */ |
83 | return -EIO; | 88 | return -EIO; |
84 | } | 89 | } |
85 | pr_warning("GPIO-%d autorequested\n", gpio); | ||
86 | desc_set_label(desc, "[auto]"); | 90 | desc_set_label(desc, "[auto]"); |
87 | /* caller must chip->request() w/o spinlock */ | 91 | /* caller must chip->request() w/o spinlock */ |
88 | if (chip->request) | 92 | if (chip->request) |
@@ -438,6 +442,7 @@ int gpio_export(unsigned gpio, bool direction_may_change) | |||
438 | unsigned long flags; | 442 | unsigned long flags; |
439 | struct gpio_desc *desc; | 443 | struct gpio_desc *desc; |
440 | int status = -EINVAL; | 444 | int status = -EINVAL; |
445 | char *ioname = NULL; | ||
441 | 446 | ||
442 | /* can't export until sysfs is available ... */ | 447 | /* can't export until sysfs is available ... */ |
443 | if (!gpio_class.p) { | 448 | if (!gpio_class.p) { |
@@ -461,11 +466,14 @@ int gpio_export(unsigned gpio, bool direction_may_change) | |||
461 | } | 466 | } |
462 | spin_unlock_irqrestore(&gpio_lock, flags); | 467 | spin_unlock_irqrestore(&gpio_lock, flags); |
463 | 468 | ||
469 | if (desc->chip->names && desc->chip->names[gpio - desc->chip->base]) | ||
470 | ioname = desc->chip->names[gpio - desc->chip->base]; | ||
471 | |||
464 | if (status == 0) { | 472 | if (status == 0) { |
465 | struct device *dev; | 473 | struct device *dev; |
466 | 474 | ||
467 | dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0), | 475 | dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0), |
468 | desc, "gpio%d", gpio); | 476 | desc, ioname ? ioname : "gpio%d", gpio); |
469 | if (dev) { | 477 | if (dev) { |
470 | if (direction_may_change) | 478 | if (direction_may_change) |
471 | status = sysfs_create_group(&dev->kobj, | 479 | status = sysfs_create_group(&dev->kobj, |
@@ -513,6 +521,7 @@ void gpio_unexport(unsigned gpio) | |||
513 | mutex_lock(&sysfs_lock); | 521 | mutex_lock(&sysfs_lock); |
514 | 522 | ||
515 | desc = &gpio_desc[gpio]; | 523 | desc = &gpio_desc[gpio]; |
524 | |||
516 | if (test_bit(FLAG_EXPORT, &desc->flags)) { | 525 | if (test_bit(FLAG_EXPORT, &desc->flags)) { |
517 | struct device *dev = NULL; | 526 | struct device *dev = NULL; |
518 | 527 | ||