SOC Archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: "Marek Behún" <kabel@kernel.org>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
	"Gregory CLEMENT" <gregory.clement@bootlin.com>,
	soc@kernel.org, arm@kernel.org,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Matti Vaittinen" <mazziesaccount@gmail.com>,
	"Horia Geantă" <horia.geanta@nxp.com>,
	"Pankaj Gupta" <pankaj.gupta@nxp.com>,
	"Gaurav Jain" <gaurav.jain@nxp.com>,
	linux-crypto@vger.kernel.org,
	"Herbert Xu" <herbert@gondor.apana.org.au>
Subject: Re: [PATCH v5 06/11] devm-helpers: Add resource managed version of irq_create_mapping()
Date: Tue, 26 Mar 2024 12:00:25 +0300	[thread overview]
Message-ID: <72bf31c3-337d-4747-8353-639492507a7b@moroto.mountain> (raw)
In-Reply-To: <20240323164359.21642-7-kabel@kernel.org>

On Sat, Mar 23, 2024 at 05:43:54PM +0100, Marek Behún wrote:
> +/**
> + * devm_irq_create_mapping - Resource managed version of irq_create_mapping()
> + * @dev:	Device which lifetime the mapping is bound to
> + * @domain:	domain owning this hardware interrupt or NULL for default domain
> + * @hwirq:	hardware irq number in that domain space
> + *
> + * Create an irq mapping to linux irq space which is automatically disposed when
> + * the driver is detached.
> + * devm_irq_create_mapping() can be used to omit the explicit
> + * irq_dispose_mapping() call when driver is detached.
> + *
> + * Returns a linux irq number on success, 0 if mapping could not be created, or
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> + * a negative error number if devm action could not be added.
> + */
> +static inline int devm_irq_create_mapping(struct device *dev,
> +					  struct irq_domain *domain,
> +					  irq_hw_number_t hwirq)
> +{
> +	unsigned int virq = irq_create_mapping(domain, hwirq);
> +
> +	if (!virq)
> +		return 0;

What is the point of returning zero instead of an error code?  Neither
of the callers that are introduced later in the patchset use this.

I understand that it matches some of the other legacy irq function
behaviors, but I think we are trying to move away from that because it
just leads to bugs.

Since we don't need the zero now, let's wait until we have a user before
introducing this behavior.  Then we can add a new function that returns
zero, but we'll still encourage people to use the standard error code
function where possible.  And at the same time, when we do introduce the
zero is an error code, function you should contact
kernel-janitors@vger.kernel.org so someone an write a static checker
rule to detect the bugs that result from it.

regards,
dan carpenter

> +
> +	/*
> +	 * irq_dispose_mapping() is an empty function if CONFIG_IRQ_DOMAIN is
> +	 * disabled. No need to register an action in that case.
> +	 */
> +	if (IS_ENABLED(CONFIG_IRQ_DOMAIN)) {
> +		int err;
> +
> +		err = devm_add_action_or_reset(dev, devm_irq_mapping_drop,
> +					       (void *)(unsigned long)virq);
> +		if (err)
> +			return err;
> +	}
> +
> +	return virq;
> +}
> +
>  #endif
> -- 
> 2.43.2
> 

  parent reply	other threads:[~2024-03-26  9:00 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-23 16:43 [PATCH v5 00/11] Turris Omnia MCU driver Marek Behún
2024-03-23 16:43 ` [PATCH v5 01/11] dt-bindings: arm: add cznic,turris-omnia-mcu binding Marek Behún
2024-03-26  8:45   ` Krzysztof Kozlowski
2024-03-26  9:02     ` Marek Behún
2024-03-23 16:43 ` [PATCH v5 02/11] platform: cznic: Add preliminary support for Turris Omnia MCU Marek Behún
2024-03-24 11:01   ` Andy Shevchenko
2024-03-24 15:04     ` Marek Behún
2024-03-24 15:30       ` Andy Shevchenko
2024-03-25 10:39         ` Marek Behún
2024-04-02 16:41         ` Marek Behún
2024-03-23 16:43 ` [PATCH v5 03/11] platform: cznic: turris-omnia-mcu: Add support for MCU connected GPIOs Marek Behún
2024-03-25  9:10   ` Matti Vaittinen
2024-03-25  9:53     ` Marek Behún
2024-03-25 10:25       ` Matti Vaittinen
2024-04-02  9:59   ` Dan Carpenter
2024-03-23 16:43 ` [PATCH v5 04/11] platform: cznic: turris-omnia-mcu: Add support for poweroff and wakeup Marek Behún
2024-03-23 16:43 ` [PATCH v5 05/11] platform: cznic: turris-omnia-mcu: Add support for MCU watchdog Marek Behún
2024-03-23 16:43 ` [PATCH v5 06/11] devm-helpers: Add resource managed version of irq_create_mapping() Marek Behún
2024-03-25  9:40   ` Matti Vaittinen
2024-03-25  9:57     ` Marek Behún
2024-03-26  9:00   ` Dan Carpenter [this message]
2024-03-27  9:34     ` Marek Behún
2024-03-27 11:39       ` Dan Carpenter
2024-03-23 16:43 ` [PATCH v5 07/11] platform: cznic: turris-omnia-mcu: Add support for MCU provided TRNG Marek Behún
2024-03-23 16:43 ` [PATCH v5 08/11] devm-helpers: Add resource managed version of debugfs directory create function Marek Behún
2024-03-23 17:21   ` Guenter Roeck
2024-03-23 16:43 ` [PATCH v5 09/11] platform: cznic: turris-omnia-mcu: Add support for digital message signing via debugfs Marek Behún
2024-03-23 16:43 ` [PATCH v5 10/11] ARM: dts: turris-omnia: Add MCU system-controller node Marek Behún
2024-03-23 16:43 ` [PATCH v5 11/11] ARM: dts: turris-omnia: Add GPIO key node for front button Marek Behún
     [not found] ` <20240323164359.21642-9-kabel__6885.49310886941$1711212291$gmane$org@kernel.org>
2024-03-23 21:10   ` [PATCH v5 08/11] devm-helpers: Add resource managed version of debugfs directory create function Christophe JAILLET
2024-03-23 21:25     ` Marek Behún
2024-03-24  9:21       ` Christophe JAILLET
2024-03-24 15:08         ` Marek Behún
2024-03-25 11:05     ` Dan Carpenter

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=72bf31c3-337d-4747-8353-639492507a7b@moroto.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=arm@kernel.org \
    --cc=arnd@arndb.de \
    --cc=gaurav.jain@nxp.com \
    --cc=gregory.clement@bootlin.com \
    --cc=hdegoede@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=horia.geanta@nxp.com \
    --cc=kabel@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=pankaj.gupta@nxp.com \
    --cc=soc@kernel.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).