linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Bartosz Golaszewski" <bgolaszewski@baylibre.com>
Subject: Re: [PATCH v3 1/7] irq/irq_sim: provide irq_sim_get_type()
Date: Thu, 14 Feb 2019 10:27:17 +0000	[thread overview]
Message-ID: <86tvh6sm0q.wl-marc.zyngier@arm.com> (raw)
In-Reply-To: <20190212131600.18960-2-brgl@bgdev.pl>

On Tue, 12 Feb 2019 13:15:54 +0000,
Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> 
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> Provide a helper that allows users to retrieve the current irq type
> of dummy interrupts.
> 
> Internally: store the type in the line context when the irq_set_type()
> callback is called.
> 
> This is required by the gpio-mockup module which wants to track the
> state of GPIO lines and simulate rising and falling edge interrupts.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  include/linux/irq_sim.h |  2 ++
>  kernel/irq/irq_sim.c    | 23 +++++++++++++++++++++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/include/linux/irq_sim.h b/include/linux/irq_sim.h
> index 4500d453a63e..c73be0a2c15c 100644
> --- a/include/linux/irq_sim.h
> +++ b/include/linux/irq_sim.h
> @@ -22,6 +22,7 @@ struct irq_sim_work_ctx {
>  struct irq_sim_irq_ctx {
>  	int			irqnum;
>  	bool			enabled;
> +	int			type;
>  };
>  
>  struct irq_sim {
> @@ -37,5 +38,6 @@ int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
>  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);
> +unsigned int irq_sim_get_type(struct irq_sim *sim, unsigned int offset);
>  
>  #endif /* _LINUX_IRQ_SIM_H */
> diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c
> index 98a20e1594ce..74561a0dca65 100644
> --- a/kernel/irq/irq_sim.c
> +++ b/kernel/irq/irq_sim.c
> @@ -25,10 +25,20 @@ 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)
> +{
> +	struct irq_sim_irq_ctx *irq_ctx = irq_data_get_irq_chip_data(data);
> +
> +	irq_ctx->type = type;
> +
> +	return 0;
> +}

In the cover letter, you say you only support edge. And yet you don't
reject any of the level configuration. That's not right.

> +
>  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)
> @@ -180,3 +190,16 @@ int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset)
>  	return sim->irqs[offset].irqnum;
>  }
>  EXPORT_SYMBOL_GPL(irq_sim_irqnum);
> +
> +/**
> + * irq_sim_get_type - Get the type configuration for a dummy interrupt.
> + *
> + * @sim:        The interrupt simulator object.
> + * @offset:     Offset of the simulated interrupt for which to retrieve
> + *              the type.
> + */
> +unsigned int irq_sim_get_type(struct irq_sim *sim, unsigned int offset)
> +{
> +	return sim->irqs[offset].type;
> +}
> +EXPORT_SYMBOL_GPL(irq_sim_get_type);

This just shows that the way you have architected the whole thing is
backward. The irq_set_type callback should push the configuration
wherever it makes sense instead of offering a retrieving API exposing
random bits of the data structures.

Thanks,

	M.

-- 
Jazz is not dead, it just smell funny.

  reply	other threads:[~2019-02-14 10:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12 13:15 [PATCH v3 0/7] gpio: mockup: improve the user-space testing interface Bartosz Golaszewski
2019-02-12 13:15 ` [PATCH v3 1/7] irq/irq_sim: provide irq_sim_get_type() Bartosz Golaszewski
2019-02-14 10:27   ` Marc Zyngier [this message]
2019-02-12 13:15 ` [PATCH v3 2/7] gpio: mockup: add locking Bartosz Golaszewski
2019-02-12 13:15 ` [PATCH v3 3/7] gpio: mockup: implement get_multiple() Bartosz Golaszewski
2019-02-12 13:15 ` [PATCH v3 4/7] gpio: mockup: don't create the debugfs link named after the label Bartosz Golaszewski
2019-02-12 13:15 ` [PATCH v3 5/7] gpio: mockup: change the type of 'offset' to unsigned int Bartosz Golaszewski
2019-02-12 13:15 ` [PATCH v3 6/7] gpio: mockup: change the signature of unlocked get/set helpers Bartosz Golaszewski
2019-02-12 13:16 ` [PATCH v3 7/7] gpio: mockup: rework debugfs interface Bartosz Golaszewski

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=86tvh6sm0q.wl-marc.zyngier@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=u.kleine-koenig@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).