[PATCH v6 1/8] spmi: Print error status with %pe format

AngeloGioacchino Del Regno posted 8 patches 3 months, 3 weeks ago
There is a newer version of this series
[PATCH v6 1/8] spmi: Print error status with %pe format
Posted by AngeloGioacchino Del Regno 3 months, 3 weeks ago
Instead of printing just a number, use the %pe format for error
status, increasing readability of error prints.

Signed-off-by: AngeloGioacchino Del Regno <angleogioacchino.delregno@collabora.com>
---
 drivers/spmi/spmi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c
index 3cf8d9bd4566..bcb71f25194f 100644
--- a/drivers/spmi/spmi.c
+++ b/drivers/spmi/spmi.c
@@ -68,8 +68,8 @@ int spmi_device_add(struct spmi_device *sdev)
 
 	err = device_add(&sdev->dev);
 	if (err < 0) {
-		dev_err(&sdev->dev, "Can't add %s, status %d\n",
-			dev_name(&sdev->dev), err);
+		dev_err(&sdev->dev, "Can't add %s, status %pe\n",
+			dev_name(&sdev->dev), ERR_PTR(err));
 		goto err_device_add;
 	}
 
@@ -494,8 +494,8 @@ static void of_spmi_register_devices(struct spmi_controller *ctrl)
 		err = of_property_read_u32_array(node, "reg", reg, 2);
 		if (err) {
 			dev_err(&ctrl->dev,
-				"node %pOF err (%d) does not have 'reg' property\n",
-				node, err);
+				"node %pOF err (%pe) does not have 'reg' property\n",
+				node, ERR_PTR(err));
 			continue;
 		}
 
@@ -523,7 +523,7 @@ static void of_spmi_register_devices(struct spmi_controller *ctrl)
 		err = spmi_device_add(sdev);
 		if (err) {
 			dev_err(&sdev->dev,
-				"failure adding device. status %d\n", err);
+				"failure adding device. status %pe\n", ERR_PTR(err));
 			spmi_device_put(sdev);
 		}
 	}
-- 
2.51.0
Re: [PATCH v6 1/8] spmi: Print error status with %pe format
Posted by Andy Shevchenko 3 months, 3 weeks ago
On Thu, Oct 16, 2025 at 12:43:55PM +0200, AngeloGioacchino Del Regno wrote:
> Instead of printing just a number, use the %pe format for error
> status, increasing readability of error prints.

...

>  	err = device_add(&sdev->dev);
>  	if (err < 0) {
> -		dev_err(&sdev->dev, "Can't add %s, status %d\n",
> -			dev_name(&sdev->dev), err);
> +		dev_err(&sdev->dev, "Can't add %s, status %pe\n",
> +			dev_name(&sdev->dev), ERR_PTR(err));

LOL, I only now noticed that the parameter to dev_err() and dev_name() is the
same. For christ's sake, why do we need dev_name()?

>  		goto err_device_add;
>  	}

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v6 1/8] spmi: Print error status with %pe format
Posted by AngeloGioacchino Del Regno 3 months, 3 weeks ago
Il 18/10/25 21:12, Andy Shevchenko ha scritto:
> On Thu, Oct 16, 2025 at 12:43:55PM +0200, AngeloGioacchino Del Regno wrote:
>> Instead of printing just a number, use the %pe format for error
>> status, increasing readability of error prints.
> 
> ...
> 
>>   	err = device_add(&sdev->dev);
>>   	if (err < 0) {
>> -		dev_err(&sdev->dev, "Can't add %s, status %d\n",
>> -			dev_name(&sdev->dev), err);
>> +		dev_err(&sdev->dev, "Can't add %s, status %pe\n",
>> +			dev_name(&sdev->dev), ERR_PTR(err));
> 
> LOL, I only now noticed that the parameter to dev_err() and dev_name() is the
> same. For christ's sake, why do we need dev_name()?
> 

Just only for consistency and having the exact same message as function
spmi_device_add() and nothing else.

I agree that it's not really needed; if you want I can just change the
error message in both spmi_device_add() and in the new function that I
am introducing here.

Cheers,
Angelo

>>   		goto err_device_add;
>>   	}
>