Skip to contentSkip to conversation

PM: Use %pe to print error pointers symbolically

PATCH Applied Sumeet Pawnikar 6 participants 13 messages Sep 12 – Nov 13

Subsystems (16)
lore
Share & tools
lore
#0 lore raw

v2 cover PM: Use %pe to print error pointers symbolically

This patch series is a cleanup for subsystems under power management (linux-pm) that converts several instances of error pointer printing to use the %pe format specifier instead of explicitly casting with PTR_ERR().

Currently, many drivers use PTR_ERR() paired with %ld or %li to print error codes returned as pointers. By switching to %pe and passing the error pointer directly, the logging subsystem will automatically print the symbolic error name (e.g., -ENOMEM, -EPROBE_DEFER) when CONFIG_SYMBOLIC_ERRNAME is enabled, and gracefully fall back to the numeric value otherwise.

This change significantly improves the readability of kernel logs and dmesg traces during debugging, without introducing any functional changes or side effects.

The cleanup has been applied across the following PM subsystems/drivers:
* powercap (intel_rapl_msr)
* thermal (cpufreq_cooling, devfreq_cooling, qcom)
* cpufreq (bmips, cppc, qoriq, s3c64xx)
* devfreq (imx-bus, imx8m-ddrc)
* power/supply (various battery and charger drivers)

---
changes in v2:
- Krzysztof kozlowski suggested to use dev_err_probe instead of dev_err for *_probe() functions during review of v1 series. This will be done in different patch series.
- Here in v2, reverted the changes for dev_err under *_probe() functions.

- Link to v1: https://lore.kernel.org/all/[email protected]/

---

Sumeet Pawnikar (5):
power: Use %pe to print error pointers symbolically
devfreq: Use %pe to print error pointers symbolically
cpufreq: Use %pe to print error pointers symbolically
thermal: Use %pe to print error pointers symbolically
powercap: intel_rapl: Use %pe to print error pointers symbolically

 drivers/cpufreq/bmips-cpufreq.c            | 4 ++--
 drivers/cpufreq/cppc_cpufreq.c             | 4 ++--
 drivers/cpufreq/qoriq-cpufreq.c            | 4 ++--
 drivers/cpufreq/s3c64xx-cpufreq.c          | 5 ++---
 drivers/devfreq/imx-bus.c                  | 4 ++--
 drivers/devfreq/imx8m-ddrc.c               | 3 +--
 drivers/power/reset/macsmc-reboot.c        | 4 ++--
 drivers/power/supply/cpcap-charger.c       | 4 ++--
 drivers/power/supply/intel_dc_ti_battery.c | 2 +-
 drivers/power/supply/qcom_smbx.c           | 2 +-
 drivers/powercap/intel_rapl_msr.c          | 4 ++--
 drivers/thermal/cpufreq_cooling.c          | 4 ++--
 drivers/thermal/devfreq_cooling.c          | 4 ++--
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c   | 4 ++--
 14 files changed, 25 insertions(+), 27 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/5 power: Use %pe to print error pointers symbolically

Replace PTR_ERR() and %ld/%li with %pe and pass the original pointer directly to dev_info(), dev_Warn and dev_dbg(). The %pe format specifier prints a symbolic error name (e.g. -ENOMEM) when CONFIG_SYMBOLIC_ERRNAME is enabled, otherwise it falls back gracefully and prints the raw integer value. This makes messages more readable without any functional change.

---
 drivers/power/reset/macsmc-reboot.c        | 4 ++--
 drivers/power/supply/cpcap-charger.c       | 4 ++--
 drivers/power/supply/intel_dc_ti_battery.c | 2 +-
 drivers/power/supply/qcom_smbx.c           | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/power/reset/macsmc-reboot.c +2 -2
