[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-44e72c7ebf294043cfe276f7328b8c0e6a3e50e9@git.kernel.org>
Date: Wed, 16 Aug 2017 07:46:27 -0700
From: tip-bot for Bartosz Golaszewski <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: brgl@...ev.pl, bamvor.zhangjian@...aro.org, lars@...afoo.de,
marc.zyngier@....com, hpa@...or.com, linus.walleij@...aro.org,
linux-kernel@...r.kernel.org, corbet@....net, jic23@...nel.org,
Jonathan.Cameron@...wei.com, mingo@...nel.org, tglx@...utronix.de
Subject: [tip:irq/core] genirq/irq_sim: Add a devres variant of
irq_sim_init()
Commit-ID: 44e72c7ebf294043cfe276f7328b8c0e6a3e50e9
Gitweb: http://git.kernel.org/tip/44e72c7ebf294043cfe276f7328b8c0e6a3e50e9
Author: Bartosz Golaszewski <brgl@...ev.pl>
AuthorDate: Mon, 14 Aug 2017 16:53:17 +0200
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitDate: Wed, 16 Aug 2017 16:40:02 +0200
genirq/irq_sim: Add a devres variant of irq_sim_init()
Add a resource managed version of irq_sim_init(). This can be
conveniently used in device drivers.
Signed-off-by: Bartosz Golaszewski <brgl@...ev.pl>
Acked-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: Lars-Peter Clausen <lars@...afoo.de>
Cc: Jonathan Corbet <corbet@....net>
Cc: Marc Zyngier <marc.zyngier@....com>
Cc: Linus Walleij <linus.walleij@...aro.org>
Cc: linux-doc@...r.kernel.org
Cc: linux-gpio@...r.kernel.org
Cc: Bamvor Jian Zhang <bamvor.zhangjian@...aro.org>
Cc: Jonathan Cameron <jic23@...nel.org>
Link: http://lkml.kernel.org/r/20170814145318.6495-3-brgl@bgdev.pl
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
---
Documentation/driver-model/devres.txt | 1 +
include/linux/irq_sim.h | 3 +++
kernel/irq/irq_sim.c | 43 +++++++++++++++++++++++++++++++++++
3 files changed, 47 insertions(+)
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 30e04f7..69f08c0 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -312,6 +312,7 @@ IRQ
devm_irq_alloc_descs_from()
devm_irq_alloc_generic_chip()
devm_irq_setup_generic_chip()
+ devm_irq_sim_init()
LED
devm_led_classdev_register()
diff --git a/include/linux/irq_sim.h b/include/linux/irq_sim.h
index 39ce57b..0380d89 100644
--- a/include/linux/irq_sim.h
+++ b/include/linux/irq_sim.h
@@ -10,6 +10,7 @@
*/
#include <linux/irq_work.h>
+#include <linux/device.h>
/*
* Provides a framework for allocating simulated interrupts which can be
@@ -34,6 +35,8 @@ struct irq_sim {
};
int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs);
+int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
+ unsigned int num_irqs);
void irq_sim_fini(struct irq_sim *sim);
void irq_sim_fire(struct irq_sim *sim, unsigned int offset);
int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset);
diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c
index 31a2c12..24caabf 100644
--- a/kernel/irq/irq_sim.c
+++ b/kernel/irq/irq_sim.c
@@ -10,6 +10,10 @@
#include <linux/irq_sim.h>
#include <linux/irq.h>
+struct irq_sim_devres {
+ struct irq_sim *sim;
+};
+
static void irq_sim_irqmask(struct irq_data *data)
{
struct irq_sim_irq_ctx *irq_ctx = irq_data_get_irq_chip_data(data);
@@ -92,6 +96,45 @@ void irq_sim_fini(struct irq_sim *sim)
}
EXPORT_SYMBOL_GPL(irq_sim_fini);
+static void devm_irq_sim_release(struct device *dev, void *res)
+{
+ struct irq_sim_devres *this = res;
+
+ irq_sim_fini(this->sim);
+}
+
+/**
+ * irq_sim_init - Initialize the interrupt simulator for a managed device.
+ *
+ * @dev: Device to initialize the simulator object for.
+ * @sim: The interrupt simulator object to initialize.
+ * @num_irqs: Number of interrupts to allocate
+ *
+ * Returns 0 on success and a negative error number on failure.
+ */
+int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
+ unsigned int num_irqs)
+{
+ struct irq_sim_devres *dr;
+ int rv;
+
+ dr = devres_alloc(devm_irq_sim_release, sizeof(*dr), GFP_KERNEL);
+ if (!dr)
+ return -ENOMEM;
+
+ rv = irq_sim_init(sim, num_irqs);
+ if (rv) {
+ devres_free(dr);
+ return rv;
+ }
+
+ dr->sim = sim;
+ devres_add(dev, dr);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(devm_irq_sim_init);
+
/**
* irq_sim_fire - Enqueue an interrupt.
*
Powered by blists - more mailing lists