* [PATCH v4 02/21] thermal/drivers/sun8i: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-11 17:57 ` Jernej Škrabec
2023-07-10 9:59 ` [PATCH v4 03/21] thermal/drivers/armada: " Yangtao Li
` (18 subsequent siblings)
19 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Vasily Khoruzhick, Yangtao Li, Rafael J. Wysocki, Daniel Lezcano,
Amit Kucheria, Zhang Rui, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-arm-kernel,
linux-sunxi, linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/sun8i_thermal.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c
index 195f3c5d0b38..a952804ff993 100644
--- a/drivers/thermal/sun8i_thermal.c
+++ b/drivers/thermal/sun8i_thermal.c
@@ -512,9 +512,9 @@ static int sun8i_ths_probe(struct platform_device *pdev)
* registered yet, we deffer the registration of the interrupt to
* the end.
*/
- ret = devm_request_threaded_irq(dev, irq, NULL,
- sun8i_irq_thread,
- IRQF_ONESHOT, "ths", tmdev);
+ ret = devm_request_threaded_irq_probe(dev, irq, NULL,
+ sun8i_irq_thread,
+ IRQF_ONESHOT, "ths", tmdev, NULL);
if (ret)
return ret;
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 03/21] thermal/drivers/armada: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
2023-07-10 9:59 ` [PATCH v4 02/21] thermal/drivers/sun8i: convert to use devm_request*_irq_probe() Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 9:59 ` [PATCH v4 04/21] thermal/drivers/broadcom: " Yangtao Li
` (17 subsequent siblings)
19 siblings, 0 replies; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Miquel Raynal, Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria,
Zhang Rui
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/thermal/armada_thermal.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index 9f6dc4fc9112..b7f549b6f825 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -913,15 +913,12 @@ static int armada_thermal_probe(struct platform_device *pdev)
/* The overheat interrupt feature is not mandatory */
if (irq > 0) {
- ret = devm_request_threaded_irq(&pdev->dev, irq,
- armada_overheat_isr,
- armada_overheat_isr_thread,
- 0, NULL, priv);
- if (ret) {
- dev_err(&pdev->dev, "Cannot request threaded IRQ %d\n",
- irq);
+ ret = devm_request_threaded_irq_probe(&pdev->dev, irq,
+ armada_overheat_isr,
+ armada_overheat_isr_thread,
+ 0, NULL, priv, NULL);
+ if (ret)
return ret;
- }
}
/*
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 04/21] thermal/drivers/broadcom: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
2023-07-10 9:59 ` [PATCH v4 02/21] thermal/drivers/sun8i: convert to use devm_request*_irq_probe() Yangtao Li
2023-07-10 9:59 ` [PATCH v4 03/21] thermal/drivers/armada: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 9:59 ` [PATCH v4 05/21] thermal/drivers/tegra: " Yangtao Li
` (16 subsequent siblings)
19 siblings, 0 replies; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Markus Mayer, Broadcom internal kernel review list,
Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Florian Fainelli
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-arm-kernel,
linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/broadcom/brcmstb_thermal.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c
index 72d1dbe60b8f..ea37e7ee688a 100644
--- a/drivers/thermal/broadcom/brcmstb_thermal.c
+++ b/drivers/thermal/broadcom/brcmstb_thermal.c
@@ -349,14 +349,12 @@ static int brcmstb_thermal_probe(struct platform_device *pdev)
irq = platform_get_irq_optional(pdev, 0);
if (irq >= 0) {
- ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
- brcmstb_tmon_irq_thread,
- IRQF_ONESHOT,
- DRV_NAME, priv);
- if (ret < 0) {
- dev_err(&pdev->dev, "could not request IRQ: %d\n", ret);
+ ret = devm_request_threaded_irq_probe(&pdev->dev, irq, NULL,
+ brcmstb_tmon_irq_thread,
+ IRQF_ONESHOT,
+ DRV_NAME, priv, NULL);
+ if (ret < 0)
return ret;
- }
}
dev_info(&pdev->dev, "registered AVS TMON of-sensor driver\n");
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 05/21] thermal/drivers/tegra: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (2 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 04/21] thermal/drivers/broadcom: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 13:16 ` Thierry Reding
2023-07-10 9:59 ` [PATCH v4 06/21] thermal/drivers/db8500: " Yangtao Li
` (15 subsequent siblings)
19 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Thierry Reding, Jonathan Hunter
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-tegra, linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/tegra/soctherm.c | 38 ++++++++++++-------------
drivers/thermal/tegra/tegra30-tsensor.c | 9 +++---
2 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c
index ea66cba09e56..3d144377d90a 100644
--- a/drivers/thermal/tegra/soctherm.c
+++ b/drivers/thermal/tegra/soctherm.c
@@ -1993,29 +1993,27 @@ static int soctherm_interrupts_init(struct platform_device *pdev,
return 0;
}
- ret = devm_request_threaded_irq(&pdev->dev,
- tegra->thermal_irq,
- soctherm_thermal_isr,
- soctherm_thermal_isr_thread,
- IRQF_ONESHOT,
- dev_name(&pdev->dev),
- tegra);
- if (ret < 0) {
- dev_err(&pdev->dev, "request_irq 'thermal_irq' failed.\n");
+ ret = devm_request_threaded_irq_probe(&pdev->dev,
+ tegra->thermal_irq,
+ soctherm_thermal_isr,
+ soctherm_thermal_isr_thread,
+ IRQF_ONESHOT,
+ dev_name(&pdev->dev),
+ tegra,
+ "thermal_irq");
+ if (ret < 0)
return ret;
- }
- ret = devm_request_threaded_irq(&pdev->dev,
- tegra->edp_irq,
- soctherm_edp_isr,
- soctherm_edp_isr_thread,
- IRQF_ONESHOT,
- "soctherm_edp",
- tegra);
- if (ret < 0) {
- dev_err(&pdev->dev, "request_irq 'edp_irq' failed.\n");
+ ret = devm_request_threaded_irq_probe(&pdev->dev,
+ tegra->edp_irq,
+ soctherm_edp_isr,
+ soctherm_edp_isr_thread,
+ IRQF_ONESHOT,
+ "soctherm_edp",
+ tegra,
+ "edp_irq");
+ if (ret < 0)
return ret;
- }
return 0;
}
diff --git a/drivers/thermal/tegra/tegra30-tsensor.c b/drivers/thermal/tegra/tegra30-tsensor.c
index c243e9d76d3c..dd4c2deba93a 100644
--- a/drivers/thermal/tegra/tegra30-tsensor.c
+++ b/drivers/thermal/tegra/tegra30-tsensor.c
@@ -593,12 +593,11 @@ static int tegra_tsensor_probe(struct platform_device *pdev)
return err;
}
- err = devm_request_threaded_irq(&pdev->dev, irq, NULL,
- tegra_tsensor_isr, IRQF_ONESHOT,
- "tegra_tsensor", ts);
+ err = devm_request_threaded_irq_probe(&pdev->dev, irq, NULL,
+ tegra_tsensor_isr, IRQF_ONESHOT,
+ "tegra_tsensor", ts, NULL);
if (err)
- return dev_err_probe(&pdev->dev, err,
- "failed to request interrupt\n");
+ return err;
return 0;
}
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 06/21] thermal/drivers/db8500: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (3 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 05/21] thermal/drivers/tegra: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 11:25 ` Dmitry Baryshkov
2023-07-10 9:59 ` [PATCH v4 07/21] thermal/drivers/rcar: " Yangtao Li
` (14 subsequent siblings)
19 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Andy Gross, Bjorn Andersson, Konrad Dybcio, Thara Gopinath
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-kernel, linux-arm-msm
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/db8500_thermal.c | 16 ++++++----------
drivers/thermal/qcom/lmh.c | 7 +++----
2 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c
index fca5c2c93bf9..0ef8fc2eb4a1 100644
--- a/drivers/thermal/db8500_thermal.c
+++ b/drivers/thermal/db8500_thermal.c
@@ -164,25 +164,21 @@ static int db8500_thermal_probe(struct platform_device *pdev)
if (low_irq < 0)
return low_irq;
- ret = devm_request_threaded_irq(dev, low_irq, NULL,
+ ret = devm_request_threaded_irq_probe(dev, low_irq, NULL,
prcmu_low_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
- "dbx500_temp_low", th);
- if (ret < 0) {
- dev_err(dev, "failed to allocate temp low irq\n");
+ "dbx500_temp_low", th, "temp low");
+ if (ret < 0)
return ret;
- }
high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH");
if (high_irq < 0)
return high_irq;
- ret = devm_request_threaded_irq(dev, high_irq, NULL,
+ ret = devm_request_threaded_irq_probe(dev, high_irq, NULL,
prcmu_high_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
- "dbx500_temp_high", th);
- if (ret < 0) {
- dev_err(dev, "failed to allocate temp high irq\n");
+ "dbx500_temp_high", th, "temp high");
+ if (ret < 0)
return ret;
- }
/* register of thermal sensor and get info from DT */
th->tz = devm_thermal_of_zone_register(dev, 0, th, &thdev_ops);
diff --git a/drivers/thermal/qcom/lmh.c b/drivers/thermal/qcom/lmh.c
index f6edb12ec004..48a14d7e8bf5 100644
--- a/drivers/thermal/qcom/lmh.c
+++ b/drivers/thermal/qcom/lmh.c
@@ -207,11 +207,10 @@ static int lmh_probe(struct platform_device *pdev)
/* Disable the irq and let cpufreq enable it when ready to handle the interrupt */
irq_set_status_flags(lmh_data->irq, IRQ_NOAUTOEN);
- ret = devm_request_irq(dev, lmh_data->irq, lmh_handle_irq,
- IRQF_ONESHOT | IRQF_NO_SUSPEND,
- "lmh-irq", lmh_data);
+ ret = devm_request_irq_probe(dev, lmh_data->irq, lmh_handle_irq,
+ IRQF_ONESHOT | IRQF_NO_SUSPEND,
+ "lmh-irq", lmh_data, NULL);
if (ret) {
- dev_err(dev, "Error %d registering irq %x\n", ret, lmh_data->irq);
irq_domain_remove(lmh_data->domain);
return ret;
}
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 07/21] thermal/drivers/rcar: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (4 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 06/21] thermal/drivers/db8500: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 12:27 ` Geert Uytterhoeven
2023-07-10 9:59 ` [PATCH v4 08/21] thermal/drivers/qcom/temp-alarm: " Yangtao Li
` (13 subsequent siblings)
19 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Niklas Söderlund, Rafael J. Wysocki, Daniel Lezcano,
Amit Kucheria, Zhang Rui
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-renesas-soc, linux-pm,
linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/rcar_thermal.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index b8571f7090aa..56f3983dcd5f 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -446,12 +446,10 @@ static int rcar_thermal_probe(struct platform_device *pdev)
idle = 0; /* polling delay is not needed */
}
- ret = devm_request_irq(dev, irq, rcar_thermal_irq,
- IRQF_SHARED, dev_name(dev), common);
- if (ret) {
- dev_err(dev, "irq request failed\n ");
+ ret = devm_request_irq_probe(dev, irq, rcar_thermal_irq,
+ IRQF_SHARED, dev_name(dev), common, NULL);
+ if (ret)
goto error_unregister;
- }
/* update ENR bits */
if (chip->irq_per_ch)
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 08/21] thermal/drivers/qcom/temp-alarm: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (5 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 07/21] thermal/drivers/rcar: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 11:26 ` Dmitry Baryshkov
2023-07-10 9:59 ` [PATCH v4 09/21] thermal: intel: int340x: processor_thermal: " Yangtao Li
` (12 subsequent siblings)
19 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Amit Kucheria, Thara Gopinath, Andy Gross, Bjorn Andersson,
Konrad Dybcio, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-arm-msm, linux-pm, linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
index 0e8ebfcd84c5..1b4a7eca181e 100644
--- a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
+++ b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
@@ -455,8 +455,8 @@ static int qpnp_tm_probe(struct platform_device *pdev)
devm_thermal_add_hwmon_sysfs(&pdev->dev, chip->tz_dev);
- ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, qpnp_tm_isr,
- IRQF_ONESHOT, node->name, chip);
+ ret = devm_request_threaded_irq_probe(&pdev->dev, irq, NULL, qpnp_tm_isr,
+ IRQF_ONESHOT, node->name, chip, NULL);
if (ret < 0)
return ret;
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 09/21] thermal: intel: int340x: processor_thermal: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (6 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 08/21] thermal/drivers/qcom/temp-alarm: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 17:28 ` Rafael J. Wysocki
2023-07-10 9:59 ` [PATCH v4 10/21] thermal/drivers/exynos: " Yangtao Li
` (11 subsequent siblings)
19 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
.../intel/int340x_thermal/processor_thermal_device_pci.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
index 0d1e98007270..ee766904b314 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
@@ -258,13 +258,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
irq_flag = IRQF_SHARED;
irq = pci_irq_vector(pdev, 0);
- ret = devm_request_threaded_irq(&pdev->dev, irq,
- proc_thermal_irq_handler, NULL,
- irq_flag, KBUILD_MODNAME, pci_info);
- if (ret) {
- dev_err(&pdev->dev, "Request IRQ %d failed\n", pdev->irq);
+ ret = devm_request_threaded_irq_probe(&pdev->dev, irq, proc_thermal_irq_handler,
+ NULL, irq_flag, KBUILD_MODNAME, pci_info, NULL);
+ if (ret)
goto err_free_vectors;
- }
ret = thermal_zone_device_enable(pci_info->tzone);
if (ret)
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 10/21] thermal/drivers/exynos: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (7 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 09/21] thermal: intel: int340x: processor_thermal: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 10:14 ` Krzysztof Kozlowski
2023-07-10 9:59 ` [PATCH v4 11/21] thermal/drivers/hisi: " Yangtao Li
` (10 subsequent siblings)
19 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski, Rafael J. Wysocki,
Daniel Lezcano, Amit Kucheria, Zhang Rui, Alim Akhtar
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-samsung-soc,
linux-arm-kernel, linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/samsung/exynos_tmu.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 45e5c840d130..697d2fbdb1bf 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1100,12 +1100,11 @@ static int exynos_tmu_probe(struct platform_device *pdev)
goto err_sclk;
}
- ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
- IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
- if (ret) {
- dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq);
+ ret = devm_request_irq_probe(&pdev->dev, data->irq, exynos_tmu_irq,
+ IRQF_TRIGGER_RISING | IRQF_SHARED,
+ dev_name(&pdev->dev), data, NULL);
+ if (ret)
goto err_sclk;
- }
exynos_tmu_control(pdev, true);
return 0;
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 11/21] thermal/drivers/hisi: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (8 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 10/21] thermal/drivers/exynos: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 9:59 ` [PATCH v4 12/21] thermal/drivers/rockchip: " Yangtao Li
` (9 subsequent siblings)
19 siblings, 0 replies; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/hisi_thermal.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 3f09ef8be41a..ee5f50fb2b68 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -576,14 +576,12 @@ static int hisi_thermal_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
- ret = devm_request_threaded_irq(dev, ret, NULL,
- hisi_thermal_alarm_irq_thread,
- IRQF_ONESHOT, sensor->irq_name,
- sensor);
- if (ret < 0) {
- dev_err(dev, "Failed to request alarm irq: %d\n", ret);
+ ret = devm_request_threaded_irq_probe(dev, ret, NULL,
+ hisi_thermal_alarm_irq_thread,
+ IRQF_ONESHOT, sensor->irq_name,
+ sensor, "alarm");
+ if (ret < 0)
return ret;
- }
ret = data->ops->enable_sensor(sensor);
if (ret) {
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 12/21] thermal/drivers/rockchip: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (9 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 11/21] thermal/drivers/hisi: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 11:05 ` Heiko Stuebner
2023-07-10 9:59 ` [PATCH v4 13/21] drivers/thermal/rcar_gen3_thermal: " Yangtao Li
` (8 subsequent siblings)
19 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Heiko Stuebner
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-arm-kernel,
linux-rockchip, linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/rockchip_thermal.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 77231a9d28ff..11061f6ef323 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -1577,13 +1577,12 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
"failed to register sensor[%d].\n", i);
}
- error = devm_request_threaded_irq(&pdev->dev, irq, NULL,
- &rockchip_thermal_alarm_irq_thread,
- IRQF_ONESHOT,
- "rockchip_thermal", thermal);
+ error = devm_request_threaded_irq_probe(&pdev->dev, irq, NULL,
+ &rockchip_thermal_alarm_irq_thread,
+ IRQF_ONESHOT,
+ "rockchip_thermal", thermal, "tsadc");
if (error)
- return dev_err_probe(&pdev->dev, error,
- "failed to request tsadc irq.\n");
+ return error;
thermal->chip->control(thermal->regs, true);
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 13/21] drivers/thermal/rcar_gen3_thermal: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (10 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 12/21] thermal/drivers/rockchip: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 12:27 ` Geert Uytterhoeven
2023-07-10 9:59 ` [PATCH v4 14/21] thermal/drivers/mediatek/lvts_thermal: " Yangtao Li
` (7 subsequent siblings)
19 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Niklas Söderlund, Rafael J. Wysocki, Daniel Lezcano,
Amit Kucheria, Zhang Rui
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-renesas-soc, linux-pm,
linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/rcar_gen3_thermal.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
index 9029d01e029b..ff9cd43e1881 100644
--- a/drivers/thermal/rcar_gen3_thermal.c
+++ b/drivers/thermal/rcar_gen3_thermal.c
@@ -467,9 +467,10 @@ static int rcar_gen3_thermal_request_irqs(struct rcar_gen3_thermal_priv *priv,
if (!irqname)
return -ENOMEM;
- ret = devm_request_threaded_irq(dev, irq, NULL,
- rcar_gen3_thermal_irq,
- IRQF_ONESHOT, irqname, priv);
+ ret = devm_request_threaded_irq_probe(dev, irq, NULL,
+ rcar_gen3_thermal_irq,
+ IRQF_ONESHOT, irqname,
+ priv, NULL);
if (ret)
return ret;
}
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 14/21] thermal/drivers/mediatek/lvts_thermal: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (11 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 13/21] drivers/thermal/rcar_gen3_thermal: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-11 8:04 ` AngeloGioacchino Del Regno
2023-07-10 9:59 ` [PATCH v4 15/21] thermal: max77620: " Yangtao Li
` (6 subsequent siblings)
19 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Matthias Brugger, AngeloGioacchino Del Regno
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron, linux-pm, linux-kernel,
linux-arm-kernel, linux-mediatek
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index b693fac2d677..1e12410820df 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -1148,10 +1148,10 @@ static int lvts_probe(struct platform_device *pdev)
* At this point the LVTS is initialized and enabled. We can
* safely enable the interrupt.
*/
- ret = devm_request_threaded_irq(dev, irq, NULL, lvts_irq_handler,
- IRQF_ONESHOT, dev_name(dev), lvts_td);
+ ret = devm_request_threaded_irq_probe(dev, irq, NULL, lvts_irq_handler,
+ IRQF_ONESHOT, dev_name(dev), lvts_td, NULL);
if (ret)
- return dev_err_probe(dev, ret, "Failed to request interrupt\n");
+ return ret;
platform_set_drvdata(pdev, lvts_td);
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 15/21] thermal: max77620: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (12 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 14/21] thermal/drivers/mediatek/lvts_thermal: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 9:59 ` [PATCH v4 16/21] thermal/drivers/intel/bxt_pmic: " Yangtao Li
` (5 subsequent siblings)
19 siblings, 0 replies; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/max77620_thermal.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/drivers/thermal/max77620_thermal.c b/drivers/thermal/max77620_thermal.c
index 61c7622d9945..92289498fa17 100644
--- a/drivers/thermal/max77620_thermal.c
+++ b/drivers/thermal/max77620_thermal.c
@@ -121,23 +121,19 @@ static int max77620_thermal_probe(struct platform_device *pdev)
return ret;
}
- ret = devm_request_threaded_irq(&pdev->dev, mtherm->irq_tjalarm1, NULL,
- max77620_thermal_irq,
- IRQF_ONESHOT | IRQF_SHARED,
- dev_name(&pdev->dev), mtherm);
- if (ret < 0) {
- dev_err(&pdev->dev, "Failed to request irq1: %d\n", ret);
+ ret = devm_request_threaded_irq_probe(&pdev->dev, mtherm->irq_tjalarm1, NULL,
+ max77620_thermal_irq,
+ IRQF_ONESHOT | IRQF_SHARED,
+ dev_name(&pdev->dev), mtherm, "irq1");
+ if (ret < 0)
return ret;
- }
- ret = devm_request_threaded_irq(&pdev->dev, mtherm->irq_tjalarm2, NULL,
- max77620_thermal_irq,
- IRQF_ONESHOT | IRQF_SHARED,
- dev_name(&pdev->dev), mtherm);
- if (ret < 0) {
- dev_err(&pdev->dev, "Failed to request irq2: %d\n", ret);
+ ret = devm_request_threaded_irq_probe(&pdev->dev, mtherm->irq_tjalarm2, NULL,
+ max77620_thermal_irq,
+ IRQF_ONESHOT | IRQF_SHARED,
+ dev_name(&pdev->dev), mtherm, "irq2");
+ if (ret < 0)
return ret;
- }
platform_set_drvdata(pdev, mtherm);
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 16/21] thermal/drivers/intel/bxt_pmic: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (13 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 15/21] thermal: max77620: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 9:59 ` [PATCH v4 17/21] thermal/drivers/stm: " Yangtao Li
` (4 subsequent siblings)
19 siblings, 0 replies; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/intel/intel_bxt_pmic_thermal.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/thermal/intel/intel_bxt_pmic_thermal.c b/drivers/thermal/intel/intel_bxt_pmic_thermal.c
index 6312c6ba081f..1bf3e6bf8052 100644
--- a/drivers/thermal/intel/intel_bxt_pmic_thermal.c
+++ b/drivers/thermal/intel/intel_bxt_pmic_thermal.c
@@ -241,14 +241,11 @@ static int pmic_thermal_probe(struct platform_device *pdev)
return virq;
}
- ret = devm_request_threaded_irq(&pdev->dev, virq,
- NULL, pmic_thermal_irq_handler,
- IRQF_ONESHOT, "pmic_thermal", pdev);
-
- if (ret) {
- dev_err(dev, "request irq(%d) failed: %d\n", virq, ret);
+ ret = devm_request_threaded_irq_probe(&pdev->dev, virq, NULL,
+ pmic_thermal_irq_handler, IRQF_ONESHOT,
+ "pmic_thermal", pdev, NULL);
+ if (ret)
return ret;
- }
pmic_irq_count++;
}
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 17/21] thermal/drivers/stm: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (14 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 16/21] thermal/drivers/intel/bxt_pmic: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 9:59 ` [PATCH v4 18/21] thermal/drivers/qcom/tsens-v0_1: " Yangtao Li
` (3 subsequent siblings)
19 siblings, 0 replies; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Maxime Coquelin, Alexandre Torgue
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-kernel, linux-stm32,
linux-arm-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/st/st_thermal_memmap.c | 12 +++++-------
drivers/thermal/st/stm_thermal.c | 13 ++++---------
2 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/drivers/thermal/st/st_thermal_memmap.c b/drivers/thermal/st/st_thermal_memmap.c
index e8cfa83b724a..40bb318b5489 100644
--- a/drivers/thermal/st/st_thermal_memmap.c
+++ b/drivers/thermal/st/st_thermal_memmap.c
@@ -97,14 +97,12 @@ static int st_mmap_register_enable_irq(struct st_thermal_sensor *sensor)
if (sensor->irq < 0)
return sensor->irq;
- ret = devm_request_threaded_irq(dev, sensor->irq,
- NULL, st_mmap_thermal_trip_handler,
- IRQF_TRIGGER_RISING | IRQF_ONESHOT,
- dev->driver->name, sensor);
- if (ret) {
- dev_err(dev, "failed to register IRQ %d\n", sensor->irq);
+ ret = devm_request_threaded_irq_probe(dev, sensor->irq,
+ NULL, st_mmap_thermal_trip_handler,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+ dev->driver->name, sensor, NULL);
+ if (ret)
return ret;
- }
return st_mmap_enable_irq(sensor);
}
diff --git a/drivers/thermal/st/stm_thermal.c b/drivers/thermal/st/stm_thermal.c
index 903fcf1763f1..6a36a7eab9bd 100644
--- a/drivers/thermal/st/stm_thermal.c
+++ b/drivers/thermal/st/stm_thermal.c
@@ -387,16 +387,11 @@ static int stm_register_irq(struct stm_thermal_sensor *sensor)
if (sensor->irq < 0)
return sensor->irq;
- ret = devm_request_threaded_irq(dev, sensor->irq,
- NULL,
- stm_thermal_irq_handler,
- IRQF_ONESHOT,
- dev->driver->name, sensor);
- if (ret) {
- dev_err(dev, "%s: Failed to register IRQ %d\n", __func__,
- sensor->irq);
+ ret = devm_request_threaded_irq_probe(dev, sensor->irq, NULL,
+ stm_thermal_irq_handler, IRQF_ONESHOT,
+ dev->driver->name, sensor, NULL);
+ if (ret)
return ret;
- }
dev_dbg(dev, "%s: thermal IRQ registered", __func__);
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 18/21] thermal/drivers/qcom/tsens-v0_1: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (15 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 17/21] thermal/drivers/stm: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 11:26 ` Dmitry Baryshkov
2023-07-10 9:59 ` [PATCH v4 19/21] thermal: qcom-spmi-adc-tm5: " Yangtao Li
` (2 subsequent siblings)
19 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Amit Kucheria, Thara Gopinath, Andy Gross, Bjorn Andersson,
Konrad Dybcio, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-arm-msm, linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/qcom/tsens.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 98c356acfe98..d4528d36c085 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -1171,21 +1171,18 @@ static int tsens_register_irq(struct tsens_priv *priv, char *irqname,
} else {
/* VER_0 interrupt is TRIGGER_RISING, VER_0_1 and up is ONESHOT */
if (tsens_version(priv) == VER_0)
- ret = devm_request_threaded_irq(&pdev->dev, irq,
- thread_fn, NULL,
- IRQF_TRIGGER_RISING,
- dev_name(&pdev->dev),
- priv);
+ ret = devm_request_threaded_irq_probe(&pdev->dev, irq,
+ thread_fn, NULL,
+ IRQF_TRIGGER_RISING,
+ dev_name(&pdev->dev),
+ priv, NULL);
else
- ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
- thread_fn, IRQF_ONESHOT,
- dev_name(&pdev->dev),
- priv);
+ ret = devm_request_threaded_irq_probe(&pdev->dev, irq, NULL,
+ thread_fn, IRQF_ONESHOT,
+ dev_name(&pdev->dev),
+ priv, NULL);
- if (ret)
- dev_err(&pdev->dev, "%s: failed to get irq\n",
- __func__);
- else
+ if (!ret)
enable_irq_wake(irq);
}
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 19/21] thermal: qcom-spmi-adc-tm5: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (16 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 18/21] thermal/drivers/qcom/tsens-v0_1: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 11:27 ` Dmitry Baryshkov
2023-07-10 9:59 ` [PATCH v4 20/21] thermal/drivers/uniphier: " Yangtao Li
2023-07-10 9:59 ` [PATCH v4 21/21] thermal/drivers/imx: " Yangtao Li
19 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Amit Kucheria,
Thara Gopinath, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-arm-msm, linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
index 5ddc39b2be32..90d46dc60806 100644
--- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
+++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
@@ -1044,8 +1044,9 @@ static int adc_tm5_probe(struct platform_device *pdev)
return ret;
}
- return devm_request_threaded_irq(dev, irq, NULL, adc_tm->data->isr,
- IRQF_ONESHOT, adc_tm->data->irq_name, adc_tm);
+ return devm_request_threaded_irq_probe(dev, irq, NULL, adc_tm->data->isr,
+ IRQF_ONESHOT, adc_tm->data->irq_name,
+ adc_tm, NULL);
}
static const struct of_device_id adc_tm5_match_table[] = {
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 20/21] thermal/drivers/uniphier: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (17 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 19/21] thermal: qcom-spmi-adc-tm5: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
2023-07-10 9:59 ` [PATCH v4 21/21] thermal/drivers/imx: " Yangtao Li
19 siblings, 0 replies; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Kunihiko Hayashi, Masami Hiramatsu
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-arm-kernel,
linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/uniphier_thermal.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/uniphier_thermal.c b/drivers/thermal/uniphier_thermal.c
index aef6119cc004..34d8eb2138d3 100644
--- a/drivers/thermal/uniphier_thermal.c
+++ b/drivers/thermal/uniphier_thermal.c
@@ -278,9 +278,9 @@ static int uniphier_tm_probe(struct platform_device *pdev)
return ret;
}
- ret = devm_request_threaded_irq(dev, irq, uniphier_tm_alarm_irq,
- uniphier_tm_alarm_irq_thread,
- 0, "thermal", tdev);
+ ret = devm_request_threaded_irq_probe(dev, irq, uniphier_tm_alarm_irq,
+ uniphier_tm_alarm_irq_thread,
+ 0, "thermal", tdev, NULL);
if (ret)
return ret;
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* [PATCH v4 21/21] thermal/drivers/imx: convert to use devm_request*_irq_probe()
[not found] <20230710095926.15614-1-frank.li@vivo.com>
` (18 preceding siblings ...)
2023-07-10 9:59 ` [PATCH v4 20/21] thermal/drivers/uniphier: " Yangtao Li
@ 2023-07-10 9:59 ` Yangtao Li
19 siblings, 0 replies; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 9:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
NXP Linux Team
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-arm-kernel,
linux-kernel
There are more than 700 calls to devm_request_threaded_irq method and
more than 1000 calls to devm_request_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 2000 lines
of code can be saved by removing the msg in the driver.
And tglx point out that:
If we actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
519 messages total (there are probably more)
352 unique messages
323 unique messages after lower casing
Those 323 are mostly just variants of the same patterns with
slight modifications in formatting and information provided.
186 of these messages do not deliver any useful information,
e.g. "no irq", "
The most useful one of all is: "could request wakeup irq: %d"
So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.
It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.
So convert to use devm_request*_irq_probe() API, which 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.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/imx_thermal.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index a94ec0a0c9dd..3131a09f9906 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -746,13 +746,12 @@ static int imx_thermal_probe(struct platform_device *pdev)
if (ret)
goto thermal_zone_unregister;
- ret = devm_request_threaded_irq(&pdev->dev, data->irq,
- imx_thermal_alarm_irq, imx_thermal_alarm_irq_thread,
- 0, "imx_thermal", data);
- if (ret < 0) {
- dev_err(&pdev->dev, "failed to request alarm irq: %d\n", ret);
+ ret = devm_request_threaded_irq_probe(&pdev->dev, data->irq,
+ imx_thermal_alarm_irq,
+ imx_thermal_alarm_irq_thread,
+ 0, "imx_thermal", data, "alarm");
+ if (ret < 0)
goto thermal_zone_unregister;
- }
pm_runtime_put(data->dev);
--
2.39.0
^ permalink raw reply related [flat|nested] 35+ messages in thread
* Re: [PATCH v4 10/21] thermal/drivers/exynos: convert to use devm_request*_irq_probe()
2023-07-10 9:59 ` [PATCH v4 10/21] thermal/drivers/exynos: " Yangtao Li
@ 2023-07-10 10:14 ` Krzysztof Kozlowski
0 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-10 10:14 UTC (permalink / raw)
To: Yangtao Li, Bartlomiej Zolnierkiewicz, Rafael J. Wysocki,
Daniel Lezcano, Amit Kucheria, Zhang Rui, Alim Akhtar
Cc: Thomas Gleixner, Krzysztof Kozlowski, Uwe Kleine-König,
Jonathan Cameron, AngeloGioacchino Del Regno, linux-pm,
linux-samsung-soc, linux-arm-kernel, linux-kernel
On 10/07/2023 11:59, Yangtao Li wrote:
> There are more than 700 calls to devm_request_threaded_irq method and
> more than 1000 calls to devm_request_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 2000 lines
> of code can be saved by removing the msg in the driver.
>
> And tglx point out that:
>
> If we actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
> 519 messages total (there are probably more)
>
> 352 unique messages
>
> 323 unique messages after lower casing
>
> Those 323 are mostly just variants of the same patterns with
> slight modifications in formatting and information provided.
>
> 186 of these messages do not deliver any useful information,
> e.g. "no irq", "
>
> The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> So convert to use devm_request*_irq_probe() API, which 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.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 12/21] thermal/drivers/rockchip: convert to use devm_request*_irq_probe()
2023-07-10 9:59 ` [PATCH v4 12/21] thermal/drivers/rockchip: " Yangtao Li
@ 2023-07-10 11:05 ` Heiko Stuebner
0 siblings, 0 replies; 35+ messages in thread
From: Heiko Stuebner @ 2023-07-10 11:05 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Yangtao Li
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-arm-kernel,
linux-rockchip, linux-kernel
Am Montag, 10. Juli 2023, 11:59:16 CEST schrieb Yangtao Li:
> There are more than 700 calls to devm_request_threaded_irq method and
> more than 1000 calls to devm_request_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 2000 lines
> of code can be saved by removing the msg in the driver.
>
> And tglx point out that:
>
> If we actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
> 519 messages total (there are probably more)
>
> 352 unique messages
>
> 323 unique messages after lower casing
>
> Those 323 are mostly just variants of the same patterns with
> slight modifications in formatting and information provided.
>
> 186 of these messages do not deliver any useful information,
> e.g. "no irq", "
>
> The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> So convert to use devm_request*_irq_probe() API, which 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.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
Acked-by: Heiko Stuebner <heiko@sntech.de>
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 06/21] thermal/drivers/db8500: convert to use devm_request*_irq_probe()
2023-07-10 9:59 ` [PATCH v4 06/21] thermal/drivers/db8500: " Yangtao Li
@ 2023-07-10 11:25 ` Dmitry Baryshkov
2023-07-10 11:30 ` Yangtao Li
0 siblings, 1 reply; 35+ messages in thread
From: Dmitry Baryshkov @ 2023-07-10 11:25 UTC (permalink / raw)
To: Yangtao Li, Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria,
Zhang Rui, Andy Gross, Bjorn Andersson, Konrad Dybcio,
Thara Gopinath
Cc: Thomas Gleixner, Krzysztof Kozlowski, Uwe Kleine-König,
Jonathan Cameron, AngeloGioacchino Del Regno, linux-pm,
linux-kernel, linux-arm-msm
On 10/07/2023 12:59, Yangtao Li wrote:
> There are more than 700 calls to devm_request_threaded_irq method and
> more than 1000 calls to devm_request_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 2000 lines
> of code can be saved by removing the msg in the driver.
>
> And tglx point out that:
>
> If we actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
> 519 messages total (there are probably more)
>
> 352 unique messages
>
> 323 unique messages after lower casing
>
> Those 323 are mostly just variants of the same patterns with
> slight modifications in formatting and information provided.
>
> 186 of these messages do not deliver any useful information,
> e.g. "no irq", "
>
> The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> So convert to use devm_request*_irq_probe() API, which 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.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
> drivers/thermal/db8500_thermal.c | 16 ++++++----------
> drivers/thermal/qcom/lmh.c | 7 +++----
Please split LMH to a separate driver.
> 2 files changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c
> index fca5c2c93bf9..0ef8fc2eb4a1 100644
> --- a/drivers/thermal/db8500_thermal.c
> +++ b/drivers/thermal/db8500_thermal.c
> @@ -164,25 +164,21 @@ static int db8500_thermal_probe(struct platform_device *pdev)
> if (low_irq < 0)
> return low_irq;
>
> - ret = devm_request_threaded_irq(dev, low_irq, NULL,
> + ret = devm_request_threaded_irq_probe(dev, low_irq, NULL,
> prcmu_low_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
> - "dbx500_temp_low", th);
> - if (ret < 0) {
> - dev_err(dev, "failed to allocate temp low irq\n");
> + "dbx500_temp_low", th, "temp low");
> + if (ret < 0)
> return ret;
> - }
>
> high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH");
> if (high_irq < 0)
> return high_irq;
>
> - ret = devm_request_threaded_irq(dev, high_irq, NULL,
> + ret = devm_request_threaded_irq_probe(dev, high_irq, NULL,
> prcmu_high_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
> - "dbx500_temp_high", th);
> - if (ret < 0) {
> - dev_err(dev, "failed to allocate temp high irq\n");
> + "dbx500_temp_high", th, "temp high");
> + if (ret < 0)
> return ret;
> - }
>
> /* register of thermal sensor and get info from DT */
> th->tz = devm_thermal_of_zone_register(dev, 0, th, &thdev_ops);
> diff --git a/drivers/thermal/qcom/lmh.c b/drivers/thermal/qcom/lmh.c
> index f6edb12ec004..48a14d7e8bf5 100644
> --- a/drivers/thermal/qcom/lmh.c
> +++ b/drivers/thermal/qcom/lmh.c
> @@ -207,11 +207,10 @@ static int lmh_probe(struct platform_device *pdev)
>
> /* Disable the irq and let cpufreq enable it when ready to handle the interrupt */
> irq_set_status_flags(lmh_data->irq, IRQ_NOAUTOEN);
> - ret = devm_request_irq(dev, lmh_data->irq, lmh_handle_irq,
> - IRQF_ONESHOT | IRQF_NO_SUSPEND,
> - "lmh-irq", lmh_data);
> + ret = devm_request_irq_probe(dev, lmh_data->irq, lmh_handle_irq,
> + IRQF_ONESHOT | IRQF_NO_SUSPEND,
> + "lmh-irq", lmh_data, NULL);
> if (ret) {
> - dev_err(dev, "Error %d registering irq %x\n", ret, lmh_data->irq);
> irq_domain_remove(lmh_data->domain);
> return ret;
> }
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 08/21] thermal/drivers/qcom/temp-alarm: convert to use devm_request*_irq_probe()
2023-07-10 9:59 ` [PATCH v4 08/21] thermal/drivers/qcom/temp-alarm: " Yangtao Li
@ 2023-07-10 11:26 ` Dmitry Baryshkov
0 siblings, 0 replies; 35+ messages in thread
From: Dmitry Baryshkov @ 2023-07-10 11:26 UTC (permalink / raw)
To: Yangtao Li, Amit Kucheria, Thara Gopinath, Andy Gross,
Bjorn Andersson, Konrad Dybcio, Rafael J. Wysocki, Daniel Lezcano,
Zhang Rui
Cc: Thomas Gleixner, Krzysztof Kozlowski, Uwe Kleine-König,
Jonathan Cameron, AngeloGioacchino Del Regno, linux-arm-msm,
linux-pm, linux-kernel
On 10/07/2023 12:59, Yangtao Li wrote:
> There are more than 700 calls to devm_request_threaded_irq method and
> more than 1000 calls to devm_request_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 2000 lines
> of code can be saved by removing the msg in the driver.
>
> And tglx point out that:
>
> If we actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
> 519 messages total (there are probably more)
>
> 352 unique messages
>
> 323 unique messages after lower casing
>
> Those 323 are mostly just variants of the same patterns with
> slight modifications in formatting and information provided.
>
> 186 of these messages do not deliver any useful information,
> e.g. "no irq", "
>
> The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> So convert to use devm_request*_irq_probe() API, which 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.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
> drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 18/21] thermal/drivers/qcom/tsens-v0_1: convert to use devm_request*_irq_probe()
2023-07-10 9:59 ` [PATCH v4 18/21] thermal/drivers/qcom/tsens-v0_1: " Yangtao Li
@ 2023-07-10 11:26 ` Dmitry Baryshkov
0 siblings, 0 replies; 35+ messages in thread
From: Dmitry Baryshkov @ 2023-07-10 11:26 UTC (permalink / raw)
To: Yangtao Li, Amit Kucheria, Thara Gopinath, Andy Gross,
Bjorn Andersson, Konrad Dybcio, Rafael J. Wysocki, Daniel Lezcano,
Zhang Rui
Cc: Thomas Gleixner, Krzysztof Kozlowski, Uwe Kleine-König,
Jonathan Cameron, AngeloGioacchino Del Regno, linux-pm,
linux-arm-msm, linux-kernel
On 10/07/2023 12:59, Yangtao Li wrote:
> There are more than 700 calls to devm_request_threaded_irq method and
> more than 1000 calls to devm_request_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 2000 lines
> of code can be saved by removing the msg in the driver.
>
> And tglx point out that:
>
> If we actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
> 519 messages total (there are probably more)
>
> 352 unique messages
>
> 323 unique messages after lower casing
>
> Those 323 are mostly just variants of the same patterns with
> slight modifications in formatting and information provided.
>
> 186 of these messages do not deliver any useful information,
> e.g. "no irq", "
>
> The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> So convert to use devm_request*_irq_probe() API, which 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.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
> drivers/thermal/qcom/tsens.c | 23 ++++++++++-------------
> 1 file changed, 10 insertions(+), 13 deletions(-)
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 19/21] thermal: qcom-spmi-adc-tm5: convert to use devm_request*_irq_probe()
2023-07-10 9:59 ` [PATCH v4 19/21] thermal: qcom-spmi-adc-tm5: " Yangtao Li
@ 2023-07-10 11:27 ` Dmitry Baryshkov
0 siblings, 0 replies; 35+ messages in thread
From: Dmitry Baryshkov @ 2023-07-10 11:27 UTC (permalink / raw)
To: Yangtao Li, Andy Gross, Bjorn Andersson, Konrad Dybcio,
Amit Kucheria, Thara Gopinath, Rafael J. Wysocki, Daniel Lezcano,
Zhang Rui
Cc: Thomas Gleixner, Krzysztof Kozlowski, Uwe Kleine-König,
Jonathan Cameron, AngeloGioacchino Del Regno, linux-pm,
linux-arm-msm, linux-kernel
On 10/07/2023 12:59, Yangtao Li wrote:
> There are more than 700 calls to devm_request_threaded_irq method and
> more than 1000 calls to devm_request_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 2000 lines
> of code can be saved by removing the msg in the driver.
>
> And tglx point out that:
>
> If we actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
> 519 messages total (there are probably more)
>
> 352 unique messages
>
> 323 unique messages after lower casing
>
> Those 323 are mostly just variants of the same patterns with
> slight modifications in formatting and information provided.
>
> 186 of these messages do not deliver any useful information,
> e.g. "no irq", "
>
> The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> So convert to use devm_request*_irq_probe() API, which 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.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
> drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 06/21] thermal/drivers/db8500: convert to use devm_request*_irq_probe()
2023-07-10 11:25 ` Dmitry Baryshkov
@ 2023-07-10 11:30 ` Yangtao Li
2023-07-10 11:40 ` Dmitry Baryshkov
0 siblings, 1 reply; 35+ messages in thread
From: Yangtao Li @ 2023-07-10 11:30 UTC (permalink / raw)
To: Dmitry Baryshkov, Rafael J. Wysocki, Daniel Lezcano,
Amit Kucheria, Zhang Rui, Andy Gross, Bjorn Andersson,
Konrad Dybcio, Thara Gopinath
Cc: Thomas Gleixner, Krzysztof Kozlowski, Uwe Kleine-König,
Jonathan Cameron, AngeloGioacchino Del Regno, linux-pm,
linux-kernel, linux-arm-msm
Hi Dmitry,
On 2023/7/10 19:25, Dmitry Baryshkov wrote:
> On 10/07/2023 12:59, Yangtao Li wrote:
>> There are more than 700 calls to devm_request_threaded_irq method and
>> more than 1000 calls to devm_request_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 2000 lines
>> of code can be saved by removing the msg in the driver.
>>
>> And tglx point out that:
>>
>> If we actually look at the call sites of
>> devm_request_threaded_irq() then the vast majority of them print
>> more or
>> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>>
>> 519 messages total (there are probably more)
>>
>> 352 unique messages
>>
>> 323 unique messages after lower casing
>>
>> Those 323 are mostly just variants of the same patterns with
>> slight modifications in formatting and information provided.
>>
>> 186 of these messages do not deliver any useful information,
>> e.g. "no irq", "
>>
>> The most useful one of all is: "could request wakeup irq: %d"
>>
>> So there is certainly an argument to be made that this particular
>> function should print a well formatted and informative error message.
>>
>> It's not a general allocator like kmalloc(). It's specialized and
>> in the
>> vast majority of cases failing to request the interrupt causes the
>> device probe to fail. So having proper and consistent information why
>> the device cannot be used _is_ useful.
>>
>> So convert to use devm_request*_irq_probe() API, which 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.
>>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Krzysztof Kozlowski <krzk@kernel.org>
>> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
>> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
>> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>> Signed-off-by: Yangtao Li <frank.li@vivo.com>
>> ---
>> drivers/thermal/db8500_thermal.c | 16 ++++++----------
>> drivers/thermal/qcom/lmh.c | 7 +++----
>
> Please split LMH to a separate driver.
Sorry for mixing these two patches together,
can I add your Reviewed-by tag when the patch is resubmitted for the
next version?
Thx,
Yangtao
>
>> 2 files changed, 9 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/thermal/db8500_thermal.c
>> b/drivers/thermal/db8500_thermal.c
>> index fca5c2c93bf9..0ef8fc2eb4a1 100644
>> --- a/drivers/thermal/db8500_thermal.c
>> +++ b/drivers/thermal/db8500_thermal.c
>> @@ -164,25 +164,21 @@ static int db8500_thermal_probe(struct
>> platform_device *pdev)
>> if (low_irq < 0)
>> return low_irq;
>> - ret = devm_request_threaded_irq(dev, low_irq, NULL,
>> + ret = devm_request_threaded_irq_probe(dev, low_irq, NULL,
>> prcmu_low_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
>> - "dbx500_temp_low", th);
>> - if (ret < 0) {
>> - dev_err(dev, "failed to allocate temp low irq\n");
>> + "dbx500_temp_low", th, "temp low");
>> + if (ret < 0)
>> return ret;
>> - }
>> high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH");
>> if (high_irq < 0)
>> return high_irq;
>> - ret = devm_request_threaded_irq(dev, high_irq, NULL,
>> + ret = devm_request_threaded_irq_probe(dev, high_irq, NULL,
>> prcmu_high_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
>> - "dbx500_temp_high", th);
>> - if (ret < 0) {
>> - dev_err(dev, "failed to allocate temp high irq\n");
>> + "dbx500_temp_high", th, "temp high");
>> + if (ret < 0)
>> return ret;
>> - }
>> /* register of thermal sensor and get info from DT */
>> th->tz = devm_thermal_of_zone_register(dev, 0, th, &thdev_ops);
>> diff --git a/drivers/thermal/qcom/lmh.c b/drivers/thermal/qcom/lmh.c
>> index f6edb12ec004..48a14d7e8bf5 100644
>> --- a/drivers/thermal/qcom/lmh.c
>> +++ b/drivers/thermal/qcom/lmh.c
>> @@ -207,11 +207,10 @@ static int lmh_probe(struct platform_device *pdev)
>> /* Disable the irq and let cpufreq enable it when ready to
>> handle the interrupt */
>> irq_set_status_flags(lmh_data->irq, IRQ_NOAUTOEN);
>> - ret = devm_request_irq(dev, lmh_data->irq, lmh_handle_irq,
>> - IRQF_ONESHOT | IRQF_NO_SUSPEND,
>> - "lmh-irq", lmh_data);
>> + ret = devm_request_irq_probe(dev, lmh_data->irq, lmh_handle_irq,
>> + IRQF_ONESHOT | IRQF_NO_SUSPEND,
>> + "lmh-irq", lmh_data, NULL);
>> if (ret) {
>> - dev_err(dev, "Error %d registering irq %x\n", ret,
>> lmh_data->irq);
>> irq_domain_remove(lmh_data->domain);
>> return ret;
>> }
>
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 06/21] thermal/drivers/db8500: convert to use devm_request*_irq_probe()
2023-07-10 11:30 ` Yangtao Li
@ 2023-07-10 11:40 ` Dmitry Baryshkov
0 siblings, 0 replies; 35+ messages in thread
From: Dmitry Baryshkov @ 2023-07-10 11:40 UTC (permalink / raw)
To: Yangtao Li
Cc: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Andy Gross, Bjorn Andersson, Konrad Dybcio, Thara Gopinath,
Thomas Gleixner, Krzysztof Kozlowski, Uwe Kleine-König,
Jonathan Cameron, AngeloGioacchino Del Regno, linux-pm,
linux-kernel, linux-arm-msm
On Mon, 10 Jul 2023 at 14:30, Yangtao Li <frank.li@vivo.com> wrote:
>
> Hi Dmitry,
>
> On 2023/7/10 19:25, Dmitry Baryshkov wrote:
>
> > On 10/07/2023 12:59, Yangtao Li wrote:
> >> There are more than 700 calls to devm_request_threaded_irq method and
> >> more than 1000 calls to devm_request_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 2000 lines
> >> of code can be saved by removing the msg in the driver.
> >>
> >> And tglx point out that:
> >>
> >> If we actually look at the call sites of
> >> devm_request_threaded_irq() then the vast majority of them print
> >> more or
> >> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
> >>
> >> 519 messages total (there are probably more)
> >>
> >> 352 unique messages
> >>
> >> 323 unique messages after lower casing
> >>
> >> Those 323 are mostly just variants of the same patterns with
> >> slight modifications in formatting and information provided.
> >>
> >> 186 of these messages do not deliver any useful information,
> >> e.g. "no irq", "
> >>
> >> The most useful one of all is: "could request wakeup irq: %d"
> >>
> >> So there is certainly an argument to be made that this particular
> >> function should print a well formatted and informative error message.
> >>
> >> It's not a general allocator like kmalloc(). It's specialized and
> >> in the
> >> vast majority of cases failing to request the interrupt causes the
> >> device probe to fail. So having proper and consistent information why
> >> the device cannot be used _is_ useful.
> >>
> >> So convert to use devm_request*_irq_probe() API, which 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.
> >>
> >> Cc: Thomas Gleixner <tglx@linutronix.de>
> >> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> >> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> >> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> >> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> >> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> >> ---
> >> drivers/thermal/db8500_thermal.c | 16 ++++++----------
> >> drivers/thermal/qcom/lmh.c | 7 +++----
> >
> > Please split LMH to a separate driver.
>
>
> Sorry for mixing these two patches together,
>
> can I add your Reviewed-by tag when the patch is resubmitted for the
> next version?
Yes, please add it to the LMH patch.
>
>
> Thx,
>
> Yangtao
>
> >
> >> 2 files changed, 9 insertions(+), 14 deletions(-)
> >>
> >> diff --git a/drivers/thermal/db8500_thermal.c
> >> b/drivers/thermal/db8500_thermal.c
> >> index fca5c2c93bf9..0ef8fc2eb4a1 100644
> >> --- a/drivers/thermal/db8500_thermal.c
> >> +++ b/drivers/thermal/db8500_thermal.c
> >> @@ -164,25 +164,21 @@ static int db8500_thermal_probe(struct
> >> platform_device *pdev)
> >> if (low_irq < 0)
> >> return low_irq;
> >> - ret = devm_request_threaded_irq(dev, low_irq, NULL,
> >> + ret = devm_request_threaded_irq_probe(dev, low_irq, NULL,
> >> prcmu_low_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
> >> - "dbx500_temp_low", th);
> >> - if (ret < 0) {
> >> - dev_err(dev, "failed to allocate temp low irq\n");
> >> + "dbx500_temp_low", th, "temp low");
> >> + if (ret < 0)
> >> return ret;
> >> - }
> >> high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH");
> >> if (high_irq < 0)
> >> return high_irq;
> >> - ret = devm_request_threaded_irq(dev, high_irq, NULL,
> >> + ret = devm_request_threaded_irq_probe(dev, high_irq, NULL,
> >> prcmu_high_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
> >> - "dbx500_temp_high", th);
> >> - if (ret < 0) {
> >> - dev_err(dev, "failed to allocate temp high irq\n");
> >> + "dbx500_temp_high", th, "temp high");
> >> + if (ret < 0)
> >> return ret;
> >> - }
> >> /* register of thermal sensor and get info from DT */
> >> th->tz = devm_thermal_of_zone_register(dev, 0, th, &thdev_ops);
> >> diff --git a/drivers/thermal/qcom/lmh.c b/drivers/thermal/qcom/lmh.c
> >> index f6edb12ec004..48a14d7e8bf5 100644
> >> --- a/drivers/thermal/qcom/lmh.c
> >> +++ b/drivers/thermal/qcom/lmh.c
> >> @@ -207,11 +207,10 @@ static int lmh_probe(struct platform_device *pdev)
> >> /* Disable the irq and let cpufreq enable it when ready to
> >> handle the interrupt */
> >> irq_set_status_flags(lmh_data->irq, IRQ_NOAUTOEN);
> >> - ret = devm_request_irq(dev, lmh_data->irq, lmh_handle_irq,
> >> - IRQF_ONESHOT | IRQF_NO_SUSPEND,
> >> - "lmh-irq", lmh_data);
> >> + ret = devm_request_irq_probe(dev, lmh_data->irq, lmh_handle_irq,
> >> + IRQF_ONESHOT | IRQF_NO_SUSPEND,
> >> + "lmh-irq", lmh_data, NULL);
> >> if (ret) {
> >> - dev_err(dev, "Error %d registering irq %x\n", ret,
> >> lmh_data->irq);
> >> irq_domain_remove(lmh_data->domain);
> >> return ret;
> >> }
> >
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 07/21] thermal/drivers/rcar: convert to use devm_request*_irq_probe()
2023-07-10 9:59 ` [PATCH v4 07/21] thermal/drivers/rcar: " Yangtao Li
@ 2023-07-10 12:27 ` Geert Uytterhoeven
0 siblings, 0 replies; 35+ messages in thread
From: Geert Uytterhoeven @ 2023-07-10 12:27 UTC (permalink / raw)
To: Yangtao Li
Cc: Niklas Söderlund, Rafael J. Wysocki, Daniel Lezcano,
Amit Kucheria, Zhang Rui, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-renesas-soc, linux-pm,
linux-kernel
On Mon, Jul 10, 2023 at 12:07 PM Yangtao Li <frank.li@vivo.com> wrote:
> There are more than 700 calls to devm_request_threaded_irq method and
> more than 1000 calls to devm_request_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 2000 lines
> of code can be saved by removing the msg in the driver.
>
> And tglx point out that:
>
> If we actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
> 519 messages total (there are probably more)
>
> 352 unique messages
>
> 323 unique messages after lower casing
>
> Those 323 are mostly just variants of the same patterns with
> slight modifications in formatting and information provided.
>
> 186 of these messages do not deliver any useful information,
> e.g. "no irq", "
>
> The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> So convert to use devm_request*_irq_probe() API, which 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.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 13/21] drivers/thermal/rcar_gen3_thermal: convert to use devm_request*_irq_probe()
2023-07-10 9:59 ` [PATCH v4 13/21] drivers/thermal/rcar_gen3_thermal: " Yangtao Li
@ 2023-07-10 12:27 ` Geert Uytterhoeven
0 siblings, 0 replies; 35+ messages in thread
From: Geert Uytterhoeven @ 2023-07-10 12:27 UTC (permalink / raw)
To: Yangtao Li
Cc: Niklas Söderlund, Rafael J. Wysocki, Daniel Lezcano,
Amit Kucheria, Zhang Rui, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-renesas-soc, linux-pm,
linux-kernel
On Mon, Jul 10, 2023 at 12:10 PM Yangtao Li <frank.li@vivo.com> wrote:
> There are more than 700 calls to devm_request_threaded_irq method and
> more than 1000 calls to devm_request_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 2000 lines
> of code can be saved by removing the msg in the driver.
>
> And tglx point out that:
>
> If we actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
> 519 messages total (there are probably more)
>
> 352 unique messages
>
> 323 unique messages after lower casing
>
> Those 323 are mostly just variants of the same patterns with
> slight modifications in formatting and information provided.
>
> 186 of these messages do not deliver any useful information,
> e.g. "no irq", "
>
> The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> So convert to use devm_request*_irq_probe() API, which 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.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 05/21] thermal/drivers/tegra: convert to use devm_request*_irq_probe()
2023-07-10 9:59 ` [PATCH v4 05/21] thermal/drivers/tegra: " Yangtao Li
@ 2023-07-10 13:16 ` Thierry Reding
2023-07-10 13:55 ` Krzysztof Kozlowski
0 siblings, 1 reply; 35+ messages in thread
From: Thierry Reding @ 2023-07-10 13:16 UTC (permalink / raw)
To: Yangtao Li
Cc: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Jonathan Hunter, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-tegra, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2250 bytes --]
On Mon, Jul 10, 2023 at 05:59:09PM +0800, Yangtao Li wrote:
> There are more than 700 calls to devm_request_threaded_irq method and
> more than 1000 calls to devm_request_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 2000 lines
> of code can be saved by removing the msg in the driver.
>
> And tglx point out that:
>
> If we actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
> 519 messages total (there are probably more)
>
> 352 unique messages
>
> 323 unique messages after lower casing
>
> Those 323 are mostly just variants of the same patterns with
> slight modifications in formatting and information provided.
>
> 186 of these messages do not deliver any useful information,
> e.g. "no irq", "
>
> The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> So convert to use devm_request*_irq_probe() API, which 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.
Do we really need to keep repeating this same commit message for each
and everyone of these commits? It's already in the cover letter and
presumably on the patch that introduces the new helper, so surely we can
come up with a denser version for individual subsystem patches.
Other than that this looks good:
Acked-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 05/21] thermal/drivers/tegra: convert to use devm_request*_irq_probe()
2023-07-10 13:16 ` Thierry Reding
@ 2023-07-10 13:55 ` Krzysztof Kozlowski
0 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-10 13:55 UTC (permalink / raw)
To: Thierry Reding, Yangtao Li
Cc: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Jonathan Hunter, Thomas Gleixner, Uwe Kleine-König,
Jonathan Cameron, AngeloGioacchino Del Regno, linux-pm,
linux-tegra, linux-kernel
On 10/07/2023 15:16, Thierry Reding wrote:
> On Mon, Jul 10, 2023 at 05:59:09PM +0800, Yangtao Li wrote:
>> There are more than 700 calls to devm_request_threaded_irq method and
>> more than 1000 calls to devm_request_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 2000 lines
>> of code can be saved by removing the msg in the driver.
>>
>> And tglx point out that:
>>
>> If we actually look at the call sites of
>> devm_request_threaded_irq() then the vast majority of them print more or
>> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>>
>> 519 messages total (there are probably more)
>>
>> 352 unique messages
>>
>> 323 unique messages after lower casing
>>
>> Those 323 are mostly just variants of the same patterns with
>> slight modifications in formatting and information provided.
>>
>> 186 of these messages do not deliver any useful information,
>> e.g. "no irq", "
>>
>> The most useful one of all is: "could request wakeup irq: %d"
>>
>> So there is certainly an argument to be made that this particular
>> function should print a well formatted and informative error message.
>>
>> It's not a general allocator like kmalloc(). It's specialized and in the
>> vast majority of cases failing to request the interrupt causes the
>> device probe to fail. So having proper and consistent information why
>> the device cannot be used _is_ useful.
>>
>> So convert to use devm_request*_irq_probe() API, which 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.
>
> Do we really need to keep repeating this same commit message for each
> and everyone of these commits? It's already in the cover letter and
> presumably on the patch that introduces the new helper, so surely we can
> come up with a denser version for individual subsystem patches.
Yeah, this is way too long to put in every commit doing the same but for
different drivers.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 09/21] thermal: intel: int340x: processor_thermal: convert to use devm_request*_irq_probe()
2023-07-10 9:59 ` [PATCH v4 09/21] thermal: intel: int340x: processor_thermal: " Yangtao Li
@ 2023-07-10 17:28 ` Rafael J. Wysocki
0 siblings, 0 replies; 35+ messages in thread
From: Rafael J. Wysocki @ 2023-07-10 17:28 UTC (permalink / raw)
To: Yangtao Li
Cc: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Thomas Gleixner, Krzysztof Kozlowski, Uwe Kleine-König,
Jonathan Cameron, AngeloGioacchino Del Regno, linux-pm,
linux-kernel
On Mon, Jul 10, 2023 at 12:00 PM Yangtao Li <frank.li@vivo.com> wrote:
>
> There are more than 700 calls to devm_request_threaded_irq method and
> more than 1000 calls to devm_request_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 2000 lines
> of code can be saved by removing the msg in the driver.
>
> And tglx point out that:
>
> If we actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
> 519 messages total (there are probably more)
>
> 352 unique messages
>
> 323 unique messages after lower casing
>
> Those 323 are mostly just variants of the same patterns with
> slight modifications in formatting and information provided.
>
> 186 of these messages do not deliver any useful information,
> e.g. "no irq", "
>
> The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> So convert to use devm_request*_irq_probe() API, which 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.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
> ---
> .../intel/int340x_thermal/processor_thermal_device_pci.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
> index 0d1e98007270..ee766904b314 100644
> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
> @@ -258,13 +258,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
> irq_flag = IRQF_SHARED;
>
> irq = pci_irq_vector(pdev, 0);
> - ret = devm_request_threaded_irq(&pdev->dev, irq,
> - proc_thermal_irq_handler, NULL,
> - irq_flag, KBUILD_MODNAME, pci_info);
> - if (ret) {
> - dev_err(&pdev->dev, "Request IRQ %d failed\n", pdev->irq);
> + ret = devm_request_threaded_irq_probe(&pdev->dev, irq, proc_thermal_irq_handler,
> + NULL, irq_flag, KBUILD_MODNAME, pci_info, NULL);
> + if (ret)
> goto err_free_vectors;
> - }
>
> ret = thermal_zone_device_enable(pci_info->tzone);
> if (ret)
> --
> 2.39.0
>
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 14/21] thermal/drivers/mediatek/lvts_thermal: convert to use devm_request*_irq_probe()
2023-07-10 9:59 ` [PATCH v4 14/21] thermal/drivers/mediatek/lvts_thermal: " Yangtao Li
@ 2023-07-11 8:04 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 35+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-07-11 8:04 UTC (permalink / raw)
To: Yangtao Li, Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria,
Zhang Rui, Matthias Brugger
Cc: Thomas Gleixner, Krzysztof Kozlowski, Uwe Kleine-König,
Jonathan Cameron, linux-pm, linux-kernel, linux-arm-kernel,
linux-mediatek
Il 10/07/23 11:59, Yangtao Li ha scritto:
> There are more than 700 calls to devm_request_threaded_irq method and
> more than 1000 calls to devm_request_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 2000 lines
> of code can be saved by removing the msg in the driver.
>
> And tglx point out that:
>
> If we actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
> 519 messages total (there are probably more)
>
> 352 unique messages
>
> 323 unique messages after lower casing
>
> Those 323 are mostly just variants of the same patterns with
> slight modifications in formatting and information provided.
>
> 186 of these messages do not deliver any useful information,
> e.g. "no irq", "
>
> The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> So convert to use devm_request*_irq_probe() API, which 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.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v4 02/21] thermal/drivers/sun8i: convert to use devm_request*_irq_probe()
2023-07-10 9:59 ` [PATCH v4 02/21] thermal/drivers/sun8i: convert to use devm_request*_irq_probe() Yangtao Li
@ 2023-07-11 17:57 ` Jernej Škrabec
0 siblings, 0 replies; 35+ messages in thread
From: Jernej Škrabec @ 2023-07-11 17:57 UTC (permalink / raw)
To: Vasily Khoruzhick, Yangtao Li, Rafael J. Wysocki, Daniel Lezcano,
Amit Kucheria, Zhang Rui, Chen-Yu Tsai, Samuel Holland,
Yangtao Li
Cc: Yangtao Li, Thomas Gleixner, Krzysztof Kozlowski,
Uwe Kleine-König, Jonathan Cameron,
AngeloGioacchino Del Regno, linux-pm, linux-arm-kernel,
linux-sunxi, linux-kernel
Dne ponedeljek, 10. julij 2023 ob 11:59:06 CEST je Yangtao Li napisal(a):
> There are more than 700 calls to devm_request_threaded_irq method and
> more than 1000 calls to devm_request_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 2000 lines
> of code can be saved by removing the msg in the driver.
>
> And tglx point out that:
>
> If we actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
> 519 messages total (there are probably more)
>
> 352 unique messages
>
> 323 unique messages after lower casing
>
> Those 323 are mostly just variants of the same patterns with
> slight modifications in formatting and information provided.
>
> 186 of these messages do not deliver any useful information,
> e.g. "no irq", "
>
> The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> So convert to use devm_request*_irq_probe() API, which 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.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Best regards,
Jernej
> drivers/thermal/sun8i_thermal.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c
> index 195f3c5d0b38..a952804ff993 100644
> --- a/drivers/thermal/sun8i_thermal.c
> +++ b/drivers/thermal/sun8i_thermal.c
> @@ -512,9 +512,9 @@ static int sun8i_ths_probe(struct platform_device *pdev)
> * registered yet, we deffer the registration of the interrupt to
> * the end.
> */
> - ret = devm_request_threaded_irq(dev, irq, NULL,
> - sun8i_irq_thread,
> - IRQF_ONESHOT, "ths", tmdev);
> + ret = devm_request_threaded_irq_probe(dev, irq, NULL,
> + sun8i_irq_thread,
> + IRQF_ONESHOT, "ths", tmdev, NULL);
> if (ret)
> return ret;
>
>
^ permalink raw reply [flat|nested] 35+ messages in thread
end of thread, other threads:[~2023-07-11 17:57 UTC | newest]
Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20230710095926.15614-1-frank.li@vivo.com>
2023-07-10 9:59 ` [PATCH v4 02/21] thermal/drivers/sun8i: convert to use devm_request*_irq_probe() Yangtao Li
2023-07-11 17:57 ` Jernej Škrabec
2023-07-10 9:59 ` [PATCH v4 03/21] thermal/drivers/armada: " Yangtao Li
2023-07-10 9:59 ` [PATCH v4 04/21] thermal/drivers/broadcom: " Yangtao Li
2023-07-10 9:59 ` [PATCH v4 05/21] thermal/drivers/tegra: " Yangtao Li
2023-07-10 13:16 ` Thierry Reding
2023-07-10 13:55 ` Krzysztof Kozlowski
2023-07-10 9:59 ` [PATCH v4 06/21] thermal/drivers/db8500: " Yangtao Li
2023-07-10 11:25 ` Dmitry Baryshkov
2023-07-10 11:30 ` Yangtao Li
2023-07-10 11:40 ` Dmitry Baryshkov
2023-07-10 9:59 ` [PATCH v4 07/21] thermal/drivers/rcar: " Yangtao Li
2023-07-10 12:27 ` Geert Uytterhoeven
2023-07-10 9:59 ` [PATCH v4 08/21] thermal/drivers/qcom/temp-alarm: " Yangtao Li
2023-07-10 11:26 ` Dmitry Baryshkov
2023-07-10 9:59 ` [PATCH v4 09/21] thermal: intel: int340x: processor_thermal: " Yangtao Li
2023-07-10 17:28 ` Rafael J. Wysocki
2023-07-10 9:59 ` [PATCH v4 10/21] thermal/drivers/exynos: " Yangtao Li
2023-07-10 10:14 ` Krzysztof Kozlowski
2023-07-10 9:59 ` [PATCH v4 11/21] thermal/drivers/hisi: " Yangtao Li
2023-07-10 9:59 ` [PATCH v4 12/21] thermal/drivers/rockchip: " Yangtao Li
2023-07-10 11:05 ` Heiko Stuebner
2023-07-10 9:59 ` [PATCH v4 13/21] drivers/thermal/rcar_gen3_thermal: " Yangtao Li
2023-07-10 12:27 ` Geert Uytterhoeven
2023-07-10 9:59 ` [PATCH v4 14/21] thermal/drivers/mediatek/lvts_thermal: " Yangtao Li
2023-07-11 8:04 ` AngeloGioacchino Del Regno
2023-07-10 9:59 ` [PATCH v4 15/21] thermal: max77620: " Yangtao Li
2023-07-10 9:59 ` [PATCH v4 16/21] thermal/drivers/intel/bxt_pmic: " Yangtao Li
2023-07-10 9:59 ` [PATCH v4 17/21] thermal/drivers/stm: " Yangtao Li
2023-07-10 9:59 ` [PATCH v4 18/21] thermal/drivers/qcom/tsens-v0_1: " Yangtao Li
2023-07-10 11:26 ` Dmitry Baryshkov
2023-07-10 9:59 ` [PATCH v4 19/21] thermal: qcom-spmi-adc-tm5: " Yangtao Li
2023-07-10 11:27 ` Dmitry Baryshkov
2023-07-10 9:59 ` [PATCH v4 20/21] thermal/drivers/uniphier: " Yangtao Li
2023-07-10 9:59 ` [PATCH v4 21/21] thermal/drivers/imx: " Yangtao Li
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).