index 9fc36fa68676..7b8460a55e9d 100644
@@ -221,8 +221,8 @@ static int macsmc_reboot_probe(struct platform_device *pdev)
 		if (IS_ERR(cell)) {
 			if (PTR_ERR(cell) == -EPROBE_DEFER)
 				return -EPROBE_DEFER;
-			dev_warn(&pdev->dev, "Missing NVMEM cell %s (%ld)\n",
-				 nvmem_names[i], PTR_ERR(cell));
+			dev_warn(&pdev->dev, "Missing NVMEM cell %s (%pe)\n",
+				 nvmem_names[i], cell);
 			/* Non fatal, we'll deal with it */
 			cell = NULL;
 		}
drivers/power/supply/cpcap-charger.c +2 -2
index 34a57dd5c3cf..d423a8bdc0c2 100644
@@ -808,8 +808,8 @@ static void cpcap_charger_init_optional_gpios(struct cpcap_charger_ddata *ddata)
 		ddata->gpio[i] = devm_gpiod_get_index(ddata->dev, "mode",
 						      i, GPIOD_OUT_HIGH);
 		if (IS_ERR(ddata->gpio[i])) {
-			dev_info(ddata->dev, "no mode change GPIO%i: %li\n",
-				 i, PTR_ERR(ddata->gpio[i]));
+			dev_info(ddata->dev, "no mode change GPIO%i: %pe\n",
+				 i, ddata->gpio[i]);
 			ddata->gpio[i] = NULL;
 		}
 	}
drivers/power/supply/intel_dc_ti_battery.c +1 -1
index cb6fa8d88b43..5819df23a543 100644
@@ -349,7 +349,7 @@ static int dc_ti_battery_probe(struct platform_device *pdev)
 
 	chip->vbat_channel = devm_iio_channel_get(dev, "VBAT");
 	if (IS_ERR(chip->vbat_channel)) {
-		dev_dbg(dev, "devm_iio_channel_get() ret %ld\n", PTR_ERR(chip->vbat_channel));
+		dev_dbg(dev, "devm_iio_channel_get() ret %pe\n", chip->vbat_channel);
 		return dev_err_probe(dev, -EPROBE_DEFER, "Waiting for VBAT IIO channel\n");
 	}
 
drivers/power/supply/qcom_smbx.c +1 -1
index 67fdb4335338..c8e242341d04 100644
@@ -613,7 +613,7 @@ static int smb_get_iio_chan(struct smb_chip *chip, struct iio_channel *chan,
 	}
 
 	if (IS_ERR(chan)) {
-		dev_err(chip->dev, "Failed to chan, err = %li", PTR_ERR(chan));
+		dev_err(chip->dev, "Failed to chan, err = %pe", chan);
 		return PTR_ERR(chan);
 	}
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/5 devfreq: Use %pe to print error pointers symbolically

In reply to Sumeet Pawnikar

Replace PTR_ERR() and %ld with %pe and pass the original pointer directly to dev_err(). The %pe format specifier prints a symbolic error name (e.g. -ENOMEM) when CONFIG_SYMBOLIC_ERRNAME is enabled, otherwise it falls back gracefully and prints the raw integer value. This makes messages more readable without any functional change.

---
 drivers/devfreq/imx-bus.c    | 4 ++--
 drivers/devfreq/imx8m-ddrc.c | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/devfreq/imx-bus.c +2 -2
index 49798f542d68..dba76d8b9e5a 100644
@@ -75,8 +75,8 @@ static int imx_bus_init_icc(struct device *dev)
 	priv->icc_pdev = platform_device_register_data(
 			dev, icc_driver_name, -1, NULL, 0);
 	if (IS_ERR(priv->icc_pdev)) {
-		dev_err(dev, "failed to register icc provider %s: %ld\n",
-				icc_driver_name, PTR_ERR(priv->icc_pdev));
+		dev_err(dev, "failed to register icc provider %s: %pe\n",
+				icc_driver_name, priv->icc_pdev);
 		return PTR_ERR(priv->icc_pdev);
 	}
 
