GPIO fixes for the v4.13 series:
- 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. -----BEGIN PGP SIGNATURE----- iQIcBAABAgAGBQJZnT/4AAoJEEEQszewGV1zt4oP/14p4YCqooukiR8oZpG30Wj3 34EOPQ2k2/BrKegO3IN+4TkZScfnH4hqeJ6z95mrJtI0MMXBM3Zu+967L1lVOueB TBaxb034iNGpjztB3gQ1cCBuR7409AH89irzUFeNXfSZtelAu73lfiEp1W02+uUt 80Jlzuov/ANJi2PrNS1arH8QJmurWwhmbCsqQ8xB8RXkNE0uu5809ahntqlgfSpf bXGXPrtmNgM14BheGhYMTR+jZRprlblRYrz1Cjy9x9iJeJWOzADVpjeIjBZxI4OG M+MPWfyXZldiVXlhR5QQgeJnQgmi4AkhL7VSkez5Dpdirtrnh0hgVc+oPw01w2g4 bsbaXGzwTuT5ok20+E92po5ALMCLfOwj3Jw91b7UquLbM0QqgDVz/u7VpAk2gPuT fWTIBxyQMfUSvNqKTF6/gJIkfA40H/x2ydVJvDdFT9I3B4KP4yxPjHzMTd99MmuR +2n4nULjzjocuaYAdZVAd8gxh+dzsaVBBEx+uSu/jgjoObMKyt93JnWZvak8sBvI Gehe2zvfvLtGN3C9cBAGzlZIP6vIhB8emCLR7DMLsarGybgwhoxU45cvAfuKepge FojltQhVXMmiwdNQI4CxNzfRhXOpUhY7/yim/2w+evT9UM15QHKI7CS/3QUqe8uk qnAFYNXQ9v6PVrh+egu9 =eV+r -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
a67ca1e9bd
@ -557,7 +557,7 @@ static void mvebu_gpio_irq_handler(struct irq_desc *desc)
|
|||||||
edge_cause = mvebu_gpio_read_edge_cause(mvchip);
|
edge_cause = mvebu_gpio_read_edge_cause(mvchip);
|
||||||
edge_mask = mvebu_gpio_read_edge_mask(mvchip);
|
edge_mask = mvebu_gpio_read_edge_mask(mvchip);
|
||||||
|
|
||||||
cause = (data_in ^ level_mask) | (edge_cause & edge_mask);
|
cause = (data_in & level_mask) | (edge_cause & edge_mask);
|
||||||
|
|
||||||
for (i = 0; i < mvchip->chip.ngpio; i++) {
|
for (i = 0; i < mvchip->chip.ngpio; i++) {
|
||||||
int irq;
|
int irq;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <linux/sysfs.h>
|
#include <linux/sysfs.h>
|
||||||
|
#include <linux/gpio.h>
|
||||||
#include <linux/gpio/consumer.h>
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/gpio/driver.h>
|
#include <linux/gpio/driver.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
@ -432,6 +433,11 @@ static struct attribute *gpiochip_attrs[] = {
|
|||||||
};
|
};
|
||||||
ATTRIBUTE_GROUPS(gpiochip);
|
ATTRIBUTE_GROUPS(gpiochip);
|
||||||
|
|
||||||
|
static struct gpio_desc *gpio_to_valid_desc(int gpio)
|
||||||
|
{
|
||||||
|
return gpio_is_valid(gpio) ? gpio_to_desc(gpio) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* /sys/class/gpio/export ... write-only
|
* /sys/class/gpio/export ... write-only
|
||||||
* integer N ... number of GPIO to export (full access)
|
* integer N ... number of GPIO to export (full access)
|
||||||
@ -450,7 +456,7 @@ static ssize_t export_store(struct class *class,
|
|||||||
if (status < 0)
|
if (status < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
desc = gpio_to_desc(gpio);
|
desc = gpio_to_valid_desc(gpio);
|
||||||
/* reject invalid GPIOs */
|
/* reject invalid GPIOs */
|
||||||
if (!desc) {
|
if (!desc) {
|
||||||
pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
|
pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
|
||||||
@ -493,7 +499,7 @@ static ssize_t unexport_store(struct class *class,
|
|||||||
if (status < 0)
|
if (status < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
desc = gpio_to_desc(gpio);
|
desc = gpio_to_valid_desc(gpio);
|
||||||
/* reject bogus commands (gpio_unexport ignores them) */
|
/* reject bogus commands (gpio_unexport ignores them) */
|
||||||
if (!desc) {
|
if (!desc) {
|
||||||
pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
|
pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
|
||||||
|
Loading…
Reference in New Issue
Block a user