diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-08-23 14:43:38 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-08-23 14:43:38 -0400 |
| commit | a67ca1e9bd07c05548bf7c2d6f065ca9db11e9bf (patch) | |
| tree | ed9a85e8db34c7073a36307932fa45913c91c1eb | |
| parent | 55652400fdab0838b7ef446f4a3541aefdd9ccb0 (diff) | |
| parent | 3f13b6a24f192da3096389b82202f16eff2c11ee (diff) | |
Merge tag 'gpio-v4.13-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij:
"Here are the (hopefully) last GPIO fixes for v4.13:
- an important core fix to reject invalid GPIOs *before* trying to
obtain a GPIO descriptor for it.
- a driver fix for the mvebu driver IRQ handling"
* tag 'gpio-v4.13-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
gpio: mvebu: Fix cause computation in irq handler
gpio: reject invalid gpio before getting gpio_desc
| -rw-r--r-- | drivers/gpio/gpio-mvebu.c | 2 | ||||
| -rw-r--r-- | drivers/gpio/gpiolib-sysfs.c | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index e338c3743562..45c65f805fd6 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c | |||
| @@ -557,7 +557,7 @@ static void mvebu_gpio_irq_handler(struct irq_desc *desc) | |||
| 557 | edge_cause = mvebu_gpio_read_edge_cause(mvchip); | 557 | edge_cause = mvebu_gpio_read_edge_cause(mvchip); |
| 558 | edge_mask = mvebu_gpio_read_edge_mask(mvchip); | 558 | edge_mask = mvebu_gpio_read_edge_mask(mvchip); |
| 559 | 559 | ||
| 560 | cause = (data_in ^ level_mask) | (edge_cause & edge_mask); | 560 | cause = (data_in & level_mask) | (edge_cause & edge_mask); |
| 561 | 561 | ||
| 562 | for (i = 0; i < mvchip->chip.ngpio; i++) { | 562 | for (i = 0; i < mvchip->chip.ngpio; i++) { |
| 563 | int irq; | 563 | int irq; |
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 16fe9742597b..fc80add5fedb 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #include <linux/mutex.h> | 2 | #include <linux/mutex.h> |
| 3 | #include <linux/device.h> | 3 | #include <linux/device.h> |
| 4 | #include <linux/sysfs.h> | 4 | #include <linux/sysfs.h> |
| 5 | #include <linux/gpio.h> | ||
| 5 | #include <linux/gpio/consumer.h> | 6 | #include <linux/gpio/consumer.h> |
| 6 | #include <linux/gpio/driver.h> | 7 | #include <linux/gpio/driver.h> |
| 7 | #include <linux/interrupt.h> | 8 | #include <linux/interrupt.h> |
| @@ -432,6 +433,11 @@ static struct attribute *gpiochip_attrs[] = { | |||
| 432 | }; | 433 | }; |
| 433 | ATTRIBUTE_GROUPS(gpiochip); | 434 | ATTRIBUTE_GROUPS(gpiochip); |
| 434 | 435 | ||
| 436 | static struct gpio_desc *gpio_to_valid_desc(int gpio) | ||
| 437 | { | ||
| 438 | return gpio_is_valid(gpio) ? gpio_to_desc(gpio) : NULL; | ||
| 439 | } | ||
| 440 | |||
| 435 | /* | 441 | /* |
| 436 | * /sys/class/gpio/export ... write-only | 442 | * /sys/class/gpio/export ... write-only |
| 437 | * integer N ... number of GPIO to export (full access) | 443 | * integer N ... number of GPIO to export (full access) |
| @@ -450,7 +456,7 @@ static ssize_t export_store(struct class *class, | |||
| 450 | if (status < 0) | 456 | if (status < 0) |
| 451 | goto done; | 457 | goto done; |
| 452 | 458 | ||
| 453 | desc = gpio_to_desc(gpio); | 459 | desc = gpio_to_valid_desc(gpio); |
| 454 | /* reject invalid GPIOs */ | 460 | /* reject invalid GPIOs */ |
| 455 | if (!desc) { | 461 | if (!desc) { |
| 456 | pr_warn("%s: invalid GPIO %ld\n", __func__, gpio); | 462 | pr_warn("%s: invalid GPIO %ld\n", __func__, gpio); |
| @@ -493,7 +499,7 @@ static ssize_t unexport_store(struct class *class, | |||
| 493 | if (status < 0) | 499 | if (status < 0) |
| 494 | goto done; | 500 | goto done; |
| 495 | 501 | ||
| 496 | desc = gpio_to_desc(gpio); | 502 | desc = gpio_to_valid_desc(gpio); |
| 497 | /* reject bogus commands (gpio_unexport ignores them) */ | 503 | /* reject bogus commands (gpio_unexport ignores them) */ |
| 498 | if (!desc) { | 504 | if (!desc) { |
| 499 | pr_warn("%s: invalid GPIO %ld\n", __func__, gpio); | 505 | pr_warn("%s: invalid GPIO %ld\n", __func__, gpio); |