drivers/devfreq/imx8m-ddrc.c +1 -2
index 52beeb5b7d65..28d7c595fa17 100644
@@ -340,8 +340,7 @@ static int imx8m_ddrc_check_opps(struct device *dev)
 	for (i = 0, freq = 0; i < opp_count; ++i, ++freq) {
 		opp = dev_pm_opp_find_freq_ceil(dev, &freq);
 		if (IS_ERR(opp)) {
-			dev_err(dev, "Failed enumerating OPPs: %ld\n",
-				PTR_ERR(opp));
+			dev_err(dev, "Failed enumerating OPPs: %pe\n", opp);
 			return PTR_ERR(opp);
 		}
 		dev_pm_opp_put(opp);
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 2/5
#3 lore raw

Re: [PATCH v2 2/5] devfreq: Use %pe to print error pointers symbolically

Quoted 5 lines · Sumeet Pawnikar
drivers/devfreq/imx-bus.c +0 -0
index 49798f542d68..dba76d8b9e5a 100644

drivers/devfreq/imx-bus.c static int imx_bus_init_icc(struct device *dev) · line 81

Quoted 9 lines
drivers/devfreq/imx-bus.c +2 -2
@@ -75,8 +75,8 @@ static int imx_bus_init_icc(struct device *dev)
 	priv->icc_pdev = platform_device_register_data(
 			dev, icc_driver_name, -1, NULL, 0);
 	if (IS_ERR(priv->icc_pdev)) {
-		dev_err(dev, "failed to register icc provider %s: %ld\n",
-				icc_driver_name, PTR_ERR(priv->icc_pdev));
+		dev_err(dev, "failed to register icc provider %s: %pe\n",
+				icc_driver_name, priv->icc_pdev);
 		return PTR_ERR(priv->icc_pdev);
 	}

Apparently reviewing only a few lines of entire patch is still reviewing:

https://lore.kernel.org/all/[email protected]/

Therefore:

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH v2 2/5] devfreq: Use %pe to print error pointers symbolically

In reply to Sumeet Pawnikar
Quoted 32 lines · Sumeet Pawnikar

Replace PTR_ERR() and %ld with %pe and pass the original pointer directly to dev_err(). The %pe format specifier prints a symbolic error name (e.g. -ENOMEM) when CONFIG_SYMBOLIC_ERRNAME is enabled, otherwise it falls back gracefully and prints the raw integer value. This makes messages more readable without any functional change.

---
 drivers/devfreq/imx-bus.c    | 4 ++--
 drivers/devfreq/imx8m-ddrc.c | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/devfreq/imx-bus.c +2 -2
index 49798f542d68..dba76d8b9e5a 100644
@@ -75,8 +75,8 @@ static int imx_bus_init_icc(struct device *dev)
 	priv->icc_pdev = platform_device_register_data(
 			dev, icc_driver_name, -1, NULL, 0);
 	if (IS_ERR(priv->icc_pdev)) {
-		dev_err(dev, "failed to register icc provider %s: %ld\n",
-				icc_driver_name, PTR_ERR(priv->icc_pdev));
+		dev_err(dev, "failed to register icc provider %s: %pe\n",
+				icc_driver_name, priv->icc_pdev);
 		return PTR_ERR(priv->icc_pdev);
 	}
 
drivers/devfreq/imx8m-ddrc.c +0 -0
index 52beeb5b7d65..28d7c595fa17 100644

drivers/devfreq/imx8m-ddrc.c static int imx8m_ddrc_check_opps(struct device *dev) · line 346

