2023-08-01 21:58:30

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH] gpio: sim: mark the GPIO chip as a one that can sleep

From: Bartosz Golaszewski <[email protected]>

Simulated chips use a mutex for synchronization in driver callbacks so
they must not be called from interrupt context. Set the can_sleep field
of the GPIO chip to true to force users to only use threaded irqs.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/gpio/gpio-sim.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index cfbdade841e8..5f8723ad0048 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -429,6 +429,7 @@ static int gpio_sim_add_bank(struct fwnode_handle *swnode, struct device *dev)
gc->set_config = gpio_sim_set_config;
gc->to_irq = gpio_sim_to_irq;
gc->free = gpio_sim_free;
+ gc->can_sleep = true;

ret = devm_gpiochip_add_data(dev, gc, chip);
if (ret)
--
2.39.2



2023-08-02 23:23:20

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH] gpio: sim: mark the GPIO chip as a one that can sleep

On Tue, Aug 1, 2023 at 9:10 PM Bartosz Golaszewski <[email protected]> wrote:

> From: Bartosz Golaszewski <[email protected]>
>
> Simulated chips use a mutex for synchronization in driver callbacks so
> they must not be called from interrupt context. Set the can_sleep field
> of the GPIO chip to true to force users to only use threaded irqs.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Obviously correct.
Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij