mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 05:55:44 +02:00
gpio: aggregator: Fix calling into sleeping GPIO controllers
[ Upstream commit2cba05451a] If the parent GPIO controller is a sleeping controller (e.g. a GPIO controller connected to I2C), getting or setting a GPIO triggers a might_sleep() warning. This happens because the GPIO Aggregator takes the can_sleep flag into account only for its internal locking, not for calling into the parent GPIO controller. Fix this by using the gpiod_[gs]et*_cansleep() APIs when calling into a sleeping GPIO controller. Reported-by: Mikko Salomäki <ms@datarespons.se> Fixes:828546e242("gpio: Add GPIO Aggregator") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
0042178a69
commit
70ea005626
|
|
@ -330,7 +330,8 @@ static int gpio_fwd_get(struct gpio_chip *chip, unsigned int offset)
|
||||||
{
|
{
|
||||||
struct gpiochip_fwd *fwd = gpiochip_get_data(chip);
|
struct gpiochip_fwd *fwd = gpiochip_get_data(chip);
|
||||||
|
|
||||||
return gpiod_get_value(fwd->descs[offset]);
|
return chip->can_sleep ? gpiod_get_value_cansleep(fwd->descs[offset])
|
||||||
|
: gpiod_get_value(fwd->descs[offset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gpio_fwd_get_multiple(struct gpiochip_fwd *fwd, unsigned long *mask,
|
static int gpio_fwd_get_multiple(struct gpiochip_fwd *fwd, unsigned long *mask,
|
||||||
|
|
@ -349,6 +350,9 @@ static int gpio_fwd_get_multiple(struct gpiochip_fwd *fwd, unsigned long *mask,
|
||||||
for_each_set_bit(i, mask, fwd->chip.ngpio)
|
for_each_set_bit(i, mask, fwd->chip.ngpio)
|
||||||
descs[j++] = fwd->descs[i];
|
descs[j++] = fwd->descs[i];
|
||||||
|
|
||||||
|
if (fwd->chip.can_sleep)
|
||||||
|
error = gpiod_get_array_value_cansleep(j, descs, NULL, values);
|
||||||
|
else
|
||||||
error = gpiod_get_array_value(j, descs, NULL, values);
|
error = gpiod_get_array_value(j, descs, NULL, values);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
@ -384,6 +388,9 @@ static void gpio_fwd_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||||
{
|
{
|
||||||
struct gpiochip_fwd *fwd = gpiochip_get_data(chip);
|
struct gpiochip_fwd *fwd = gpiochip_get_data(chip);
|
||||||
|
|
||||||
|
if (chip->can_sleep)
|
||||||
|
gpiod_set_value_cansleep(fwd->descs[offset], value);
|
||||||
|
else
|
||||||
gpiod_set_value(fwd->descs[offset], value);
|
gpiod_set_value(fwd->descs[offset], value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -403,6 +410,9 @@ static void gpio_fwd_set_multiple(struct gpiochip_fwd *fwd, unsigned long *mask,
|
||||||
descs[j++] = fwd->descs[i];
|
descs[j++] = fwd->descs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fwd->chip.can_sleep)
|
||||||
|
gpiod_set_array_value_cansleep(j, descs, NULL, values);
|
||||||
|
else
|
||||||
gpiod_set_array_value(j, descs, NULL, values);
|
gpiod_set_array_value(j, descs, NULL, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user