[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240624093934.17089-3-brgl@bgdev.pl>
Date: Mon, 24 Jun 2024 11:39:33 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Linus Walleij <linus.walleij@...aro.org>,
Thomas Gleixner <tglx@...utronix.de>
Cc: linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: [PATCH v2 2/2] gpio: sim: lock GPIOs as interrupts when they are requested
From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
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.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
---
drivers/gpio/gpio-sim.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index 4157735ea791..dcca1d7f173e 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -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);
--
2.43.0
Powered by blists - more mailing lists