linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Yangtao Li <frank.li@vivo.com>
Cc: miquel.raynal@bootlin.com, rafael@kernel.org,
	daniel.lezcano@linaro.org, amitk@kernel.org, rui.zhang@intel.com,
	mmayer@broadcom.com, bcm-kernel-feedback-list@broadcom.com,
	florian.fainelli@broadcom.com, shawnguo@kernel.org,
	s.hauer@pengutronix.de, kernel@pengutronix.de,
	festevam@gmail.com, linux-imx@nxp.com, agross@kernel.org,
	andersson@kernel.org, konrad.dybcio@linaro.org,
	thara.gopinath@gmail.com, heiko@sntech.de,
	mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com,
	thierry.reding@gmail.com, jonathanh@nvidia.com,
	tglx@linutronix.de, matthias.bgg@gmail.com,
	angelogioacchino.delregno@collabora.com,
	srinivas.pandruvada@linux.intel.com,
	DLG-Adam.Ward.opensource@dm.renesas.com,
	shangxiaojing@huawei.com, bchihi@baylibre.com,
	wenst@chromium.org, hayashi.kunihiko@socionext.com,
	niklas.soderlund+renesas@ragnatech.se, chi.minghao@zte.com.cn,
	johan+linaro@kernel.org, jernej.skrabec@gmail.com,
	linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq()
Date: Tue, 27 Jun 2023 13:00:25 +0200	[thread overview]
Message-ID: <20230627110025.vgtplc6nluiiuvoh@pengutronix.de> (raw)
In-Reply-To: <20230627101215.58798-1-frank.li@vivo.com>

[-- Attachment #1: Type: text/plain, Size: 2270 bytes --]

Hello,

On Tue, Jun 27, 2023 at 06:12:01PM +0800, Yangtao Li wrote:
> Ensure that all error handling branches print error information. In this
> way, when this function fails, the upper-layer functions can directly
> return an error code without missing debugging information. Otherwise,
> the error message will be printed redundantly or missing.
> 
> There are more than 700 calls to the devm_request_threaded_irq method.
> Most drivers only request one interrupt resource, and these error
> messages are basically the same. If error messages are printed
> everywhere, more than 1000 lines of code can be saved by removing the
> msg in the driver.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  kernel/irq/devres.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
> index f6e5515ee077..fcb946ffb7ec 100644
> --- a/kernel/irq/devres.c
> +++ b/kernel/irq/devres.c
> @@ -58,8 +58,10 @@ int devm_request_threaded_irq(struct device *dev, unsigned int irq,
>  
>  	dr = devres_alloc(devm_irq_release, sizeof(struct irq_devres),
>  			  GFP_KERNEL);
> -	if (!dr)
> +	if (!dr) {
> +		dev_err(dev, "Failed to allocate device resource data\n");
>  		return -ENOMEM;
> +	}
>  
>  	if (!devname)
>  		devname = dev_name(dev);
> @@ -67,6 +69,7 @@ int devm_request_threaded_irq(struct device *dev, unsigned int irq,
>  	rc = request_threaded_irq(irq, handler, thread_fn, irqflags, devname,
>  				  dev_id);
>  	if (rc) {
> +		dev_err_probe(dev, rc, "Failed to request threaded irq%d: %d\n", irq, rc);

This changes semantics because dev_err_probe() is only supposed to be
called in probe functions. Not sure about devm_request_threaded_irq, but
its friend request_irq is called in the setup_irq (or open IIRC)
callback of serial drivers.

While I assume changing to dev_err_probe is a result of my concern that
no error should be printed when rc=-EPROBEDEFER, my other concern that
adding an error message to a generic allocation function is a bad idea
still stands.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2023-06-27 11:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 10:12 [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq() Yangtao Li
2023-06-27 10:12 ` [PATCH v2 02/15] thermal/drivers/armada: remove redundant msg Yangtao Li
2023-06-27 10:12 ` [PATCH v2 03/15] thermal/drivers/brcmstb_thermal: " Yangtao Li
2023-06-27 10:12 ` [PATCH v2 04/15] thermal/drivers/db8500: " Yangtao Li
2023-06-27 10:12 ` [PATCH v2 05/15] thermal/drivers/hisi: " Yangtao Li
2023-06-27 10:12 ` [PATCH v2 06/15] thermal/drivers/imx: " Yangtao Li
2023-06-27 10:12 ` [PATCH v2 07/15] thermal/drivers/qcom: " Yangtao Li
2023-06-27 10:12 ` [PATCH v2 08/15] thermal/drivers/tegra-soctherm: " Yangtao Li
2023-06-27 10:12 ` [PATCH v2 09/15] thermal/drivers/maxim: " Yangtao Li
2023-06-27 10:12 ` [PATCH v2 10/15] thermal/drivers/int340x: " Yangtao Li
2023-06-27 10:12 ` [PATCH v2 11/15] thermal/drivers/intel: " Yangtao Li
2023-06-27 10:12 ` [PATCH v2 12/15] thermal/drivers/stm: " Yangtao Li
2023-06-27 10:12 ` [PATCH v2 13/15] thermal/drivers/rockchip: " Yangtao Li
2023-06-27 10:12 ` [PATCH v2 14/15] thermal/drivers/tegra: " Yangtao Li
2023-06-27 10:12 ` [PATCH v2 15/15] thermal/drivers/mediatek/lvts_thermal: " Yangtao Li
2023-06-27 10:28 ` [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq() Krzysztof Kozlowski
2023-06-27 11:00 ` Uwe Kleine-König [this message]
2023-06-30 11:11   ` Thomas Gleixner
2023-07-03  9:13     ` Yangtao Li
2023-07-03  9:53       ` Uwe Kleine-König
2023-07-03 11:37         ` Yangtao Li
2023-07-03 12:15     ` Yangtao Li
2023-07-03 12:19     ` Yangtao Li
     [not found]     ` <247a8166-f131-2d07-ec2b-479a4c19297f@vivo.com>
2023-07-03 12:28       ` Krzysztof Kozlowski
2023-07-03 16:07 ` Ahmad Fatoum

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=20230627110025.vgtplc6nluiiuvoh@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=DLG-Adam.Ward.opensource@dm.renesas.com \
    --cc=agross@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=amitk@kernel.org \
    --cc=andersson@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=bchihi@baylibre.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=chi.minghao@zte.com.cn \
    --cc=daniel.lezcano@linaro.org \
    --cc=festevam@gmail.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=frank.li@vivo.com \
    --cc=hayashi.kunihiko@socionext.com \
    --cc=heiko@sntech.de \
    --cc=jernej.skrabec@gmail.com \
    --cc=johan+linaro@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=kernel@pengutronix.de \
    --cc=konrad.dybcio@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=mmayer@broadcom.com \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shangxiaojing@huawei.com \
    --cc=shawnguo@kernel.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=thara.gopinath@gmail.com \
    --cc=thierry.reding@gmail.com \
    --cc=wenst@chromium.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 NNTP newsgroup(s).