mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 05:32:00 +00:00
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 <linus.walleij@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20240624093934.17089-3-brgl@bgdev.pl Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
011f583781
commit
9d9c1796a6
@ -227,6 +227,27 @@ static void gpio_sim_free(struct gpio_chip *gc, unsigned int offset)
|
||||
}
|
||||
}
|
||||
|
||||
static int gpio_sim_irq_requested(struct irq_domain *domain,
|
||||
irq_hw_number_t hwirq, void *data)
|
||||
{
|
||||
struct gpio_sim_chip *chip = data;
|
||||
|
||||
return gpiochip_lock_as_irq(&chip->gc, hwirq);
|
||||
}
|
||||
|
||||
static void gpio_sim_irq_released(struct irq_domain *domain,
|
||||
irq_hw_number_t hwirq, void *data)
|
||||
{
|
||||
struct gpio_sim_chip *chip = data;
|
||||
|
||||
gpiochip_unlock_as_irq(&chip->gc, hwirq);
|
||||
}
|
||||
|
||||
static const struct irq_sim_ops gpio_sim_irq_sim_ops = {
|
||||
.irq_sim_irq_requested = gpio_sim_irq_requested,
|
||||
.irq_sim_irq_released = gpio_sim_irq_released,
|
||||
};
|
||||
|
||||
static void gpio_sim_dbg_show(struct seq_file *seq, struct gpio_chip *gc)
|
||||
{
|
||||
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)
|
||||
if (!chip->pull_map)
|
||||
return -ENOMEM;
|
||||
|
||||
chip->irq_sim = devm_irq_domain_create_sim(dev, swnode, num_lines);
|
||||
chip->irq_sim = devm_irq_domain_create_sim_full(dev, swnode, num_lines,
|
||||
&gpio_sim_irq_sim_ops,
|
||||
chip);
|
||||
if (IS_ERR(chip->irq_sim))
|
||||
return PTR_ERR(chip->irq_sim);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user