Quoted 9 lines
drivers/devfreq/imx8m-ddrc.c +1 -2
@@ -340,8 +340,7 @@ static int imx8m_ddrc_check_opps(struct device *dev)
 	for (i = 0, freq = 0; i < opp_count; ++i, ++freq) {
 		opp = dev_pm_opp_find_freq_ceil(dev, &freq);
 		if (IS_ERR(opp)) {
-			dev_err(dev, "Failed enumerating OPPs: %ld\n",
-				PTR_ERR(opp));
+			dev_err(dev, "Failed enumerating OPPs: %pe\n", opp);
 			return PTR_ERR(opp);
 		}
 		dev_pm_opp_put(opp);

Hi,

Applied it.

Thanks

#5 lore raw

PATCH v2 3/5 cpufreq: Use %pe to print error pointers symbolically

In reply to Sumeet Pawnikar

Replace PTR_ERR() and %ld with %pe and pass the original pointer directly to pr_err() and pr_warn(). The %pe format specifier prints a symbolic error name (e.g. -ENOMEM) when CONFIG_SYMBOLIC_ERRNAME is enabled, otherwise it falls back gracefully and prints the raw integer value. This makes messages more readable without any functional change.

---
 drivers/cpufreq/bmips-cpufreq.c   | 4 ++--
 drivers/cpufreq/cppc_cpufreq.c    | 4 ++--
 drivers/cpufreq/qoriq-cpufreq.c   | 4 ++--
 drivers/cpufreq/s3c64xx-cpufreq.c | 5 ++---
 4 files changed, 8 insertions(+), 9 deletions(-)
drivers/cpufreq/bmips-cpufreq.c +2 -2
index a8e35bc75fb2..389fff5e6f65 100644
@@ -132,8 +132,8 @@ static int bmips_cpufreq_init(struct cpufreq_policy *policy)
 
 	freq_table = bmips_cpufreq_get_freq_table(policy);
 	if (IS_ERR(freq_table)) {
-		pr_err("%s: couldn't determine frequency table (%ld).\n",
-			BMIPS_CPUFREQ_NAME, PTR_ERR(freq_table));
+		pr_err("%s: couldn't determine frequency table (%pe).\n",
+			BMIPS_CPUFREQ_NAME, freq_table);
 		return PTR_ERR(freq_table);
 	}
 
drivers/cpufreq/cppc_cpufreq.c +2 -2
index 80893844353c..f767898ebfb5 100644
@@ -230,8 +230,8 @@ static void cppc_fie_kworker_init(void)
 
 	kworker_fie = kthread_run_worker(0, "cppc_fie");
 	if (IS_ERR(kworker_fie)) {
-		pr_warn("%s: failed to create kworker_fie: %ld\n", __func__,
-			PTR_ERR(kworker_fie));
+		pr_warn("%s: failed to create kworker_fie: %pe\n", __func__,
+			kworker_fie);
 		fie_disabled = FIE_DISABLED;
 		kworker_fie = NULL;
 		return;
drivers/cpufreq/qoriq-cpufreq.c +2 -2
index 42edb41ad459..0652e5df0278 100644
@@ -57,8 +57,8 @@ static u32 get_bus_freq(void)
 	/* get platform freq by its clock name */
 	pltclk = clk_get(NULL, "cg-pll0-div1");
 	if (IS_ERR(pltclk)) {
-		pr_err("%s: can't get bus frequency %ld\n",
-		       __func__, PTR_ERR(pltclk));
+		pr_err("%s: can't get bus frequency %pe\n",
+		       __func__, pltclk);
 		return PTR_ERR(pltclk);
 	}
 
drivers/cpufreq/s3c64xx-cpufreq.c +2 -3
index 9cef71528076..9a01592425ee 100644
@@ -152,15 +152,14 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)
 
 	policy->clk = clk_get(NULL, "armclk");
 	if (IS_ERR(policy->clk)) {
-		pr_err("Unable to obtain ARMCLK: %ld\n",
-		       PTR_ERR(policy->clk));
+		pr_err("Unable to obtain ARMCLK: %pe\n", policy->clk);
 		return PTR_ERR(policy->clk);
 	}
 
 #ifdef CONFIG_REGULATOR
 	vddarm = regulator_get(NULL, "vddarm");
 	if (IS_ERR(vddarm)) {
-		pr_err("Failed to obtain VDDARM: %ld\n", PTR_ERR(vddarm));
+		pr_err("Failed to obtain VDDARM: %pe\n", vddarm);
 		pr_err("Only frequency scaling available\n");
 		vddarm = NULL;
 	} else {
Signature · 1 line
2.43.0
maintainer Applied
#6 lore raw

Re: [PATCH v2 3/5] cpufreq: Use %pe to print error pointers symbolically

Quoted 71 lines · Sumeet Pawnikar

Replace PTR_ERR() and %ld with %pe and pass the original pointer directly to pr_err() and pr_warn(). The %pe format specifier prints a symbolic error name (e.g. -ENOMEM) when CONFIG_SYMBOLIC_ERRNAME is enabled, otherwise it falls back gracefully and prints the raw integer value. This makes messages more readable without any functional change.

---
 drivers/cpufreq/bmips-cpufreq.c   | 4 ++--
 drivers/cpufreq/cppc_cpufreq.c    | 4 ++--
 drivers/cpufreq/qoriq-cpufreq.c   | 4 ++--
 drivers/cpufreq/s3c64xx-cpufreq.c | 5 ++---
 4 files changed, 8 insertions(+), 9 deletions(-)
drivers/cpufreq/bmips-cpufreq.c +2 -2
index a8e35bc75fb2..389fff5e6f65 100644
@@ -132,8 +132,8 @@ static int bmips_cpufreq_init(struct cpufreq_policy *policy)
 
 	freq_table = bmips_cpufreq_get_freq_table(policy);
 	if (IS_ERR(freq_table)) {
-		pr_err("%s: couldn't determine frequency table (%ld).\n",
-			BMIPS_CPUFREQ_NAME, PTR_ERR(freq_table));
+		pr_err("%s: couldn't determine frequency table (%pe).\n",
+			BMIPS_CPUFREQ_NAME, freq_table);
 		return PTR_ERR(freq_table);
 	}
 
drivers/cpufreq/cppc_cpufreq.c +2 -2
index 80893844353c..f767898ebfb5 100644
@@ -230,8 +230,8 @@ static void cppc_fie_kworker_init(void)
 
 	kworker_fie = kthread_run_worker(0, "cppc_fie");
 	if (IS_ERR(kworker_fie)) {
-		pr_warn("%s: failed to create kworker_fie: %ld\n", __func__,
-			PTR_ERR(kworker_fie));
+		pr_warn("%s: failed to create kworker_fie: %pe\n", __func__,
+			kworker_fie);
 		fie_disabled = FIE_DISABLED;
 		kworker_fie = NULL;
 		return;
drivers/cpufreq/qoriq-cpufreq.c +2 -2
index 42edb41ad459..0652e5df0278 100644
@@ -57,8 +57,8 @@ static u32 get_bus_freq(void)
 	/* get platform freq by its clock name */
 	pltclk = clk_get(NULL, "cg-pll0-div1");
 	if (IS_ERR(pltclk)) {
-		pr_err("%s: can't get bus frequency %ld\n",
-		       __func__, PTR_ERR(pltclk));
+		pr_err("%s: can't get bus frequency %pe\n",
+		       __func__, pltclk);
 		return PTR_ERR(pltclk);
 	}
 
drivers/cpufreq/s3c64xx-cpufreq.c +1 -2
index 9cef71528076..9a01592425ee 100644
@@ -152,15 +152,14 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)
 
 	policy->clk = clk_get(NULL, "armclk");
 	if (IS_ERR(policy->clk)) {
-		pr_err("Unable to obtain ARMCLK: %ld\n",
-		       PTR_ERR(policy->clk));
+		pr_err("Unable to obtain ARMCLK: %pe\n", policy->clk);
 		return PTR_ERR(policy->clk);

drivers/cpufreq/s3c64xx-cpufreq.c static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) · line 165

Quoted 10 lines
drivers/cpufreq/s3c64xx-cpufreq.c +1 -1
 	}
 
 #ifdef CONFIG_REGULATOR
 	vddarm = regulator_get(NULL, "vddarm");
 	if (IS_ERR(vddarm)) {
-		pr_err("Failed to obtain VDDARM: %ld\n", PTR_ERR(vddarm));
+		pr_err("Failed to obtain VDDARM: %pe\n", vddarm);
 		pr_err("Only frequency scaling available\n");
 		vddarm = NULL;
 	} else {

Applied. Thanks.

Signature · 1 line
viresh
#7 lore raw

PATCH v2 4/5 thermal: Use %pe to print error pointers symbolically

In reply to Sumeet Pawnikar

Replace PTR_ERR() and %ld with %pe and pass the original pointer directly to pr_err() and dev_err(). The %pe format specifier prints a symbolic error name (e.g. -ENOMEM) when CONFIG_SYMBOLIC_ERRNAME is enabled, otherwise it falls back gracefully and prints the raw integer value. This makes messages more readable without any functional change.

---
 drivers/thermal/cpufreq_cooling.c        | 4 ++--
 drivers/thermal/devfreq_cooling.c        | 4 ++--
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/thermal/cpufreq_cooling.c +2 -2
index 768859a7aed0..856d619370db 100644
@@ -661,8 +661,8 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy)
 
 		cdev = __cpufreq_cooling_register(np, policy, em);
 		if (IS_ERR(cdev)) {
-			pr_err("cpufreq_cooling: cpu%d failed to register as cooling device: %ld\n",
-			       policy->cpu, PTR_ERR(cdev));
+			pr_err("cpufreq_cooling: cpu%d failed to register as cooling device: %pe\n",
+			       policy->cpu, cdev);
 			cdev = NULL;
 		}
 	}
