Skip to content

Commit 9d9c179

Browse files
author
Bartosz Golaszewski
committed
gpio: sim: lock GPIOs as interrupts when they are requested
Use the extended irq_sim interface to supply the simulated interrupt domain with callbacks allowing the GPIO sim to lock/unlock GPIOs requested as interrupts. Reviewed-by: Linus Walleij <[email protected]> Acked-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 011f583 commit 9d9c179

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

drivers/gpio/gpio-sim.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,27 @@ static void gpio_sim_free(struct gpio_chip *gc, unsigned int offset)
227227
}
228228
}
229229

230+
static int gpio_sim_irq_requested(struct irq_domain *domain,
231+
irq_hw_number_t hwirq, void *data)
232+
{
233+
struct gpio_sim_chip *chip = data;
234+
235+
return gpiochip_lock_as_irq(&chip->gc, hwirq);
236+
}
237+
238+
static void gpio_sim_irq_released(struct irq_domain *domain,
239+
irq_hw_number_t hwirq, void *data)
240+
{
241+
struct gpio_sim_chip *chip = data;
242+
243+
gpiochip_unlock_as_irq(&chip->gc, hwirq);
244+
}
245+
246+
static const struct irq_sim_ops gpio_sim_irq_sim_ops = {
247+
.irq_sim_irq_requested = gpio_sim_irq_requested,
248+
.irq_sim_irq_released = gpio_sim_irq_released,
249+
};
250+
230251
static void gpio_sim_dbg_show(struct seq_file *seq, struct gpio_chip *gc)
231252
{
232253
struct gpio_sim_chip *chip = gpiochip_get_data(gc);
@@ -443,7 +464,9 @@ static int gpio_sim_add_bank(struct fwnode_handle *swnode, struct device *dev)
443464
if (!chip->pull_map)
444465
return -ENOMEM;
445466

446-
chip->irq_sim = devm_irq_domain_create_sim(dev, swnode, num_lines);
467+
chip->irq_sim = devm_irq_domain_create_sim_full(dev, swnode, num_lines,
468+
&gpio_sim_irq_sim_ops,
469+
chip);
447470
if (IS_ERR(chip->irq_sim))
448471
return PTR_ERR(chip->irq_sim);
449472

0 commit comments

Comments
 (0)