* [PATCH v2] HID: pulsar: print errors with %pe
@ 2026-11-06 8:33 Aryan Sinha
2026-11-07 15:52 ` Nikolas Koesling
0 siblings, 1 reply; 2+ messages in thread
From: Aryan Sinha @ 2026-11-06 8:33 UTC (permalink / raw)
To: Nikolas Koesling, Jiri Kosina, Benjamin Tissoires
Cc: linux-input, linux-kernel, Aryan Sinha
%pe prints the symbolic errno, which is easier to read in a log than the
raw number. Convert every print in the driver that logs an errno so they
all report the same way.
The prints that log data bytes, battery readings or a byte count are left
on %d, those are not error values.
v2:
- convert the remaining errno prints too, not just the battery one
Signed-off-by: Aryan Sinha <sinha.aryan03@gmail.com>
---
v2:
- convert the remaining errno prints too, not just the battery one
v1: https://lore.kernel.org/all/20261104150055.33028-1-sinha.aryan03@gmail.com/
drivers/hid/hid-pulsar.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/drivers/hid/hid-pulsar.c b/drivers/hid/hid-pulsar.c
index b0b34849f..495ce3b5c 100644
--- a/drivers/hid/hid-pulsar.c
+++ b/drivers/hid/hid-pulsar.c
@@ -162,8 +162,8 @@ static int exec_cmd(struct pulsar_data *drvdata, const u8 *payload,
spin_lock_irqsave(&drvdata->raw_event_lock, flags);
drvdata->pending_event = CMD_NONE;
spin_unlock_irqrestore(&drvdata->raw_event_lock, flags);
- hid_err(hdev, "failed to send command 0x%02x: %d\n",
- payload[1], ret);
+ hid_err(hdev, "failed to send command 0x%02x: %pe\n",
+ payload[1], ERR_PTR(ret));
goto out;
}
@@ -295,8 +295,8 @@ static int read_power(struct pulsar_data *drvdata)
if (status < 0) {
ret = status;
hid_err(drvdata->hdev,
- "%s: failed to read status: %d\n",
- __func__, ret);
+ "%s: failed to read status: %pe\n",
+ __func__, ERR_PTR(ret));
goto unlock;
}
@@ -320,8 +320,8 @@ static int read_power(struct pulsar_data *drvdata)
ret = exec_cmd(drvdata, payload, response, CMD_TIMEOUT_MSEC);
if (ret < 0) {
- hid_err(drvdata->hdev, "%s: failed to read power: %d\n",
- __func__, ret);
+ hid_err(drvdata->hdev, "%s: failed to read power: %pe\n",
+ __func__, ERR_PTR(ret));
goto unlock;
}
@@ -411,8 +411,8 @@ static void power_uevent_work_handler(struct work_struct *work)
ret = read_power(drvdata);
if (ret < 0) {
- hid_err(drvdata->hdev, "%s: failed to read power: %d\n",
- __func__, ret);
+ hid_err(drvdata->hdev, "%s: failed to read power: %pe\n",
+ __func__, ERR_PTR(ret));
return;
}
@@ -584,10 +584,11 @@ static void pulsar_init_work(struct work_struct *work)
}
if (ret < 0) {
if (drvdata->type == TYPE_PULSAR) {
- hid_err(hdev, "failed to read device info: %d\n", ret);
+ hid_err(hdev, "failed to read device info: %pe\n",
+ ERR_PTR(ret));
return;
}
- hid_dbg(hdev, "failed to read device info: %d\n", ret);
+ hid_dbg(hdev, "failed to read device info: %pe\n", ERR_PTR(ret));
snprintf(drvdata->battery.model,
sizeof(drvdata->battery.model), "%s", hdev->name);
goto register_battery;
@@ -615,8 +616,8 @@ static void pulsar_init_work(struct work_struct *work)
devm_power_supply_register(&hdev->dev, &drvdata->battery.desc,
&psy_cfg);
if (IS_ERR(drvdata->battery.ps)) {
- hid_err(hdev, "failed to register battery: %ld\n",
- PTR_ERR(drvdata->battery.ps));
+ hid_err(hdev, "failed to register battery: %pe\n",
+ drvdata->battery.ps);
drvdata->battery.ps = NULL;
return;
}
@@ -639,7 +640,7 @@ static int pulsar_probe(struct hid_device *hdev, const struct hid_device_id *id)
ret = hid_parse(hdev);
if (ret < 0) {
- hid_err(hdev, "hid_parse failed: %d\n", ret);
+ hid_err(hdev, "hid_parse failed: %pe\n", ERR_PTR(ret));
return ret;
}
--
2.46.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v2] HID: pulsar: print errors with %pe
2026-11-06 8:33 [PATCH v2] HID: pulsar: print errors with %pe Aryan Sinha
@ 2026-11-07 15:52 ` Nikolas Koesling
0 siblings, 0 replies; 2+ messages in thread
From: Nikolas Koesling @ 2026-11-07 15:52 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, Aryan Sinha
Cc: linux-input, linux-kernel, Aryan Sinha
> %pe prints the symbolic errno, which is easier to read in a log than the
> raw number. Convert every print in the driver that logs an errno so they
> all report the same way.
>
> The prints that log data bytes, battery readings or a byte count are left
> on %d, those are not error values.
>
> v2:
> - convert the remaining errno prints too, not just the battery one
>
The changelog should go below the "---" line so it doesn't end up in
the commit message.
The code changes look good to me.
Thanks,
Nikolas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-07 15:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 8:33 [PATCH v2] HID: pulsar: print errors with %pe Aryan Sinha
2026-11-07 15:52 ` Nikolas Koesling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®