drivers/thermal/devfreq_cooling.c +2 -2
index 0330a8112832..9ada52cbf7dd 100644
@@ -156,8 +156,8 @@ static unsigned long get_voltage(struct devfreq *df, unsigned long freq)
 		opp = dev_pm_opp_find_freq_exact(dev, freq, false);
 
 	if (IS_ERR(opp)) {
-		dev_err_ratelimited(dev, "Failed to find OPP for frequency %lu: %ld\n",
-				    freq, PTR_ERR(opp));
+		dev_err_ratelimited(dev, "Failed to find OPP for frequency %lu: %pe\n",
+				    freq, opp);
 		return 0;
 	}
 
drivers/thermal/qcom/qcom-spmi-adc-tm5.c +2 -2
index af72db6299cd..4554a6fa55d1 100644
@@ -680,8 +680,8 @@ static int adc_tm5_register_tzd(struct adc_tm5_chip *adc_tm)
 				continue;
 			}
 
-			dev_err(adc_tm->dev, "Error registering TZ zone for channel %d: %ld\n",
-				adc_tm->channels[i].channel, PTR_ERR(tzd));
+			dev_err(adc_tm->dev, "Error registering TZ zone for channel %d: %pe\n",
+				adc_tm->channels[i].channel, tzd);
 			return PTR_ERR(tzd);
 		}
 		adc_tm->channels[i].tzd = tzd;
