mirror of
https://github.com/torvalds/linux.git
synced 2026-05-23 14:42:08 +02:00
GPIO fixes for the v4.7 cycle:
- It was discovered that too many parts of the kernel does not
respect gpiod_to_irq() returning zero for an invalid IRQ.
While this gets fixed, we need to make it return negative
errorcodes again.
- Harden the library a bit when passed error pointers. It is
a bug to use these, but let's be helpful and warn the users.
- Fix an uninitialized spinlock in the 104-idi-48 driver.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABAgAGBQJXaraQAAoJEEEQszewGV1zfUQQAKOAYtQ6nMat4R12UR0RKTIV
oHALxvZVHvaZbMxwSwcyIognHQJ6u6tgsTrv4M8+XQqW9LsIyw7wWzbLHY+ceYSO
l29RKzjm0diUcFBQ+E9bYoETYtg1XDjJwAtu/hRhNp3MYXZg7UeoHijvAprGYmkM
ZyQ90Et4E0TfaLV+nuHBHPlU/5kzdkKXdzH+DwNxEbFKK0y35QaOWHRolRV8/qh3
H/WgDyFo0KzRb6Ehd/MnTCq5UyQp0cAoPDuyOp6LIihFlu81UQfFhSr5kS3Q4jV+
EbZ59XbhjXy+UUsYRaFOmGlIsVOyVhqwsRa5VzuBEdKsrW5BG2zKNBz2ANteoyUp
1nmcde4r28G10zJU0uiNasPk2VEpAhbcGyu6VfSyS9nSNn2sBR+tEYhn7IYP26xo
PN53tjDB3xc0hpAvNUwdJBJ6kJGlqT5GyLkTwy9Yt1IlMi7aKUforyh6e8feEri4
j/BQWFrmxnjcQWpPJhPdkVZozmFeHBM9+tREhEjBXRiEWIyBzAh9m2kNK3Gg3vfW
YLikNGdo2w7rmKA+BvFfzOlqg2R/SWvPXSqL0Y4H/IAe+OT5pV0rf/UW6FBKLTuY
qgmavFcTbMCbTRR3nVtaAN5HZiW5eXN8u16ONaZbGgroT9PPzLwXJ58gpkXv+v/3
VTg2vw1debYCwrastDdi
=cwEd
-----END PGP SIGNATURE-----
Merge tag 'gpio-v4.7-4' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij:
"More GPIO fixes. Most prominent the gpiod_to_irq() fix brought to my
attention by Hans de Goede. The hardening patch is a consequence of
the reasoning around that bug.
- It was discovered that too many parts of the kernel does not
respect gpiod_to_irq() returning zero for an invalid IRQ. While
this gets fixed, we need to make it return negative errorcodes
again.
- Harden the library a bit when passed error pointers. It is a bug
to use these, but let's be helpful and warn the users.
- Fix an uninitialized spinlock in the 104-idi-48 driver"
* tag 'gpio-v4.7-4' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
gpio: make library immune to error pointers
gpio: make sure gpiod_to_irq() returns negative on NULL desc
gpio: 104-idi-48: Fix missing spin_lock_init for ack_lock
This commit is contained in:
commit
144b5ae3e3
|
|
@ -247,6 +247,7 @@ static int idi_48_probe(struct device *dev, unsigned int id)
|
|||
idi48gpio->irq = irq[id];
|
||||
|
||||
spin_lock_init(&idi48gpio->lock);
|
||||
spin_lock_init(&idi48gpio->ack_lock);
|
||||
|
||||
dev_set_drvdata(dev, idi48gpio);
|
||||
|
||||
|
|
|
|||
|
|
@ -1373,8 +1373,12 @@ static int __gpiod_request(struct gpio_desc *desc, const char *label)
|
|||
#define VALIDATE_DESC(desc) do { \
|
||||
if (!desc) \
|
||||
return 0; \
|
||||
if (IS_ERR(desc)) { \
|
||||
pr_warn("%s: invalid GPIO (errorpointer)\n", __func__); \
|
||||
return PTR_ERR(desc); \
|
||||
} \
|
||||
if (!desc->gdev) { \
|
||||
pr_warn("%s: invalid GPIO\n", __func__); \
|
||||
pr_warn("%s: invalid GPIO (no device)\n", __func__); \
|
||||
return -EINVAL; \
|
||||
} \
|
||||
if ( !desc->gdev->chip ) { \
|
||||
|
|
@ -1386,8 +1390,12 @@ static int __gpiod_request(struct gpio_desc *desc, const char *label)
|
|||
#define VALIDATE_DESC_VOID(desc) do { \
|
||||
if (!desc) \
|
||||
return; \
|
||||
if (IS_ERR(desc)) { \
|
||||
pr_warn("%s: invalid GPIO (errorpointer)\n", __func__); \
|
||||
return; \
|
||||
} \
|
||||
if (!desc->gdev) { \
|
||||
pr_warn("%s: invalid GPIO\n", __func__); \
|
||||
pr_warn("%s: invalid GPIO (no device)\n", __func__); \
|
||||
return; \
|
||||
} \
|
||||
if (!desc->gdev->chip) { \
|
||||
|
|
@ -2056,7 +2064,14 @@ int gpiod_to_irq(const struct gpio_desc *desc)
|
|||
struct gpio_chip *chip;
|
||||
int offset;
|
||||
|
||||
VALIDATE_DESC(desc);
|
||||
/*
|
||||
* Cannot VALIDATE_DESC() here as gpiod_to_irq() consumer semantics
|
||||
* requires this function to not return zero on an invalid descriptor
|
||||
* but rather a negative error number.
|
||||
*/
|
||||
if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip)
|
||||
return -EINVAL;
|
||||
|
||||
chip = desc->gdev->chip;
|
||||
offset = gpio_chip_hwgpio(desc);
|
||||
if (chip->to_irq) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user