Skip to contentSkip to conversation

gpio: sim: mark the GPIO chip as a one that can sleep

PATCH In review Bartosz Golaszewski 3 participants 4 messages Aug 1, 2023 – Aug 2, 2023 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/gpio/gpio-sim.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpio-sim.c +1 -0
index cfbdade841e8..5f8723ad0048 100644
@@ -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)
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Bartosz Golaszewski

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.

Ah, good catch! Doesn't it deserve a Fixes tag?

Quoted 20 lines
---
 drivers/gpio/gpio-sim.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpio-sim.c +1 -0
index cfbdade841e8..5f8723ad0048 100644
@@ -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)
Signature · 1 line
2.39.2
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 5 lines · Bartosz Golaszewski

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.

Ah, good catch! Doesn't it deserve a Fixes tag?

I will add it when applying.

Bart

Quoted 29 lines
Quoted 18 lines
---
 drivers/gpio/gpio-sim.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpio-sim.c +1 -1
index cfbdade841e8..5f8723ad0048 100644
@@ -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)
--
Quoted 2 lines

2.39.2

--
With Best Regards,
Andy Shevchenko

Reviewed-by on v1 1/1
#3 lore raw
In reply to Bartosz Golaszewski
Quoted 7 lines · Bartosz Golaszewski

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.

Obviously correct.

Yours,
Linus Walleij