Signature · 1 line
2.43.0
maintainer Applied
#8 lore raw

Re: [PATCH v2 4/5] thermal: Use %pe to print error pointers symbolically

Quoted 50 lines · Sumeet Pawnikar

Replace PTR_ERR() and %ld with %pe and pass the original pointer directly to pr_err() and dev_err(). The %pe format specifier prints a symbolic error name (e.g. -ENOMEM) when CONFIG_SYMBOLIC_ERRNAME is enabled, otherwise it falls back gracefully and prints the raw integer value. This makes messages more readable without any functional change.

---
 drivers/thermal/cpufreq_cooling.c        | 4 ++--
 drivers/thermal/devfreq_cooling.c        | 4 ++--
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/thermal/cpufreq_cooling.c +2 -2
index 768859a7aed0..856d619370db 100644
@@ -661,8 +661,8 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy)
 
                cdev = __cpufreq_cooling_register(np, policy, em);
                if (IS_ERR(cdev)) {
-                       pr_err("cpufreq_cooling: cpu%d failed to register as cooling device: %ld\n",
-                              policy->cpu, PTR_ERR(cdev));
+                       pr_err("cpufreq_cooling: cpu%d failed to register as cooling device: %pe\n",
+                              policy->cpu, cdev);
                        cdev = NULL;
                }
        }
