[PATCH v5 07/13] HID: haptic: Adopt pr_fmt, dev_fmt and hid_*() printk helpers

From: Rong Zhang

Date: Sun Nov 29 2026 - 12:57:04 EST


Now that hid-haptic has been converted into a plugin and will support
all sorts of devices in the following changes, printing messages under
other HID driver's hood may be confusing.

Add pr_fmt and dev_fmt to help identify the source of printk messages.

Meanwhile, migrate from the tedious dev_*() printk helpers to tidier
hid_*() ones.

Signed-off-by: Rong Zhang <i@xxxxxxxx>
---
drivers/hid/hid-haptic.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index c8c1c7fddaa6..3edda5d6018b 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -5,6 +5,9 @@
* Copyright (c) 2021 Angela Czubak <acz@xxxxxxxxxxxx>
*/

+#define pr_fmt(fmt) "hid-haptic: " fmt
+#define dev_fmt pr_fmt
+
#include <linux/err.h>
#include <linux/input/mt.h>
#include <linux/module.h>
@@ -18,8 +21,7 @@ static void __hid_haptic_feature_mapping(struct hid_device *hdev, struct hid_hap

if (usage->hid == HID_HP_AUTOTRIGGER) {
if (usage->usage_index >= field->report_count) {
- dev_err(&hdev->dev,
- "HID_HP_AUTOTRIGGER out of range\n");
+ hid_err(hdev, "HID_HP_AUTOTRIGGER out of range\n");
return;
}
haptic->auto_trigger_report = field->report;
@@ -418,7 +420,7 @@ static int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *ha
}

if (haptic->max_waveform_id != haptic->max_duration_id)
- dev_warn(&hdev->dev,
+ hid_warn(hdev,
"Haptic duration and waveform lists have different max id (%u and %u).\n",
haptic->max_duration_id, haptic->max_waveform_id);

@@ -449,8 +451,7 @@ static int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *ha
hid_alloc_report_buf(haptic->manual_trigger_report,
GFP_KERNEL);
if (!haptic->effect[r].report_buf) {
- dev_err(&hdev->dev,
- "Failed to allocate a buffer for an effect.\n");
+ hid_err(hdev, "Failed to allocate a buffer for an effect.\n");
ret = -ENOMEM;
goto buffer_free;
}
@@ -461,8 +462,7 @@ static int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *ha
hid_alloc_report_buf(haptic->manual_trigger_report,
GFP_KERNEL);
if (!haptic->stop_effect.report_buf) {
- dev_err(&hdev->dev,
- "Failed to allocate a buffer for stop effect.\n");
+ hid_err(hdev, "Failed to allocate a buffer for stop effect.\n");
ret = -ENOMEM;
goto buffer_free;
}
@@ -481,7 +481,7 @@ static int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *ha

ret = input_ff_create(dev, FF_MAX_EFFECTS);
if (ret) {
- dev_err(&hdev->dev, "Failed to create ff device.\n");
+ hid_err(hdev, "Failed to create ff device.\n");
goto reset_evbit;
}


--
2.55.0