[PATCH v6 11/13] HID: haptic: Add quirk table

From: Rong Zhang

Date: Wed Dec 02 2026 - 13:39:05 EST


In the following changes, per-device quirk flags are needed to handle
faulty devices.

Add a quirk table and match it on init.

Signed-off-by: Rong Zhang <i@xxxxxxxx>
---
drivers/hid/hid-haptic.c | 16 ++++++++++++++++
drivers/hid/hid-haptic.h | 4 ++++
2 files changed, 20 insertions(+)

diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index aae4ff1f0cca..f3118876d1b2 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -17,6 +17,20 @@

#include "hid-haptic.h"

+static const struct hid_device_id hid_haptic_quirks[] = {
+ { }
+};
+
+static u32 hid_haptic_match_quirks(struct hid_device *hdev)
+{
+ const struct hid_device_id *id = hid_match_id(hdev, hid_haptic_quirks);
+ u32 quirks;
+
+ quirks = id ? id->driver_data : 0;
+
+ return quirks;
+}
+
static void __hid_haptic_feature_mapping(struct hid_device *hdev, struct hid_haptic_device *haptic,
struct hid_field *field, struct hid_usage *usage)
{
@@ -448,6 +462,8 @@ static int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *ha
.hid_usage = HID_HP_WAVEFORMSTOP & HID_USAGE,
};

+ haptic->quirks = hid_haptic_match_quirks(hdev);
+
haptic->hdev = hdev;
haptic->max_waveform_id = max(2u, haptic->max_waveform_id);
haptic->max_duration_id = max(2u, haptic->max_duration_id);
diff --git a/drivers/hid/hid-haptic.h b/drivers/hid/hid-haptic.h
index 009133ac50ba..3464766def08 100644
--- a/drivers/hid/hid-haptic.h
+++ b/drivers/hid/hid-haptic.h
@@ -5,6 +5,7 @@
* Copyright (c) 2021 Angela Czubak <acz@xxxxxxxxxxxx>
*/

+#include <linux/bits.h>
#include <linux/compiler.h>
#include <linux/container_of.h>
#include <linux/err.h>
@@ -56,6 +57,9 @@ struct hid_haptic_device {
u32 *duration_map;
u16 press_ordinal;
u16 release_ordinal;
+
+ u32 quirks;
+
struct hid_haptic_effect *effect;
struct hid_haptic_effect stop_effect;


--
2.55.0