[PATCH v5 04/13] HID: haptic: Postpone GET_REPORT to init

From: Rong Zhang

Date: Sun Nov 29 2026 - 12:55:42 EST


Currently, the driver calls GET_REPORT within the feature_mapping
callback. This is not optimal, as the driver works only if manual
trigger is also available and the if the device is a touchpad. It makes
no sense to initiate device IO if the device is not supported by the
driver.

Hence, postpone GET_REPORT to hid_haptic_init(), and parse default
trigger in parse_auto_trigger_field() where many fields are already
parsed there.

Signed-off-by: Rong Zhang <i@xxxxxxxx>
---
Changes in v5:
- Factor out a helper function
---
drivers/hid/hid-haptic.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index 06d1785a7d8c..2e9631fa2f69 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -22,13 +22,6 @@ void hid_haptic_feature_mapping(struct hid_device *hdev,
"HID_HP_AUTOTRIGGER out of range\n");
return;
}
-
- hid_device_io_start(hdev);
- hid_hw_request(hdev, field->report, HID_REQ_GET_REPORT);
- hid_hw_wait(hdev);
- hid_device_io_stop(hdev);
- haptic->default_auto_trigger =
- field->value[usage->usage_index];
haptic->auto_trigger_report = field->report;
} else if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ORDINAL) {
usage_hid = usage->hid & HID_USAGE;
@@ -135,6 +128,9 @@ static void parse_auto_trigger_field(struct hid_haptic_device *haptic,
break;
case HID_UP_HAPTIC:
switch (field->usage[n].hid) {
+ case HID_HP_AUTOTRIGGER:
+ haptic->default_auto_trigger = field->value[n];
+ break;
case HID_HP_WAVEFORMVENDORID:
haptic->vendor_id = field->value[n];
break;
@@ -402,6 +398,16 @@ static void hid_haptic_destroy(struct ff_device *ff)
haptic->hid_usage_map = NULL;
}

+static void hid_haptic_get_reports(struct hid_device *hdev, struct hid_haptic_device *haptic)
+{
+ hid_device_io_start(hdev);
+
+ hid_hw_request(hdev, haptic->auto_trigger_report, HID_REQ_GET_REPORT);
+
+ hid_hw_wait(hdev);
+ hid_device_io_stop(hdev);
+}
+
int hid_haptic_init(struct hid_device *hdev,
struct hid_haptic_device *haptic,
struct input_dev *dev)
@@ -438,6 +444,9 @@ int hid_haptic_init(struct hid_device *hdev,
HID_HP_WAVEFORMSTOP & HID_USAGE;

mutex_init(&haptic->auto_trigger_mutex);
+
+ hid_haptic_get_reports(hdev, haptic);
+
for (r = 0; r < haptic->auto_trigger_report->maxfield; r++)
parse_auto_trigger_field(haptic, haptic->auto_trigger_report->field[r]);


--
2.55.0