* [PATCH 00/12] thermal/drivers: simplify probe()
@ 2024-07-09 12:59 Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 01/12] thermal/drivers/broadcom: fix race between removal and clock disable Krzysztof Kozlowski
` (12 more replies)
0 siblings, 13 replies; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, stable,
Krzysztof Kozlowski
Simplify error handling in probe() and also fix one possible issue in
remove().
Best regards,
Krzysztof
---
Krzysztof Kozlowski (12):
thermal/drivers/broadcom: fix race between removal and clock disable
thermal/drivers/broadcom: simplify probe() with local dev variable
thermal/drivers/broadcom: simplify with dev_err_probe()
thermal/drivers/exynos: simplify probe() with local dev variable
thermal/drivers/exynos: simplify with dev_err_probe()
thermal/drivers/hisi: simplify with dev_err_probe()
thermal/drivers/imx: simplify probe() with local dev variable
thermal/drivers/imx: simplify with dev_err_probe()
thermal/drivers/qcom-spmi-adc-tm5: simplify with dev_err_probe()
thermal/drivers/qcom-tsens: simplify with dev_err_probe()
thermal/drivers/generic-adc: simplify probe() with local dev variable
thermal/drivers/generic-adc: simplify with dev_err_probe()
drivers/thermal/broadcom/bcm2835_thermal.c | 49 +++++++--------------------
drivers/thermal/hisi_thermal.c | 9 ++---
drivers/thermal/imx_thermal.c | 42 +++++++++++------------
drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 9 ++---
drivers/thermal/qcom/tsens.c | 8 ++---
drivers/thermal/samsung/exynos_tmu.c | 54 +++++++++++++-----------------
drivers/thermal/thermal-generic-adc.c | 27 +++++++--------
7 files changed, 76 insertions(+), 122 deletions(-)
---
base-commit: 2e0171396caa83c9d908ba2676ba59bce333b550
change-id: 20240709-thermal-probe-a747013ed28d
Best regards,
--
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 01/12] thermal/drivers/broadcom: fix race between removal and clock disable
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
@ 2024-07-09 12:59 ` Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 02/12] thermal/drivers/broadcom: simplify probe() with local dev variable Krzysztof Kozlowski
` (11 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, stable,
Krzysztof Kozlowski
During the probe, driver enables clocks necessary to access registers
(in get_temp()) and then registers thermal zone with managed-resources
(devm) interface. Removal of device is not done in reversed order,
because:
1. Clock will be disabled in driver remove() callback - thermal zone is
still registered and accessible to users,
2. devm interface will unregister thermal zone.
This leaves short window between (1) and (2) for accessing the
get_temp() callback with disabled clock.
Fix this by enabling clock also via devm-interface, so entire cleanup
path will be in proper, reversed order.
Fixes: 8454c8c09c77 ("thermal/drivers/bcm2835: Remove buggy call to thermal_of_zone_unregister")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/broadcom/bcm2835_thermal.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c
index 5c1cebe07580..3b1030fc4fbf 100644
--- a/drivers/thermal/broadcom/bcm2835_thermal.c
+++ b/drivers/thermal/broadcom/bcm2835_thermal.c
@@ -185,7 +185,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
return err;
}
- data->clk = devm_clk_get(&pdev->dev, NULL);
+ data->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(data->clk)) {
err = PTR_ERR(data->clk);
if (err != -EPROBE_DEFER)
@@ -193,10 +193,6 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
return err;
}
- err = clk_prepare_enable(data->clk);
- if (err)
- return err;
-
rate = clk_get_rate(data->clk);
if ((rate < 1920000) || (rate > 5000000))
dev_warn(&pdev->dev,
@@ -211,7 +207,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
dev_err(&pdev->dev,
"Failed to register the thermal device: %d\n",
err);
- goto err_clk;
+ return err;
}
/*
@@ -236,7 +232,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
dev_err(&pdev->dev,
"Not able to read trip_temp: %d\n",
err);
- goto err_tz;
+ return err;
}
/* set bandgap reference voltage and enable voltage regulator */
@@ -269,17 +265,11 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
*/
err = thermal_add_hwmon_sysfs(tz);
if (err)
- goto err_tz;
+ return err;
bcm2835_thermal_debugfs(pdev);
return 0;
-err_tz:
- devm_thermal_of_zone_unregister(&pdev->dev, tz);
-err_clk:
- clk_disable_unprepare(data->clk);
-
- return err;
}
static void bcm2835_thermal_remove(struct platform_device *pdev)
@@ -287,7 +277,6 @@ static void bcm2835_thermal_remove(struct platform_device *pdev)
struct bcm2835_thermal_data *data = platform_get_drvdata(pdev);
debugfs_remove_recursive(data->debugfsdir);
- clk_disable_unprepare(data->clk);
}
static struct platform_driver bcm2835_thermal_driver = {
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 02/12] thermal/drivers/broadcom: simplify probe() with local dev variable
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 01/12] thermal/drivers/broadcom: fix race between removal and clock disable Krzysztof Kozlowski
@ 2024-07-09 12:59 ` Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 03/12] thermal/drivers/broadcom: simplify with dev_err_probe() Krzysztof Kozlowski
` (10 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, Krzysztof Kozlowski
Simplify the probe() function by using local 'dev' instead of
&pdev->dev.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/broadcom/bcm2835_thermal.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c
index 3b1030fc4fbf..38fb0c8cd55e 100644
--- a/drivers/thermal/broadcom/bcm2835_thermal.c
+++ b/drivers/thermal/broadcom/bcm2835_thermal.c
@@ -163,6 +163,7 @@ MODULE_DEVICE_TABLE(of, bcm2835_thermal_of_match_table);
static int bcm2835_thermal_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
const struct of_device_id *match;
struct thermal_zone_device *tz;
struct bcm2835_thermal_data *data;
@@ -170,12 +171,11 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
u32 val;
unsigned long rate;
- data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
- match = of_match_device(bcm2835_thermal_of_match_table,
- &pdev->dev);
+ match = of_match_device(bcm2835_thermal_of_match_table, dev);
if (!match)
return -EINVAL;
@@ -185,28 +185,25 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
return err;
}
- data->clk = devm_clk_get_enabled(&pdev->dev, NULL);
+ data->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(data->clk)) {
err = PTR_ERR(data->clk);
if (err != -EPROBE_DEFER)
- dev_err(&pdev->dev, "Could not get clk: %d\n", err);
+ dev_err(dev, "Could not get clk: %d\n", err);
return err;
}
rate = clk_get_rate(data->clk);
if ((rate < 1920000) || (rate > 5000000))
- dev_warn(&pdev->dev,
+ dev_warn(dev,
"Clock %pCn running at %lu Hz is outside of the recommended range: 1.92 to 5MHz\n",
data->clk, rate);
/* register of thermal sensor and get info from DT */
- tz = devm_thermal_of_zone_register(&pdev->dev, 0, data,
- &bcm2835_thermal_ops);
+ tz = devm_thermal_of_zone_register(dev, 0, data, &bcm2835_thermal_ops);
if (IS_ERR(tz)) {
err = PTR_ERR(tz);
- dev_err(&pdev->dev,
- "Failed to register the thermal device: %d\n",
- err);
+ dev_err(dev, "Failed to register the thermal device: %d\n", err);
return err;
}
@@ -229,9 +226,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
*/
err = thermal_zone_get_trip(tz, 0, &trip);
if (err < 0) {
- dev_err(&pdev->dev,
- "Not able to read trip_temp: %d\n",
- err);
+ dev_err(dev, "Not able to read trip_temp: %d\n", err);
return err;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 03/12] thermal/drivers/broadcom: simplify with dev_err_probe()
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 01/12] thermal/drivers/broadcom: fix race between removal and clock disable Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 02/12] thermal/drivers/broadcom: simplify probe() with local dev variable Krzysztof Kozlowski
@ 2024-07-09 12:59 ` Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 04/12] thermal/drivers/exynos: simplify probe() with local dev variable Krzysztof Kozlowski
` (9 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, Krzysztof Kozlowski
Error handling in probe() can be a bit simpler with dev_err_probe().
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/broadcom/bcm2835_thermal.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c
index 38fb0c8cd55e..5ad87eb3f578 100644
--- a/drivers/thermal/broadcom/bcm2835_thermal.c
+++ b/drivers/thermal/broadcom/bcm2835_thermal.c
@@ -186,12 +186,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
}
data->clk = devm_clk_get_enabled(dev, NULL);
- if (IS_ERR(data->clk)) {
- err = PTR_ERR(data->clk);
- if (err != -EPROBE_DEFER)
- dev_err(dev, "Could not get clk: %d\n", err);
- return err;
- }
+ if (IS_ERR(data->clk))
+ return dev_err_probe(dev, PTR_ERR(data->clk), "Could not get clk\n");
rate = clk_get_rate(data->clk);
if ((rate < 1920000) || (rate > 5000000))
@@ -201,11 +197,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
/* register of thermal sensor and get info from DT */
tz = devm_thermal_of_zone_register(dev, 0, data, &bcm2835_thermal_ops);
- if (IS_ERR(tz)) {
- err = PTR_ERR(tz);
- dev_err(dev, "Failed to register the thermal device: %d\n", err);
- return err;
- }
+ if (IS_ERR(tz))
+ return dev_err_probe(dev, PTR_ERR(tz), "Failed to register the thermal device\n");
/*
* right now the FW does set up the HW-block, so we are not
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 04/12] thermal/drivers/exynos: simplify probe() with local dev variable
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
` (2 preceding siblings ...)
2024-07-09 12:59 ` [PATCH 03/12] thermal/drivers/broadcom: simplify with dev_err_probe() Krzysztof Kozlowski
@ 2024-07-09 12:59 ` Krzysztof Kozlowski
2024-07-10 10:30 ` Alim Akhtar
2024-07-09 12:59 ` [PATCH 05/12] thermal/drivers/exynos: simplify with dev_err_probe() Krzysztof Kozlowski
` (8 subsequent siblings)
12 siblings, 1 reply; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, Krzysztof Kozlowski
Simplify the probe() function by using local 'dev' instead of
&pdev->dev. While touching devm_kzalloc(), use preferred sizeof(*)
syntax.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/samsung/exynos_tmu.c | 42 +++++++++++++++++-------------------
1 file changed, 20 insertions(+), 22 deletions(-)
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 6482513bfe66..1152871cc982 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1004,11 +1004,11 @@ static const struct thermal_zone_device_ops exynos_sensor_ops = {
static int exynos_tmu_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct exynos_tmu_data *data;
int ret;
- data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
- GFP_KERNEL);
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
@@ -1020,7 +1020,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
* TODO: Add regulator as an SOC feature, so that regulator enable
* is a compulsory call.
*/
- ret = devm_regulator_get_enable_optional(&pdev->dev, "vtmu");
+ ret = devm_regulator_get_enable_optional(dev, "vtmu");
switch (ret) {
case 0:
case -ENODEV:
@@ -1028,8 +1028,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
case -EPROBE_DEFER:
return -EPROBE_DEFER;
default:
- dev_err(&pdev->dev, "Failed to get enabled regulator: %d\n",
- ret);
+ dev_err(dev, "Failed to get enabled regulator: %d\n", ret);
return ret;
}
@@ -1037,44 +1036,44 @@ static int exynos_tmu_probe(struct platform_device *pdev)
if (ret)
return ret;
- data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
+ data->clk = devm_clk_get(dev, "tmu_apbif");
if (IS_ERR(data->clk)) {
- dev_err(&pdev->dev, "Failed to get clock\n");
+ dev_err(dev, "Failed to get clock\n");
return PTR_ERR(data->clk);
}
- data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
+ data->clk_sec = devm_clk_get(dev, "tmu_triminfo_apbif");
if (IS_ERR(data->clk_sec)) {
if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
- dev_err(&pdev->dev, "Failed to get triminfo clock\n");
+ dev_err(dev, "Failed to get triminfo clock\n");
return PTR_ERR(data->clk_sec);
}
} else {
ret = clk_prepare(data->clk_sec);
if (ret) {
- dev_err(&pdev->dev, "Failed to get clock\n");
+ dev_err(dev, "Failed to get clock\n");
return ret;
}
}
ret = clk_prepare(data->clk);
if (ret) {
- dev_err(&pdev->dev, "Failed to get clock\n");
+ dev_err(dev, "Failed to get clock\n");
goto err_clk_sec;
}
switch (data->soc) {
case SOC_ARCH_EXYNOS5433:
case SOC_ARCH_EXYNOS7:
- data->sclk = devm_clk_get(&pdev->dev, "tmu_sclk");
+ data->sclk = devm_clk_get(dev, "tmu_sclk");
if (IS_ERR(data->sclk)) {
- dev_err(&pdev->dev, "Failed to get sclk\n");
+ dev_err(dev, "Failed to get sclk\n");
ret = PTR_ERR(data->sclk);
goto err_clk;
} else {
ret = clk_prepare_enable(data->sclk);
if (ret) {
- dev_err(&pdev->dev, "Failed to enable sclk\n");
+ dev_err(dev, "Failed to enable sclk\n");
goto err_clk;
}
}
@@ -1085,33 +1084,32 @@ static int exynos_tmu_probe(struct platform_device *pdev)
ret = exynos_tmu_initialize(pdev);
if (ret) {
- dev_err(&pdev->dev, "Failed to initialize TMU\n");
+ dev_err(dev, "Failed to initialize TMU\n");
goto err_sclk;
}
- data->tzd = devm_thermal_of_zone_register(&pdev->dev, 0, data,
+ data->tzd = devm_thermal_of_zone_register(dev, 0, data,
&exynos_sensor_ops);
if (IS_ERR(data->tzd)) {
ret = PTR_ERR(data->tzd);
if (ret != -EPROBE_DEFER)
- dev_err(&pdev->dev, "Failed to register sensor: %d\n",
- ret);
+ dev_err(dev, "Failed to register sensor: %d\n", ret);
goto err_sclk;
}
ret = exynos_thermal_zone_configure(pdev);
if (ret) {
- dev_err(&pdev->dev, "Failed to configure the thermal zone\n");
+ dev_err(dev, "Failed to configure the thermal zone\n");
goto err_sclk;
}
- ret = devm_request_threaded_irq(&pdev->dev, data->irq, NULL,
+ ret = devm_request_threaded_irq(dev, data->irq, NULL,
exynos_tmu_threaded_irq,
IRQF_TRIGGER_RISING
| IRQF_SHARED | IRQF_ONESHOT,
- dev_name(&pdev->dev), data);
+ dev_name(dev), data);
if (ret) {
- dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq);
+ dev_err(dev, "Failed to request irq: %d\n", data->irq);
goto err_sclk;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 05/12] thermal/drivers/exynos: simplify with dev_err_probe()
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
` (3 preceding siblings ...)
2024-07-09 12:59 ` [PATCH 04/12] thermal/drivers/exynos: simplify probe() with local dev variable Krzysztof Kozlowski
@ 2024-07-09 12:59 ` Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 06/12] thermal/drivers/hisi: " Krzysztof Kozlowski
` (7 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, Krzysztof Kozlowski
Error handling in probe() can be a bit simpler with dev_err_probe().
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/samsung/exynos_tmu.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 1152871cc982..96cffb2c44ba 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1037,17 +1037,14 @@ static int exynos_tmu_probe(struct platform_device *pdev)
return ret;
data->clk = devm_clk_get(dev, "tmu_apbif");
- if (IS_ERR(data->clk)) {
- dev_err(dev, "Failed to get clock\n");
- return PTR_ERR(data->clk);
- }
+ if (IS_ERR(data->clk))
+ return dev_err_probe(dev, PTR_ERR(data->clk), "Failed to get clock\n");
data->clk_sec = devm_clk_get(dev, "tmu_triminfo_apbif");
if (IS_ERR(data->clk_sec)) {
- if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
- dev_err(dev, "Failed to get triminfo clock\n");
- return PTR_ERR(data->clk_sec);
- }
+ if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO)
+ return dev_err_probe(dev, PTR_ERR(data->clk_sec),
+ "Failed to get triminfo clock\n");
} else {
ret = clk_prepare(data->clk_sec);
if (ret) {
@@ -1067,8 +1064,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
case SOC_ARCH_EXYNOS7:
data->sclk = devm_clk_get(dev, "tmu_sclk");
if (IS_ERR(data->sclk)) {
- dev_err(dev, "Failed to get sclk\n");
- ret = PTR_ERR(data->sclk);
+ ret = dev_err_probe(dev, PTR_ERR(data->sclk), "Failed to get sclk\n");
goto err_clk;
} else {
ret = clk_prepare_enable(data->sclk);
@@ -1091,9 +1087,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
data->tzd = devm_thermal_of_zone_register(dev, 0, data,
&exynos_sensor_ops);
if (IS_ERR(data->tzd)) {
- ret = PTR_ERR(data->tzd);
- if (ret != -EPROBE_DEFER)
- dev_err(dev, "Failed to register sensor: %d\n", ret);
+ ret = dev_err_probe(dev, PTR_ERR(data->tzd), "Failed to register sensor\n");
goto err_sclk;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 06/12] thermal/drivers/hisi: simplify with dev_err_probe()
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
` (4 preceding siblings ...)
2024-07-09 12:59 ` [PATCH 05/12] thermal/drivers/exynos: simplify with dev_err_probe() Krzysztof Kozlowski
@ 2024-07-09 12:59 ` Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 07/12] thermal/drivers/imx: simplify probe() with local dev variable Krzysztof Kozlowski
` (6 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, Krzysztof Kozlowski
Error handling in probe() can be a bit simpler with dev_err_probe().
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/hisi_thermal.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index dd751ae63608..0eb657db62e4 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -388,15 +388,10 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data)
{
struct platform_device *pdev = data->pdev;
struct device *dev = &pdev->dev;
- int ret;
data->clk = devm_clk_get(dev, "thermal_clk");
- if (IS_ERR(data->clk)) {
- ret = PTR_ERR(data->clk);
- if (ret != -EPROBE_DEFER)
- dev_err(dev, "failed to get thermal clk: %d\n", ret);
- return ret;
- }
+ if (IS_ERR(data->clk))
+ return dev_err_probe(dev, PTR_ERR(data->clk), "failed to get thermal clk\n");
data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL);
if (!data->sensor)
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 07/12] thermal/drivers/imx: simplify probe() with local dev variable
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
` (5 preceding siblings ...)
2024-07-09 12:59 ` [PATCH 06/12] thermal/drivers/hisi: " Krzysztof Kozlowski
@ 2024-07-09 12:59 ` Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 08/12] thermal/drivers/imx: simplify with dev_err_probe() Krzysztof Kozlowski
` (5 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, Krzysztof Kozlowski
Simplify the probe() function by using local 'dev' instead of
&pdev->dev.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/imx_thermal.c | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 83eaae5ca3b8..05c24be5343f 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -601,28 +601,29 @@ static inline void imx_thermal_unregister_legacy_cooling(struct imx_thermal_data
static int imx_thermal_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct imx_thermal_data *data;
struct regmap *map;
int measure_freq;
int ret;
- data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
- data->dev = &pdev->dev;
+ data->dev = dev;
- map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "fsl,tempmon");
+ map = syscon_regmap_lookup_by_phandle(dev->of_node, "fsl,tempmon");
if (IS_ERR(map)) {
ret = PTR_ERR(map);
- dev_err(&pdev->dev, "failed to get tempmon regmap: %d\n", ret);
+ dev_err(dev, "failed to get tempmon regmap: %d\n", ret);
return ret;
}
data->tempmon = map;
- data->socdata = of_device_get_match_data(&pdev->dev);
+ data->socdata = of_device_get_match_data(dev);
if (!data->socdata) {
- dev_err(&pdev->dev, "no device match found\n");
+ dev_err(dev, "no device match found\n");
return -ENODEV;
}
@@ -645,15 +646,15 @@ static int imx_thermal_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, data);
- if (of_property_present(pdev->dev.of_node, "nvmem-cells")) {
+ if (of_property_present(dev->of_node, "nvmem-cells")) {
ret = imx_init_from_nvmem_cells(pdev);
if (ret)
- return dev_err_probe(&pdev->dev, ret,
+ return dev_err_probe(dev, ret,
"failed to init from nvmem\n");
} else {
ret = imx_init_from_tempmon_data(pdev);
if (ret) {
- dev_err(&pdev->dev, "failed to init from fsl,tempmon-data\n");
+ dev_err(dev, "failed to init from fsl,tempmon-data\n");
return ret;
}
}
@@ -673,15 +674,14 @@ static int imx_thermal_probe(struct platform_device *pdev)
ret = imx_thermal_register_legacy_cooling(data);
if (ret)
- return dev_err_probe(&pdev->dev, ret,
+ return dev_err_probe(dev, ret,
"failed to register cpufreq cooling device\n");
- data->thermal_clk = devm_clk_get(&pdev->dev, NULL);
+ data->thermal_clk = devm_clk_get(dev, NULL);
if (IS_ERR(data->thermal_clk)) {
ret = PTR_ERR(data->thermal_clk);
if (ret != -EPROBE_DEFER)
- dev_err(&pdev->dev,
- "failed to get thermal clk: %d\n", ret);
+ dev_err(dev, "failed to get thermal clk: %d\n", ret);
goto legacy_cleanup;
}
@@ -694,7 +694,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
*/
ret = clk_prepare_enable(data->thermal_clk);
if (ret) {
- dev_err(&pdev->dev, "failed to enable thermal clk: %d\n", ret);
+ dev_err(dev, "failed to enable thermal clk: %d\n", ret);
goto legacy_cleanup;
}
@@ -707,12 +707,12 @@ static int imx_thermal_probe(struct platform_device *pdev)
IMX_POLLING_DELAY);
if (IS_ERR(data->tz)) {
ret = PTR_ERR(data->tz);
- dev_err(&pdev->dev,
- "failed to register thermal zone device %d\n", ret);
+ dev_err(dev, "failed to register thermal zone device %d\n",
+ ret);
goto clk_disable;
}
- dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC"
+ dev_info(dev, "%s CPU temperature grade - max:%dC"
" critical:%dC passive:%dC\n", data->temp_grade,
data->temp_max / 1000, trips[IMX_TRIP_CRITICAL].temperature / 1000,
trips[IMX_TRIP_PASSIVE].temperature / 1000);
@@ -736,7 +736,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
usleep_range(20, 50);
/* the core was configured and enabled just before */
- pm_runtime_set_active(&pdev->dev);
+ pm_runtime_set_active(dev);
pm_runtime_enable(data->dev);
ret = pm_runtime_resume_and_get(data->dev);
@@ -748,11 +748,11 @@ static int imx_thermal_probe(struct platform_device *pdev)
if (ret)
goto thermal_zone_unregister;
- ret = devm_request_threaded_irq(&pdev->dev, data->irq,
+ ret = devm_request_threaded_irq(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);
+ dev_err(dev, "failed to request alarm irq: %d\n", ret);
goto thermal_zone_unregister;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 08/12] thermal/drivers/imx: simplify with dev_err_probe()
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
` (6 preceding siblings ...)
2024-07-09 12:59 ` [PATCH 07/12] thermal/drivers/imx: simplify probe() with local dev variable Krzysztof Kozlowski
@ 2024-07-09 12:59 ` Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 09/12] thermal/drivers/qcom-spmi-adc-tm5: " Krzysztof Kozlowski
` (4 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, Krzysztof Kozlowski
Error handling in probe() can be a bit simpler with dev_err_probe().
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/imx_thermal.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 05c24be5343f..432d21cbd2b3 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -679,9 +679,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
data->thermal_clk = devm_clk_get(dev, NULL);
if (IS_ERR(data->thermal_clk)) {
- ret = PTR_ERR(data->thermal_clk);
- if (ret != -EPROBE_DEFER)
- dev_err(dev, "failed to get thermal clk: %d\n", ret);
+ ret = dev_err_probe(dev, PTR_ERR(data->thermal_clk), "failed to get thermal clk\n");
goto legacy_cleanup;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 09/12] thermal/drivers/qcom-spmi-adc-tm5: simplify with dev_err_probe()
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
` (7 preceding siblings ...)
2024-07-09 12:59 ` [PATCH 08/12] thermal/drivers/imx: simplify with dev_err_probe() Krzysztof Kozlowski
@ 2024-07-09 12:59 ` Krzysztof Kozlowski
2024-07-09 19:11 ` Bjorn Andersson
2024-07-09 12:59 ` [PATCH 10/12] thermal/drivers/qcom-tsens: " Krzysztof Kozlowski
` (3 subsequent siblings)
12 siblings, 1 reply; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, Krzysztof Kozlowski
Error handling in probe() can be a bit simpler with dev_err_probe().
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
index 756ac6842ff9..7c9f4023babc 100644
--- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
+++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
@@ -829,12 +829,9 @@ static int adc_tm5_get_dt_channel_data(struct adc_tm5_chip *adc_tm,
channel->iio = devm_fwnode_iio_channel_get_by_name(adc_tm->dev,
of_fwnode_handle(node), NULL);
- if (IS_ERR(channel->iio)) {
- ret = PTR_ERR(channel->iio);
- if (ret != -EPROBE_DEFER)
- dev_err(dev, "%s: error getting channel: %d\n", name, ret);
- return ret;
- }
+ if (IS_ERR(channel->iio))
+ return dev_err_probe(dev, PTR_ERR(channel->iio), "%s: error getting channel\n",
+ name);
ret = of_property_read_u32_array(node, "qcom,pre-scaling", varr, 2);
if (!ret) {
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 10/12] thermal/drivers/qcom-tsens: simplify with dev_err_probe()
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
` (8 preceding siblings ...)
2024-07-09 12:59 ` [PATCH 09/12] thermal/drivers/qcom-spmi-adc-tm5: " Krzysztof Kozlowski
@ 2024-07-09 12:59 ` Krzysztof Kozlowski
2024-07-09 19:12 ` Bjorn Andersson
2024-07-09 12:59 ` [PATCH 11/12] thermal/drivers/generic-adc: simplify probe() with local dev variable Krzysztof Kozlowski
` (2 subsequent siblings)
12 siblings, 1 reply; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, Krzysztof Kozlowski
Error handling in probe() can be a bit simpler with dev_err_probe().
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/qcom/tsens.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index e76e23026dc8..0b4421bf4785 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -1336,11 +1336,9 @@ static int tsens_probe(struct platform_device *pdev)
if (priv->ops->calibrate) {
ret = priv->ops->calibrate(priv);
- if (ret < 0) {
- if (ret != -EPROBE_DEFER)
- dev_err(dev, "%s: calibration failed\n", __func__);
- return ret;
- }
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "%s: calibration failed\n",
+ __func__);
}
ret = tsens_register(priv);
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 11/12] thermal/drivers/generic-adc: simplify probe() with local dev variable
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
` (9 preceding siblings ...)
2024-07-09 12:59 ` [PATCH 10/12] thermal/drivers/qcom-tsens: " Krzysztof Kozlowski
@ 2024-07-09 12:59 ` Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 12/12] thermal/drivers/generic-adc: simplify with dev_err_probe() Krzysztof Kozlowski
2024-07-15 9:21 ` [PATCH 00/12] thermal/drivers: simplify probe() Daniel Lezcano
12 siblings, 0 replies; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, Krzysztof Kozlowski
Simplify the probe() function by using local 'dev' instead of
&pdev->dev.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/thermal-generic-adc.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/thermal-generic-adc.c
index 1717e4a19dcb..d08bff91ac3d 100644
--- a/drivers/thermal/thermal-generic-adc.c
+++ b/drivers/thermal/thermal-generic-adc.c
@@ -117,44 +117,45 @@ static int gadc_thermal_read_linear_lookup_table(struct device *dev,
static int gadc_thermal_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct gadc_thermal_info *gti;
int ret;
- if (!pdev->dev.of_node) {
- dev_err(&pdev->dev, "Only DT based supported\n");
+ if (!dev->of_node) {
+ dev_err(dev, "Only DT based supported\n");
return -ENODEV;
}
- gti = devm_kzalloc(&pdev->dev, sizeof(*gti), GFP_KERNEL);
+ gti = devm_kzalloc(dev, sizeof(*gti), GFP_KERNEL);
if (!gti)
return -ENOMEM;
- gti->channel = devm_iio_channel_get(&pdev->dev, "sensor-channel");
+ gti->channel = devm_iio_channel_get(dev, "sensor-channel");
if (IS_ERR(gti->channel)) {
ret = PTR_ERR(gti->channel);
if (ret != -EPROBE_DEFER)
- dev_err(&pdev->dev, "IIO channel not found: %d\n", ret);
+ dev_err(dev, "IIO channel not found: %d\n", ret);
return ret;
}
- ret = gadc_thermal_read_linear_lookup_table(&pdev->dev, gti);
+ ret = gadc_thermal_read_linear_lookup_table(dev, gti);
if (ret < 0)
return ret;
- gti->dev = &pdev->dev;
+ gti->dev = dev;
- gti->tz_dev = devm_thermal_of_zone_register(&pdev->dev, 0, gti,
+ gti->tz_dev = devm_thermal_of_zone_register(dev, 0, gti,
&gadc_thermal_ops);
if (IS_ERR(gti->tz_dev)) {
ret = PTR_ERR(gti->tz_dev);
if (ret != -EPROBE_DEFER)
- dev_err(&pdev->dev,
+ dev_err(dev,
"Thermal zone sensor register failed: %d\n",
ret);
return ret;
}
- devm_thermal_add_hwmon_sysfs(&pdev->dev, gti->tz_dev);
+ devm_thermal_add_hwmon_sysfs(dev, gti->tz_dev);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 12/12] thermal/drivers/generic-adc: simplify with dev_err_probe()
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
` (10 preceding siblings ...)
2024-07-09 12:59 ` [PATCH 11/12] thermal/drivers/generic-adc: simplify probe() with local dev variable Krzysztof Kozlowski
@ 2024-07-09 12:59 ` Krzysztof Kozlowski
2024-07-15 9:21 ` [PATCH 00/12] thermal/drivers: simplify probe() Daniel Lezcano
12 siblings, 0 replies; 17+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-09 12:59 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, Krzysztof Kozlowski
Error handling in probe() can be a bit simpler with dev_err_probe().
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/thermal-generic-adc.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/thermal-generic-adc.c
index d08bff91ac3d..ee3d0aa31406 100644
--- a/drivers/thermal/thermal-generic-adc.c
+++ b/drivers/thermal/thermal-generic-adc.c
@@ -131,12 +131,8 @@ static int gadc_thermal_probe(struct platform_device *pdev)
return -ENOMEM;
gti->channel = devm_iio_channel_get(dev, "sensor-channel");
- if (IS_ERR(gti->channel)) {
- ret = PTR_ERR(gti->channel);
- if (ret != -EPROBE_DEFER)
- dev_err(dev, "IIO channel not found: %d\n", ret);
- return ret;
- }
+ if (IS_ERR(gti->channel))
+ return dev_err_probe(dev, PTR_ERR(gti->channel), "IIO channel not found\n");
ret = gadc_thermal_read_linear_lookup_table(dev, gti);
if (ret < 0)
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 09/12] thermal/drivers/qcom-spmi-adc-tm5: simplify with dev_err_probe()
2024-07-09 12:59 ` [PATCH 09/12] thermal/drivers/qcom-spmi-adc-tm5: " Krzysztof Kozlowski
@ 2024-07-09 19:11 ` Bjorn Andersson
0 siblings, 0 replies; 17+ messages in thread
From: Bjorn Andersson @ 2024-07-09 19:11 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath, linux-pm, linux-rpi-kernel, linux-arm-kernel,
linux-kernel, linux-samsung-soc, imx, linux-arm-msm
On Tue, Jul 09, 2024 at 02:59:39PM GMT, Krzysztof Kozlowski wrote:
> Error handling in probe() can be a bit simpler with dev_err_probe().
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Regards,
Bjorn
> ---
> drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
> index 756ac6842ff9..7c9f4023babc 100644
> --- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
> +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
> @@ -829,12 +829,9 @@ static int adc_tm5_get_dt_channel_data(struct adc_tm5_chip *adc_tm,
>
> channel->iio = devm_fwnode_iio_channel_get_by_name(adc_tm->dev,
> of_fwnode_handle(node), NULL);
> - if (IS_ERR(channel->iio)) {
> - ret = PTR_ERR(channel->iio);
> - if (ret != -EPROBE_DEFER)
> - dev_err(dev, "%s: error getting channel: %d\n", name, ret);
> - return ret;
> - }
> + if (IS_ERR(channel->iio))
> + return dev_err_probe(dev, PTR_ERR(channel->iio), "%s: error getting channel\n",
> + name);
>
> ret = of_property_read_u32_array(node, "qcom,pre-scaling", varr, 2);
> if (!ret) {
>
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 10/12] thermal/drivers/qcom-tsens: simplify with dev_err_probe()
2024-07-09 12:59 ` [PATCH 10/12] thermal/drivers/qcom-tsens: " Krzysztof Kozlowski
@ 2024-07-09 19:12 ` Bjorn Andersson
0 siblings, 0 replies; 17+ messages in thread
From: Bjorn Andersson @ 2024-07-09 19:12 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath, linux-pm, linux-rpi-kernel, linux-arm-kernel,
linux-kernel, linux-samsung-soc, imx, linux-arm-msm
On Tue, Jul 09, 2024 at 02:59:40PM GMT, Krzysztof Kozlowski wrote:
> Error handling in probe() can be a bit simpler with dev_err_probe().
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Regards,
Bjorn
> ---
> drivers/thermal/qcom/tsens.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index e76e23026dc8..0b4421bf4785 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -1336,11 +1336,9 @@ static int tsens_probe(struct platform_device *pdev)
>
> if (priv->ops->calibrate) {
> ret = priv->ops->calibrate(priv);
> - if (ret < 0) {
> - if (ret != -EPROBE_DEFER)
> - dev_err(dev, "%s: calibration failed\n", __func__);
> - return ret;
> - }
> + if (ret < 0)
> + return dev_err_probe(dev, ret, "%s: calibration failed\n",
> + __func__);
> }
>
> ret = tsens_register(priv);
>
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: [PATCH 04/12] thermal/drivers/exynos: simplify probe() with local dev variable
2024-07-09 12:59 ` [PATCH 04/12] thermal/drivers/exynos: simplify probe() with local dev variable Krzysztof Kozlowski
@ 2024-07-10 10:30 ` Alim Akhtar
0 siblings, 0 replies; 17+ messages in thread
From: Alim Akhtar @ 2024-07-10 10:30 UTC (permalink / raw)
To: 'Krzysztof Kozlowski', 'Rafael J. Wysocki',
'Daniel Lezcano', 'Zhang Rui',
'Lukasz Luba', 'Florian Fainelli',
'Ray Jui', 'Scott Branden',
'Broadcom internal kernel review list',
'Bartlomiej Zolnierkiewicz',
'Krzysztof Kozlowski', 'Shawn Guo',
'Sascha Hauer', 'Pengutronix Kernel Team',
'Fabio Estevam', 'Amit Kucheria',
'Thara Gopinath'
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm
Hello Krzysztof
> -----Original Message-----
> From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Sent: Tuesday, July 9, 2024 6:30 PM
> To: Rafael J. Wysocki <rafael@kernel.org>; Daniel Lezcano
> <daniel.lezcano@linaro.org>; Zhang Rui <rui.zhang@intel.com>; Lukasz Luba
> <lukasz.luba@arm.com>; Florian Fainelli <florian.fainelli@broadcom.com>;
> Ray Jui <rjui@broadcom.com>; Scott Branden <sbranden@broadcom.com>;
> Broadcom internal kernel review list <bcm-kernel-feedback-
> list@broadcom.com>; Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>;
> Krzysztof Kozlowski <krzk@kernel.org>; Alim Akhtar
> <alim.akhtar@samsung.com>; Shawn Guo <shawnguo@kernel.org>; Sascha
> Hauer <s.hauer@pengutronix.de>; Pengutronix Kernel Team
> <kernel@pengutronix.de>; Fabio Estevam <festevam@gmail.com>; Amit
> Kucheria <amitk@kernel.org>; Thara Gopinath <thara.gopinath@gmail.com>
> Cc: linux-pm@vger.kernel.org; linux-rpi-kernel@lists.infradead.org; linux-
> arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; linux-
> samsung-soc@vger.kernel.org; imx@lists.linux.dev; linux-arm-
> msm@vger.kernel.org; Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org>
> Subject: [PATCH 04/12] thermal/drivers/exynos: simplify probe() with local
> dev variable
>
> Simplify the probe() function by using local 'dev' instead of &pdev->dev.
> While touching devm_kzalloc(), use preferred sizeof(*) syntax.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
> drivers/thermal/samsung/exynos_tmu.c | 42 +++++++++++++++++----------
> ---------
> 1 file changed, 20 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/thermal/samsung/exynos_tmu.c
> b/drivers/thermal/samsung/exynos_tmu.c
> index 6482513bfe66..1152871cc982 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -1004,11 +1004,11 @@ static const struct thermal_zone_device_ops
> exynos_sensor_ops = {
>
> static int exynos_tmu_probe(struct platform_device *pdev) {
> + struct device *dev = &pdev->dev;
> struct exynos_tmu_data *data;
> int ret;
>
> - data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
> - GFP_KERNEL);
> + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> if (!data)
> return -ENOMEM;
>
> @@ -1020,7 +1020,7 @@ static int exynos_tmu_probe(struct
> platform_device *pdev)
> * TODO: Add regulator as an SOC feature, so that regulator enable
> * is a compulsory call.
> */
> - ret = devm_regulator_get_enable_optional(&pdev->dev, "vtmu");
> + ret = devm_regulator_get_enable_optional(dev, "vtmu");
> switch (ret) {
> case 0:
> case -ENODEV:
> @@ -1028,8 +1028,7 @@ static int exynos_tmu_probe(struct
> platform_device *pdev)
> case -EPROBE_DEFER:
> return -EPROBE_DEFER;
> default:
> - dev_err(&pdev->dev, "Failed to get enabled regulator:
> %d\n",
> - ret);
> + dev_err(dev, "Failed to get enabled regulator: %d\n", ret);
> return ret;
> }
>
> @@ -1037,44 +1036,44 @@ static int exynos_tmu_probe(struct
> platform_device *pdev)
> if (ret)
> return ret;
>
> - data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
> + data->clk = devm_clk_get(dev, "tmu_apbif");
> if (IS_ERR(data->clk)) {
> - dev_err(&pdev->dev, "Failed to get clock\n");
> + dev_err(dev, "Failed to get clock\n");
> return PTR_ERR(data->clk);
> }
>
> - data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
> + data->clk_sec = devm_clk_get(dev, "tmu_triminfo_apbif");
> if (IS_ERR(data->clk_sec)) {
> if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
> - dev_err(&pdev->dev, "Failed to get triminfo
> clock\n");
> + dev_err(dev, "Failed to get triminfo clock\n");
> return PTR_ERR(data->clk_sec);
> }
> } else {
> ret = clk_prepare(data->clk_sec);
> if (ret) {
> - dev_err(&pdev->dev, "Failed to get clock\n");
> + dev_err(dev, "Failed to get clock\n");
> return ret;
> }
> }
>
> ret = clk_prepare(data->clk);
> if (ret) {
> - dev_err(&pdev->dev, "Failed to get clock\n");
> + dev_err(dev, "Failed to get clock\n");
> goto err_clk_sec;
> }
>
> switch (data->soc) {
> case SOC_ARCH_EXYNOS5433:
> case SOC_ARCH_EXYNOS7:
> - data->sclk = devm_clk_get(&pdev->dev, "tmu_sclk");
> + data->sclk = devm_clk_get(dev, "tmu_sclk");
> if (IS_ERR(data->sclk)) {
> - dev_err(&pdev->dev, "Failed to get sclk\n");
> + dev_err(dev, "Failed to get sclk\n");
> ret = PTR_ERR(data->sclk);
> goto err_clk;
> } else {
> ret = clk_prepare_enable(data->sclk);
> if (ret) {
> - dev_err(&pdev->dev, "Failed to enable
> sclk\n");
> + dev_err(dev, "Failed to enable sclk\n");
> goto err_clk;
> }
> }
> @@ -1085,33 +1084,32 @@ static int exynos_tmu_probe(struct
> platform_device *pdev)
>
> ret = exynos_tmu_initialize(pdev);
> if (ret) {
> - dev_err(&pdev->dev, "Failed to initialize TMU\n");
> + dev_err(dev, "Failed to initialize TMU\n");
> goto err_sclk;
> }
>
> - data->tzd = devm_thermal_of_zone_register(&pdev->dev, 0, data,
> + data->tzd = devm_thermal_of_zone_register(dev, 0, data,
> &exynos_sensor_ops);
> if (IS_ERR(data->tzd)) {
> ret = PTR_ERR(data->tzd);
> if (ret != -EPROBE_DEFER)
> - dev_err(&pdev->dev, "Failed to register sensor:
> %d\n",
> - ret);
> + dev_err(dev, "Failed to register sensor: %d\n", ret);
> goto err_sclk;
> }
>
> ret = exynos_thermal_zone_configure(pdev);
> if (ret) {
> - dev_err(&pdev->dev, "Failed to configure the thermal
> zone\n");
> + dev_err(dev, "Failed to configure the thermal zone\n");
> goto err_sclk;
> }
>
> - ret = devm_request_threaded_irq(&pdev->dev, data->irq, NULL,
> + ret = devm_request_threaded_irq(dev, data->irq, NULL,
> exynos_tmu_threaded_irq,
> IRQF_TRIGGER_RISING
> | IRQF_SHARED |
> IRQF_ONESHOT,
> - dev_name(&pdev->dev), data);
> + dev_name(dev), data);
> if (ret) {
> - dev_err(&pdev->dev, "Failed to request irq: %d\n", data-
> >irq);
> + dev_err(dev, "Failed to request irq: %d\n", data->irq);
> goto err_sclk;
> }
>
>
> --
> 2.43.0
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 00/12] thermal/drivers: simplify probe()
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
` (11 preceding siblings ...)
2024-07-09 12:59 ` [PATCH 12/12] thermal/drivers/generic-adc: simplify with dev_err_probe() Krzysztof Kozlowski
@ 2024-07-15 9:21 ` Daniel Lezcano
12 siblings, 0 replies; 17+ messages in thread
From: Daniel Lezcano @ 2024-07-15 9:21 UTC (permalink / raw)
To: Krzysztof Kozlowski, Rafael J. Wysocki, Zhang Rui, Lukasz Luba,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Alim Akhtar, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Amit Kucheria,
Thara Gopinath
Cc: linux-pm, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
linux-samsung-soc, imx, linux-arm-msm, stable
On 09/07/2024 14:59, Krzysztof Kozlowski wrote:
> Simplify error handling in probe() and also fix one possible issue in
> remove().
>
> Best regards,
> Krzysztof
>
> ---
Applied, thanks
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2024-07-15 9:22 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-09 12:59 [PATCH 00/12] thermal/drivers: simplify probe() Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 01/12] thermal/drivers/broadcom: fix race between removal and clock disable Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 02/12] thermal/drivers/broadcom: simplify probe() with local dev variable Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 03/12] thermal/drivers/broadcom: simplify with dev_err_probe() Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 04/12] thermal/drivers/exynos: simplify probe() with local dev variable Krzysztof Kozlowski
2024-07-10 10:30 ` Alim Akhtar
2024-07-09 12:59 ` [PATCH 05/12] thermal/drivers/exynos: simplify with dev_err_probe() Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 06/12] thermal/drivers/hisi: " Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 07/12] thermal/drivers/imx: simplify probe() with local dev variable Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 08/12] thermal/drivers/imx: simplify with dev_err_probe() Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 09/12] thermal/drivers/qcom-spmi-adc-tm5: " Krzysztof Kozlowski
2024-07-09 19:11 ` Bjorn Andersson
2024-07-09 12:59 ` [PATCH 10/12] thermal/drivers/qcom-tsens: " Krzysztof Kozlowski
2024-07-09 19:12 ` Bjorn Andersson
2024-07-09 12:59 ` [PATCH 11/12] thermal/drivers/generic-adc: simplify probe() with local dev variable Krzysztof Kozlowski
2024-07-09 12:59 ` [PATCH 12/12] thermal/drivers/generic-adc: simplify with dev_err_probe() Krzysztof Kozlowski
2024-07-15 9:21 ` [PATCH 00/12] thermal/drivers: simplify probe() Daniel Lezcano
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).