From: Jonathan Cameron <jic23@kernel.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Marc Zyngier <marc.zyngier@arm.com>,
Jonathan Corbet <corbet@lwn.net>,
Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>,
Lars-Peter Clausen <lars@metafoo.de>,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: Re: [PATCH v2 2/3] irq/irq_sim: add a devres variant of irq_sim_init()
Date: Sat, 12 Aug 2017 12:47:34 +0100 [thread overview]
Message-ID: <20170812124513.0e6d91f9@archlinux> (raw)
In-Reply-To: <20170801145028.7558-3-brgl@bgdev.pl>
On Tue, 1 Aug 2017 16:50:27 +0200
Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> Add a resource managed version of irq_sim_init(). This can be
> conveniently used in device drivers.
>
> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Looks pretty standard to me.
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> Documentation/driver-model/devres.txt | 1 +
> include/linux/irq_sim.h | 4 ++++
> kernel/irq_sim.c | 43 +++++++++++++++++++++++++++++++++++
> 3 files changed, 48 insertions(+)
>
> diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
> index 30e04f7a690d..69f08c0f23a8 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 0c1abf0e3244..94c4bfc9b7a9 100644
> --- a/include/linux/irq_sim.h
> +++ b/include/linux/irq_sim.h
> @@ -9,6 +9,7 @@
> #define _LINUX_IRQ_SIM_H
>
> #include <linux/irq_work.h>
> +#include <linux/device.h>
>
> struct irq_sim_work_ctx {
> struct irq_work work;
> @@ -30,6 +31,9 @@ struct irq_sim {
> int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs);
> void irq_sim_fini(struct irq_sim *sim);
>
> +int devm_irq_sim_init(struct device *dev,
> + struct irq_sim *sim, unsigned int num_irqs);
> +
> 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_sim.c b/kernel/irq_sim.c
> index 4387e2bee97c..92686c0c7790 100644
> --- a/kernel/irq_sim.c
> +++ b/kernel/irq_sim.c
> @@ -90,6 +90,49 @@ void irq_sim_fini(struct irq_sim *sim)
> }
> EXPORT_SYMBOL_GPL(irq_sim_fini);
>
> +struct irq_sim_devres {
> + struct irq_sim *sim;
> +};
> +
> +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.
> *
next prev parent reply other threads:[~2017-08-12 11:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-01 14:50 [PATCH v2 0/3] simulated interrupts Bartosz Golaszewski
2017-08-01 14:50 ` [PATCH v2 1/3] irq/irq_sim: add a simple interrupt simulator framework Bartosz Golaszewski
2017-08-12 11:43 ` Jonathan Cameron
2017-08-14 9:54 ` Bartosz Golaszewski
2017-08-14 10:04 ` Jonathan Cameron
2017-08-01 14:50 ` [PATCH v2 2/3] irq/irq_sim: add a devres variant of irq_sim_init() Bartosz Golaszewski
2017-08-12 11:47 ` Jonathan Cameron [this message]
2017-08-01 14:50 ` [PATCH v2 3/3] gpio: mockup: use irq_sim Bartosz Golaszewski
2017-08-12 11:46 ` Jonathan Cameron
2017-08-13 12:16 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170812124513.0e6d91f9@archlinux \
--to=jic23@kernel.org \
--cc=bamvor.zhangjian@linaro.org \
--cc=brgl@bgdev.pl \
--cc=corbet@lwn.net \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.