drivers/thermal/devfreq_cooling.c +2 -2
index 0330a8112832..9ada52cbf7dd 100644
@@ -156,8 +156,8 @@ static unsigned long get_voltage(struct devfreq *df, unsigned long freq)
                opp = dev_pm_opp_find_freq_exact(dev, freq, false);
 
        if (IS_ERR(opp)) {
-               dev_err_ratelimited(dev, "Failed to find OPP for frequency %lu: %ld\n",
-                                   freq, PTR_ERR(opp));
+               dev_err_ratelimited(dev, "Failed to find OPP for frequency %lu: %pe\n",
+                                   freq, opp);
                return 0;
        }
 
drivers/thermal/qcom/qcom-spmi-adc-tm5.c +0 -0
index af72db6299cd..4554a6fa55d1 100644
@@ -680,8 +680,8 @@ static int adc_tm5_register_tzd(struct adc_tm5_chip *adc_tm)
                                continue;

drivers/thermal/qcom/qcom-spmi-adc-tm5.c static int adc_tm5_register_tzd(struct adc_tm5_chip *adc_tm)

Quoted 10 lines
drivers/thermal/qcom/qcom-spmi-adc-tm5.c +2 -3
                        }
 
-                       dev_err(adc_tm->dev, "Error registering TZ zone for channel %d: %ld\n",
-                               adc_tm->channels[i].channel, PTR_ERR(tzd));
+                       dev_err(adc_tm->dev, "Error registering TZ zone for channel %d: %pe\n",
+                               adc_tm->channels[i].channel, tzd);
                        return PTR_ERR(tzd);
                }
                adc_tm->channels[i].tzd = tzd;
--

Applied as 7.4 material, thanks!

#9 lore raw

PATCH v2 5/5 powercap: intel_rapl: Use %pe to print error pointers symbolically

In reply to Sumeet Pawnikar

Replace PTR_ERR() and %ld with %pe and pass the original pointer directly to pr_debug(). The %pe format specifier prints a symbolic error name (e.g. -ENOMEM) when CONFIG_SYMBOLIC_ERRNAME is enabled, otherwise it falls back gracefully and prints the raw integer value. This makes messages more readable without any functional change.

---
 drivers/powercap/intel_rapl_msr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/powercap/intel_rapl_msr.c +2 -2
index a34543e66446..46972ee1ff84 100644
@@ -582,8 +582,8 @@ static int intel_rapl_msr_init(void)
 	rapl_msr_platdev = platform_device_register_data(NULL, "intel_rapl_msr", 0, def,
 							 sizeof(*def));
 	if (IS_ERR(rapl_msr_platdev))
-		pr_debug("intel_rapl_msr device register failed, ret:%ld\n",
-			 PTR_ERR(rapl_msr_platdev));
+		pr_debug("intel_rapl_msr device register failed, ret:%pe\n",
+			 rapl_msr_platdev);
 
 	return 0;
 }
Signature · 1 line
2.43.0
maintainer Applied
#10 lore raw

Re: [PATCH v2 5/5] powercap: intel_rapl: Use %pe to print error pointers symbolically

Quoted 18 lines · Sumeet Pawnikar

Replace PTR_ERR() and %ld with %pe and pass the original pointer directly to pr_debug(). The %pe format specifier prints a symbolic error name (e.g. -ENOMEM) when CONFIG_SYMBOLIC_ERRNAME is enabled, otherwise it falls back gracefully and prints the raw integer value. This makes messages more readable without any functional change.

---
 drivers/powercap/intel_rapl_msr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/powercap/intel_rapl_msr.c +0 -0
index a34543e66446..46972ee1ff84 100644
@@ -582,8 +582,8 @@ static int intel_rapl_msr_init(void)
        rapl_msr_platdev = platform_device_register_data(NULL, "intel_rapl_msr", 0, def,

drivers/powercap/intel_rapl_msr.c static int intel_rapl_msr_init(void)

Quoted 10 lines
drivers/powercap/intel_rapl_msr.c +2 -3
                                                         sizeof(*def));
        if (IS_ERR(rapl_msr_platdev))
-               pr_debug("intel_rapl_msr device register failed, ret:%ld\n",
-                        PTR_ERR(rapl_msr_platdev));
+               pr_debug("intel_rapl_msr device register failed, ret:%pe\n",
+                        rapl_msr_platdev);
 
        return 0;
 }
