diff mbox series

[v6,1/7] irq/irq_sim: add irq_set_type() callback

Message ID 20190219160650.9614-2-brgl@bgdev.pl
State New
Headers show
Series gpio: mockup: improve the user-space testing interface | expand

Commit Message

Bartosz Golaszewski Feb. 19, 2019, 4:06 p.m. UTC
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Implement the irq_set_type() callback and call irqd_set_trigger_type()
internally so that users interested in the configured trigger type can
later retrieve it using irqd_get_trigger_type(). We only support edge
trigger types.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 kernel/irq/irq_sim.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Marc Zyngier Feb. 19, 2019, 4:14 p.m. UTC | #1
On Tue, 19 Feb 2019 17:06:44 +0100
Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> Implement the irq_set_type() callback and call irqd_set_trigger_type()
> internally so that users interested in the configured trigger type can
> later retrieve it using irqd_get_trigger_type(). We only support edge
> trigger types.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  kernel/irq/irq_sim.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c
> index 98a20e1594ce..b992f88c5613 100644
> --- a/kernel/irq/irq_sim.c
> +++ b/kernel/irq/irq_sim.c
> @@ -25,10 +25,22 @@ static void irq_sim_irqunmask(struct irq_data *data)
>  	irq_ctx->enabled = true;
>  }
>  
> +static int irq_sim_set_type(struct irq_data *data, unsigned int type)
> +{
> +	/* We only support rising and falling edge trigger types. */
> +	if (type & ~IRQ_TYPE_EDGE_BOTH)
> +		return -EINVAL;
> +
> +	irqd_set_trigger_type(data, type);
> +
> +	return 0;
> +}
> +
>  static struct irq_chip irq_sim_irqchip = {
>  	.name		= "irq_sim",
>  	.irq_mask	= irq_sim_irqmask,
>  	.irq_unmask	= irq_sim_irqunmask,
> +	.irq_set_type	= irq_sim_set_type,
>  };
>  
>  static void irq_sim_handle_irq(struct irq_work *work)

Acked-by: Marc Zyngier <marc.zyngier@arm.com>

	M.
Bartosz Golaszewski Feb. 19, 2019, 4:36 p.m. UTC | #2
wt., 19 lut 2019 o 17:14 Marc Zyngier <marc.zyngier@arm.com> napisaƂ(a):
>
> On Tue, 19 Feb 2019 17:06:44 +0100
> Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > Implement the irq_set_type() callback and call irqd_set_trigger_type()
> > internally so that users interested in the configured trigger type can
> > later retrieve it using irqd_get_trigger_type(). We only support edge
> > trigger types.
> >
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > ---
> >  kernel/irq/irq_sim.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c
> > index 98a20e1594ce..b992f88c5613 100644
> > --- a/kernel/irq/irq_sim.c
> > +++ b/kernel/irq/irq_sim.c
> > @@ -25,10 +25,22 @@ static void irq_sim_irqunmask(struct irq_data *data)
> >       irq_ctx->enabled = true;
> >  }
> >
> > +static int irq_sim_set_type(struct irq_data *data, unsigned int type)
> > +{
> > +     /* We only support rising and falling edge trigger types. */
> > +     if (type & ~IRQ_TYPE_EDGE_BOTH)
> > +             return -EINVAL;
> > +
> > +     irqd_set_trigger_type(data, type);
> > +
> > +     return 0;
> > +}
> > +
> >  static struct irq_chip irq_sim_irqchip = {
> >       .name           = "irq_sim",
> >       .irq_mask       = irq_sim_irqmask,
> >       .irq_unmask     = irq_sim_irqunmask,
> > +     .irq_set_type   = irq_sim_set_type,
> >  };
> >
> >  static void irq_sim_handle_irq(struct irq_work *work)
>
> Acked-by: Marc Zyngier <marc.zyngier@arm.com>
>

Thanks you! If you don't mind, I'll send this together with other
patches directly to Linus Walleij.

Bartosz
diff mbox series

Patch

diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c
index 98a20e1594ce..b992f88c5613 100644
--- a/kernel/irq/irq_sim.c
+++ b/kernel/irq/irq_sim.c
@@ -25,10 +25,22 @@  static void irq_sim_irqunmask(struct irq_data *data)
 	irq_ctx->enabled = true;
 }
 
+static int irq_sim_set_type(struct irq_data *data, unsigned int type)
+{
+	/* We only support rising and falling edge trigger types. */
+	if (type & ~IRQ_TYPE_EDGE_BOTH)
+		return -EINVAL;
+
+	irqd_set_trigger_type(data, type);
+
+	return 0;
+}
+
 static struct irq_chip irq_sim_irqchip = {
 	.name		= "irq_sim",
 	.irq_mask	= irq_sim_irqmask,
 	.irq_unmask	= irq_sim_irqunmask,
+	.irq_set_type	= irq_sim_set_type,
 };
 
 static void irq_sim_handle_irq(struct irq_work *work)