--

Applied as 7.4 material, thanks!

#11 lore raw
In reply to Sumeet Pawnikar
Quoted 17 lines · Sumeet Pawnikar

This patch series is a cleanup for subsystems under power management (linux-pm) that converts several instances of error pointer printing to use the %pe format specifier instead of explicitly casting with PTR_ERR().

Currently, many drivers use PTR_ERR() paired with %ld or %li to print error codes returned as pointers. By switching to %pe and passing the error pointer directly, the logging subsystem will automatically print the symbolic error name (e.g., -ENOMEM, -EPROBE_DEFER) when CONFIG_SYMBOLIC_ERRNAME is enabled, and gracefully fall back to the numeric value otherwise.

This change significantly improves the readability of kernel logs and dmesg traces during debugging, without introducing any functional changes or side effects.

Quoted 7 lines

The cleanup has been applied across the following PM subsystems/drivers:
* powercap (intel_rapl_msr)
* thermal (cpufreq_cooling, devfreq_cooling, qcom)
* cpufreq (bmips, cppc, qoriq, s3c64xx)
* devfreq (imx-bus, imx8m-ddrc)
* power/supply (various battery and charger drivers)

ping for review request on above listed changes in this v2 series.

Thanks,
Sumeet.

Quoted 37 lines

---
changes in v2:
- Krzysztof kozlowski suggested to use dev_err_probe instead of dev_err for *_probe() functions during review of v1 series. This will be done in different patch series.
- Here in v2, reverted the changes for dev_err under *_probe() functions.

- Link to v1: https://lore.kernel.org/all/[email protected]/

---

Sumeet Pawnikar (5):
power: Use %pe to print error pointers symbolically
devfreq: Use %pe to print error pointers symbolically
cpufreq: Use %pe to print error pointers symbolically
thermal: Use %pe to print error pointers symbolically
powercap: intel_rapl: Use %pe to print error pointers symbolically

 drivers/cpufreq/bmips-cpufreq.c            | 4 ++--
 drivers/cpufreq/cppc_cpufreq.c             | 4 ++--
 drivers/cpufreq/qoriq-cpufreq.c            | 4 ++--
 drivers/cpufreq/s3c64xx-cpufreq.c          | 5 ++---
 drivers/devfreq/imx-bus.c                  | 4 ++--
 drivers/devfreq/imx8m-ddrc.c               | 3 +--
 drivers/power/reset/macsmc-reboot.c        | 4 ++--
 drivers/power/supply/cpcap-charger.c       | 4 ++--
 drivers/power/supply/intel_dc_ti_battery.c | 2 +-
 drivers/power/supply/qcom_smbx.c           | 2 +-
 drivers/powercap/intel_rapl_msr.c          | 4 ++--
 drivers/thermal/cpufreq_cooling.c          | 4 ++--
 drivers/thermal/devfreq_cooling.c          | 4 ++--
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c   | 4 ++--
 14 files changed, 25 insertions(+), 27 deletions(-)

--
2.43.0

#12 lore raw

Re: (subset) [PATCH v2 0/5] PM: Use %pe to print error pointers symbolically

In reply to Sumeet Pawnikar
Quoted 5 lines · Sumeet Pawnikar

This patch series is a cleanup for subsystems under power management (linux-pm) that converts several instances of error pointer printing to use the %pe format specifier instead of explicitly casting with PTR_ERR().

Quoted 8 lines

Currently, many drivers use PTR_ERR() paired with %ld or %li to print error codes returned as pointers. By switching to %pe and passing the error pointer directly, the logging subsystem will automatically print the symbolic error name (e.g., -ENOMEM, -EPROBE_DEFER) when CONFIG_SYMBOLIC_ERRNAME is enabled, and gracefully fall back to the numeric value otherwise.

[...]

Applied, thanks!

[1/5] power: Use %pe to print error pointers symbolically

      commit: 8761a4577c4fd489fb7af435f4b11ab6762dab66

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>