All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin
@ 2026-12-02 18:33 Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 01/13] HID: haptic: Get rid of input_ff_destroy() in error paths Rong Zhang
                   ` (12 more replies)
  0 siblings, 13 replies; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang, stable

Several weeks ago, I bought a Logitech MX Master 4 with haptic feedback.
The hid-haptic already supports the Haptic usage page, but it only works
with hid-multitouch. I am also working on adding support for the
LampArray usage page recently [1].

The two drivers have a common characteristic, i.e., they targets
specific HID usage pages instead of specific devices. This leads to
additional linkage dependences because the device drivers need to call
functions provided by the usage page drivers.

Logically, the dependence should be reversed, i.e., a usage page driver
should be an optional component of the associated device driver and is
only loaded by the device driver when the device has the usage page.

Introduce hid-plugin framework for loadable plugin modules to achieve
the said logical dependence. Each plugin has a unique hid_plugin_id when
enabled, so that HID drivers can connect to it accordingly.

Plugins can be either builtin or modules. A plugin module is requested
asynchronously when a HID device tries to use it. If the module is not
available yet, the device is probed without the plugin and reprobed once
the plugin registers itself. The reprobe procedure is inspired by commit
c17a7476e4c4 ("HID: core: rewrite the hid-generic automatic unbind").

Once a plugin is fully loaded (or if the plugin is builtin), subsequent
plugin connection attempts only require RCU dereferences and module
refcount increments, without the need of requesting a module.

The plugin's private data is automatically initialized on connection
with its pointer stored into hid_device. Disconnection also frees it
automatically. When the HID device is about to finish probe, unbound
plugins are automatically disconnected, and HID driver removal
disconnects all plugins. When a plugin turns out to be unsuitable for
the associated HID device, it can also be disconnected early to prevent
further use of the plugin.

When a plugin is disabled, its ID maps to HID_PLUGIN_DISABLED, and calls
to the plugin helper functions are eliminated by the compiler.

With the framework, convert hid-haptic to the first plugin. After the
conversion, it connects to hid-input and becomes a generic plugin.

The first few patches fix pre-existing bugs in hid-haptic and
hid-multitouch. Then the later patches refactor hid-haptic, implement
the hid-plugin framework and finish the conversion. Finally, generalize
hid-haptic.

I volunteer to maintain the framework as well as its plugins, including
hid-haptic and future ones.

Thanks Benjamin Tissoires for the inspiration for the implementation.

[1]: I know Texudo folks are working on adding hid-lamparray to connect
it to hid-generic. I am not in favor of their design, so I decided to
write a new one. In my local tree, I've had an independent
implementation with HIDRAW sniff, autonomous mode as an LED trigger,
RGB/non-RGB LampArray support, per-key LED device support, etc. I will
submit it once this series settles.

Suggested-by: Benjamin Tissoires <bentiss@kernel.org>
Link: https://lore.kernel.org/linux-input/auypydfkhx2eg7vp764way4batdilzc35inqda3exwzs3tk3ff@oagat6g46zto/
Signed-off-by: Rong Zhang <i@rong.moe>
---
Changes in v6:
- Rebase on top of hid/for-next
- Name hid-haptic's workqueue with the input device's kobject name to
  fix name collision and WQ_NAME_LEN warning
- Fix inverted td->is_haptic_touchpad check (thanks Sashiko)
- Use request_module_nowait() instead of request_module(), as the latter
  can't be used within aysnc context where some i2c-hid drivers add
  devices
- Disconnect unbound plugins automatically by consulting the
  newly-introduced bound() callback
- Free plugins' private data in their disconnect() callback for correct
  semantics, i.e., release resources wherever they were allocated
- Check mandatory callbacks on registration
- Add device_lock_assert() annotations
- Constify struct hid_plugin
- Do not attach haptic FF to unpopulated input (thanks Sashiko)
- Prefer PIDFF over hid-haptic
- Update the Kconfig help string to reflect the fact that hid-haptic
  becomes generic
- Link to v5: https://patch.msgid.link/20261130-hid-haptic-kmod-v5-0-4903f73d8cac@rong.moe

Changes in v5:
- Manage HID plugins' private data in the framework
- Disconnect all connected HID plugins on HID driver removal
- Add debug printk()s to track (dis)connection and (un)registration
- Only use HID_PLUGIN to build Kconfig menuconfig, rather than having
  plugins depend on it
  - Enable HID_PLUGIN by default to ease Kconfig migration
  - Build the hid-plugin framework only if HID_PLUGIN_CORE is selected
  - HID_HAPTIC selects it, so that olddefconfig preserves HID_HAPTIC's
    old value
- Connect hid-haptic to hid-inpput
- Convert hid-haptic to a generic plugin
- Add a quirk flag for Logitech MX Master 4
- Link to v4: https://patch.msgid.link/20261125-hid-haptic-kmod-v4-0-03713a89f656@rong.moe

Changes in v4:
- Drop get_device()/put_device() and try_module_get()/module_put()
  completely, as they are needless now (thanks Dmitry Torokhov)
- Drop synchronize_rcu() during registration as other drivers do, as
  there is nothing to protect
- Link to v3: https://patch.msgid.link/20261113-hid-haptic-kmod-v3-0-e7dfa8766c0d@rong.moe

Changes in v3:
- Correct the Fixes: tag of PATCH 4 (thanks Sashiko)
- Add missing Return: to hid_plugin_register()'s kernel-doc (ditto)
- Fix the return value of hid_haptic_connected_to_input() when
  hid-haptic is disabled (ditto)
- Link to v2: https://patch.msgid.link/20261110-hid-haptic-kmod-v2-0-b835a067cb62@rong.moe

Changes in v2:
- Reject touchpad applications with non-force units (thanks Sashiko)
- Only call runtime methods if the event source is the same input device
  as the stored one (ditto)
- Rebase on top of v7.4-rc2 due to the devm_kzalloc_obj() changes
- Link to v1: https://patch.msgid.link/20261102-hid-haptic-kmod-v1-0-a3de5626dade@rong.moe

---
Rong Zhang (13):
      HID: haptic: Get rid of input_ff_destroy() in error paths
      HID: haptic: Fix use-after-free when draining workqueue
      HID: haptic, multitouch: Check haptic prerequisite properly
      HID: haptic: Postpone GET_REPORT to init
      HID: Add hid-plugin framework for loadable plugin modules
      HID: haptic: Convert to a loadable plugin module
      HID: haptic: Adopt pr_fmt, dev_fmt and hid_*() printk helpers
      HID: Add Ordinal page defines
      HID: haptic: Handle list reports separately and make auto trigger optional
      HID: haptic: Decouple from hid-multitouch and support other devices
      HID: haptic: Add quirk table
      HID: haptic: Add HID_HAPTIC_QUIRK_NO_RETRIGGER to disable retriggering
      HID: haptic: Add quirk flag for Logitech MX Master 4

 MAINTAINERS                  |   7 +
 drivers/hid/Kconfig          |  34 +++-
 drivers/hid/Makefile         |   4 +-
 drivers/hid/hid-core.c       |   6 +
 drivers/hid/hid-haptic.c     | 458 +++++++++++++++++++++++++++++--------------
 drivers/hid/hid-haptic.h     | 181 +++++++++++------
 drivers/hid/hid-input.c      |  40 +++-
 drivers/hid/hid-multitouch.c |  41 +---
 drivers/hid/hid-plugin.c     | 304 ++++++++++++++++++++++++++++
 drivers/hid/hid-plugin.h     | 257 ++++++++++++++++++++++++
 include/linux/hid.h          |  25 +++
 11 files changed, 1105 insertions(+), 252 deletions(-)
---
base-commit: 47d0d5ce3cfca63a04eabcbeef7086d06240ff97
change-id: 9644469a-hid-haptic-kmod-4e8e420f8e5f

Thanks,
Rong


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v6 01/13] HID: haptic: Get rid of input_ff_destroy() in error paths
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 02/13] HID: haptic: Fix use-after-free when draining workqueue Rong Zhang
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang, stable

It's painful to have error paths after calling input_ff_create(),
because input_ff_destroy() frees too much things but does not restore
some other things. For example, every error path calling
input_ff_destroy() frees ff->private, while the others don't. This
divergence has caused quite a lot of trouble.

Additionally, the driver's get_device() bail-out path calls module_put()
right before hid_haptic_destroy() calling it again, causing refcount
underflow.

Since commit 2ae35f090d02 ("Input: destroy force-feedback device on
input unregistration"), the HID device is now guaranteed to have a
longer lifetime than the FF device, making get_device()/put_device()
unnecessary.

Due to the driver being unable to build as a module since commit
083a4f3f3cc7 ("HID: Kconfig: Fix build error from CONFIG_HID_HAPTIC"),
try_module_get()/module_put() is needless, too.

Remove the said calls, so that there is no error path after
input_ff_create(), eliminating the call to input_ff_destroy(). In this
manner, we don't need to restore dev->flush and dev->event either.

Fixes: 344ff3584957 ("HID: haptic: initialize haptic device")
Cc: stable@vger.kernel.org
Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Link: https://msgid.link/f44447354f28c295e79a025bbcab7a4e@gmail.com
Signed-off-by: Rong Zhang <i@rong.moe>
---
Changes in v4:
- Drop get_device()/put_device() and try_module_get()/module_put()
  completely, as they are needless now (thanks Dmitry Torokhov)
---
 drivers/hid/hid-haptic.c | 25 -------------------------
 1 file changed, 25 deletions(-)

diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index 9e50276c2dc5..c20c14bdb3e8 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -380,12 +380,8 @@ static int hid_haptic_erase(struct input_dev *dev, int effect_id)
 static void hid_haptic_destroy(struct ff_device *ff)
 {
 	struct hid_haptic_device *haptic = ff->private;
-	struct hid_device *hdev = haptic->hdev;
 	int r;
 
-	if (hdev)
-		put_device(&hdev->dev);
-
 	kfree(haptic->stop_effect.report_buf);
 	haptic->stop_effect.report_buf = NULL;
 
@@ -404,8 +400,6 @@ static void hid_haptic_destroy(struct ff_device *ff)
 
 	kfree(haptic->hid_usage_map);
 	haptic->hid_usage_map = NULL;
-
-	module_put(THIS_MODULE);
 }
 
 int hid_haptic_init(struct hid_device *hdev,
@@ -418,8 +412,6 @@ int hid_haptic_init(struct hid_device *hdev,
 		.hid_usage = HID_HP_WAVEFORMSTOP & HID_USAGE,
 	};
 	const char *prefix = "hid-haptic";
-	int (*flush)(struct input_dev *dev, struct file *file);
-	int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
 
 	haptic->hdev = hdev;
 	haptic->max_waveform_id = max(2u, haptic->max_waveform_id);
@@ -493,8 +485,6 @@ int hid_haptic_init(struct hid_device *hdev,
 
 	input_set_capability(dev, EV_FF, FF_HAPTIC);
 
-	flush = dev->flush;
-	event = dev->event;
 	ret = input_ff_create(dev, FF_MAX_EFFECTS);
 	if (ret) {
 		dev_err(&hdev->dev, "Failed to create ff device.\n");
@@ -507,23 +497,8 @@ int hid_haptic_init(struct hid_device *hdev,
 	ff->playback = hid_haptic_playback;
 	ff->erase = hid_haptic_erase;
 	ff->destroy = hid_haptic_destroy;
-	if (!try_module_get(THIS_MODULE)) {
-		dev_err(&hdev->dev, "Failed to increase module count.\n");
-		goto input_free;
-	}
-	if (!get_device(&hdev->dev)) {
-		dev_err(&hdev->dev, "Failed to get hdev device.\n");
-		module_put(THIS_MODULE);
-		goto input_free;
-	}
 	return 0;
 
-input_free:
-	input_ff_destroy(dev);
-	/* Restore dev flush and event */
-	dev->flush = flush;
-	dev->event = event;
-	return ret;
 stop_buffer_free:
 	kfree(haptic->stop_effect.report_buf);
 	haptic->stop_effect.report_buf = NULL;

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 02/13] HID: haptic: Fix use-after-free when draining workqueue
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 01/13] HID: haptic: Get rid of input_ff_destroy() in error paths Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 03/13] HID: haptic, multitouch: Check haptic prerequisite properly Rong Zhang
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang, stable

The haptic->wq is destroyed after freeing effects and their report
buffers, which is too late. If any work is still pending or running
before the workqueue destruction, haptic_work_handler() will access the
just-freed contents, causing a use-after-free.

Fix it by destroying the workqueue before freeing haptic resources. The
allocation sequence is also adjusted to the reverse.

Since the workqueue allocation is anyway touched, also drop the prefix
constant by integrating it into the fmt string. The workqueue's name now
also uses the input device's kobject name instead of the HID devices's
descriptor name, as the former is unique and much shorter while the
latter is prone to name collision and WQ_NAME_LEN warning.

Also call __clear_bit(EV_FF, dev->evbit) in the bail-out path to match
the behavior of input_ff_destroy().

Fixes: 344ff3584957 ("HID: haptic: initialize haptic device")
Cc: stable@vger.kernel.org
Signed-off-by: Rong Zhang <i@rong.moe>
---
Changes in v6:
- Name the workqueue with the input device's kobject name to fix name
  collision and WQ_NAME_LEN warning
  - This can be triggered by the Logitech Bolt Receiver once the
    following changes are applied
---
 drivers/hid/hid-haptic.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index c20c14bdb3e8..503d332a14f8 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -382,6 +382,9 @@ static void hid_haptic_destroy(struct ff_device *ff)
 	struct hid_haptic_device *haptic = ff->private;
 	int r;
 
+	destroy_workqueue(haptic->wq);
+	haptic->wq = NULL;
+
 	kfree(haptic->stop_effect.report_buf);
 	haptic->stop_effect.report_buf = NULL;
 
@@ -392,9 +395,6 @@ static void hid_haptic_destroy(struct ff_device *ff)
 	}
 	haptic->effect = NULL;
 
-	destroy_workqueue(haptic->wq);
-	haptic->wq = NULL;
-
 	kfree(haptic->duration_map);
 	haptic->duration_map = NULL;
 
@@ -411,7 +411,6 @@ int hid_haptic_init(struct hid_device *hdev,
 	struct ff_haptic_effect stop_effect = {
 		.hid_usage = HID_HP_WAVEFORMSTOP & HID_USAGE,
 	};
-	const char *prefix = "hid-haptic";
 
 	haptic->hdev = hdev;
 	haptic->max_waveform_id = max(2u, haptic->max_waveform_id);
@@ -446,15 +445,11 @@ int hid_haptic_init(struct hid_device *hdev,
 	haptic->manual_trigger_report_len =
 		hid_report_len(haptic->manual_trigger_report);
 	mutex_init(&haptic->manual_trigger_mutex);
-	haptic->wq = alloc_ordered_workqueue("%s %s", 0, prefix, hdev->name);
-	if (!haptic->wq) {
-		ret = -ENOMEM;
-		goto duration_map;
-	}
+
 	haptic->effect = kzalloc_objs(struct hid_haptic_effect, FF_MAX_EFFECTS);
 	if (!haptic->effect) {
 		ret = -ENOMEM;
-		goto output_queue;
+		goto duration_map;
 	}
 	for (r = 0; r < FF_MAX_EFFECTS; r++) {
 		haptic->effect[r].report_buf =
@@ -483,12 +478,18 @@ int hid_haptic_init(struct hid_device *hdev,
 	fill_effect_buf(haptic, &stop_effect, &haptic->stop_effect,
 			HID_HAPTIC_ORDINAL_WAVEFORMSTOP);
 
+	haptic->wq = alloc_ordered_workqueue("hid-haptic %s", 0, dev_name(&dev->dev));
+	if (!haptic->wq) {
+		ret = -ENOMEM;
+		goto stop_buffer_free;
+	}
+
 	input_set_capability(dev, EV_FF, FF_HAPTIC);
 
 	ret = input_ff_create(dev, FF_MAX_EFFECTS);
 	if (ret) {
 		dev_err(&hdev->dev, "Failed to create ff device.\n");
-		goto stop_buffer_free;
+		goto reset_evbit;
 	}
 
 	ff = dev->ff;
@@ -499,6 +500,10 @@ int hid_haptic_init(struct hid_device *hdev,
 	ff->destroy = hid_haptic_destroy;
 	return 0;
 
+reset_evbit:
+	__clear_bit(EV_FF, dev->evbit);
+	destroy_workqueue(haptic->wq);
+	haptic->wq = NULL;
 stop_buffer_free:
 	kfree(haptic->stop_effect.report_buf);
 	haptic->stop_effect.report_buf = NULL;
@@ -507,9 +512,6 @@ int hid_haptic_init(struct hid_device *hdev,
 		kfree(haptic->effect[r].report_buf);
 	kfree(haptic->effect);
 	haptic->effect = NULL;
-output_queue:
-	destroy_workqueue(haptic->wq);
-	haptic->wq = NULL;
 duration_map:
 	kfree(haptic->duration_map);
 	haptic->duration_map = NULL;

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 03/13] HID: haptic, multitouch: Check haptic prerequisite properly
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 01/13] HID: haptic: Get rid of input_ff_destroy() in error paths Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 02/13] HID: haptic: Fix use-after-free when draining workqueue Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 04/13] HID: haptic: Postpone GET_REPORT to init Rong Zhang
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang, stable

The td->is_haptic_touchpad boolean is multiplexed through during the
probe- and run-time procedures of hid-multitouch. However, the way it
flips is fragile on faulty devices.

MT touchpads have multiple HID_DG_TIPPRESSURE usages, but the value of
td->is_haptic_touchpad only depends on the last usage, and doesn't check
if all usages have the same critical annotations. Moreover, if the HID
device happens to have multiple HID_DG_TOUCHPAD applications, the haptic
device may be initialized more than once.

Reject annotation mismatches and duplicated HID_DG_TOUCHPAD input
devices to address the first issue. The annotation mismatch check only
compares unit, logical_minimum, and physical_minimum to adhere to the
previous intent as much as possible.

The relevant HID_DG_TOUCHPAD input device are cached when the check is
passed for the first time. Any check failures override it and gate
further checks, so the last call to hid_haptic_check_pressure_unit() can
precisely return the final result.

Later, hid_haptic_input_configured() continues the initialization only
if the input device matches the previously chosen one.

With these, the td->is_haptic_touchpad is converted into a one-way
(false => true) flipping manner. The MT_CLS check is also removed in
favor of the prerequisite checks.

At runtime, relevant haptic methods are called only if the event source
is the same input device as the chosen one.

Fixes: 7939f787f450 ("HID: haptic: move FF initialization into .input_configured()")
Cc: stable@vger.kernel.org
Signed-off-by: Rong Zhang <i@rong.moe>
---
Changes in v6:
- Fix inverted td->is_haptic_touchpad check (thanks Sashiko)

Changes in v5:
- Remove the MT_CLS check
- Prepare for following changes
  - Return error code in hid_haptic_input_configured()
  - Return bool in hid_haptic_check_pressure_unit()
  - Move hid_haptic_input_configured() under hid_haptic_init()
  - Factor out hid_haptic_check_prerequisites()
  - Set INPUT_PROP_PRESSUREPAD only for the HID_DG_TOUCHPAD application

Changes in v2:
- Reject touchpad applications with non-force units (thanks Sashiko)
- Only call runtime methods if the event source is the same input device
  as the stored one (ditto)
---
 drivers/hid/hid-haptic.c     | 96 ++++++++++++++++++++++++++++++--------------
 drivers/hid/hid-haptic.h     | 17 ++++++--
 drivers/hid/hid-multitouch.c | 16 +++-----
 3 files changed, 85 insertions(+), 44 deletions(-)

diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index 503d332a14f8..c396a817ec6e 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -51,13 +51,38 @@ EXPORT_SYMBOL_GPL(hid_haptic_feature_mapping);
 bool hid_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
 				    struct hid_input *hi, struct hid_field *field)
 {
-	if (field->unit == HID_UNIT_GRAM || field->unit == HID_UNIT_NEWTON) {
-		haptic->force_logical_minimum = field->logical_minimum;
-		haptic->force_physical_minimum = field->physical_minimum;
-		haptic->force_resolution = input_abs_get_res(hi->input,
-							     ABS_MT_PRESSURE);
+	if (IS_ERR(haptic->input_dev))
+		return false;
+
+	/* Don't care, return the cache result. */
+	if (hi->application != HID_DG_TOUCHPAD)
+		return !!haptic->input_dev;
+
+	if (field->unit != HID_UNIT_GRAM && field->unit != HID_UNIT_NEWTON)
+		goto reject;
+
+	if (!haptic->input_dev) {
+		haptic->input_dev = hi->input;
+		haptic->pressure_field = field;
+		haptic->force_resolution = input_abs_get_res(hi->input, ABS_MT_PRESSURE);
 		return true;
 	}
+
+	if (haptic->input_dev == hi->input &&
+	    haptic->pressure_field->unit == field->unit &&
+	    haptic->pressure_field->logical_minimum == field->logical_minimum &&
+	    haptic->pressure_field->physical_minimum == field->physical_minimum &&
+	    haptic->force_resolution == input_abs_get_res(hi->input, ABS_MT_PRESSURE))
+		return true;
+
+reject:
+	/*
+	 * Reject if:
+	 * - there are multiple input devices with pressure sensors
+	 * - there is any touchpad application with a non-force unit
+	 * - pressure annotations mismatch among HID_DG_TIPPRESSURE usages
+	 */
+	haptic->input_dev = ERR_PTR(-EPROTO);
 	return false;
 }
 EXPORT_SYMBOL_GPL(hid_haptic_check_pressure_unit);
@@ -78,31 +103,6 @@ int hid_haptic_input_mapping(struct hid_device *hdev,
 }
 EXPORT_SYMBOL_GPL(hid_haptic_input_mapping);
 
-int hid_haptic_input_configured(struct hid_device *hdev,
-				struct hid_haptic_device *haptic,
-				struct hid_input *hi)
-{
-	int error;
-
-	if (hi->application != HID_DG_TOUCHPAD)
-		return -1;
-
-	if (!haptic->auto_trigger_report || !haptic->manual_trigger_report)
-		return 0;
-
-	__set_bit(INPUT_PROP_PRESSUREPAD, hi->input->propbit);
-
-	error = hid_haptic_init(hdev, haptic, hi->input);
-	if (error) {
-		dev_warn(&hdev->dev, "Cannot allocate haptic for %s\n",
-			 hdev->name);
-		return 0;
-	}
-
-	return 1;
-}
-EXPORT_SYMBOL_GPL(hid_haptic_input_configured);
-
 static void parse_auto_trigger_field(struct hid_haptic_device *haptic,
 				     struct hid_field *field)
 {
@@ -519,10 +519,46 @@ int hid_haptic_init(struct hid_device *hdev,
 	kfree(haptic->hid_usage_map);
 	haptic->hid_usage_map = NULL;
 exit:
+	hid_warn(hdev, "Cannot allocate haptic for %s: %d\n", hdev->name, ret);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(hid_haptic_init);
 
+static int hid_haptic_check_prerequisites(struct hid_device *hdev,
+					  struct hid_haptic_device *haptic, struct hid_input *hi)
+{
+	if (!haptic->auto_trigger_report || !haptic->manual_trigger_report)
+		return -ENOENT;
+
+	if (IS_ERR_OR_NULL(haptic->input_dev))
+		return PTR_ERR(haptic->input_dev) ?: -EXDEV;
+
+	if (haptic->input_dev == hi->input)
+		return 0;
+
+	return 1; /* Waiting for the relevant input device. */
+}
+
+int hid_haptic_input_configured(struct hid_device *hdev,
+				struct hid_haptic_device *haptic, struct hid_input *hi)
+{
+	int ret;
+
+	ret = hid_haptic_check_prerequisites(hdev, haptic, hi);
+	if (ret)
+		return ret;
+
+	ret = hid_haptic_init(hdev, haptic, hi->input);
+	if (ret)
+		return ret;
+
+	if (hi->application == HID_DG_TOUCHPAD)
+		__set_bit(INPUT_PROP_PRESSUREPAD, hi->input->propbit);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(hid_haptic_input_configured);
+
 void hid_haptic_pressure_reset(struct hid_haptic_device *haptic)
 {
 	haptic->pressure_sum = 0;
diff --git a/drivers/hid/hid-haptic.h b/drivers/hid/hid-haptic.h
index 6332991a7844..e39104f75229 100644
--- a/drivers/hid/hid-haptic.h
+++ b/drivers/hid/hid-haptic.h
@@ -33,12 +33,11 @@ struct hid_haptic_device {
 	struct mutex auto_trigger_mutex;
 	struct workqueue_struct *wq;
 	struct hid_report *manual_trigger_report;
+	struct hid_field *pressure_field;
 	struct mutex manual_trigger_mutex;
 	size_t manual_trigger_report_len;
 	int pressed_state;
 	s32 pressure_sum;
-	s32 force_logical_minimum;
-	s32 force_physical_minimum;
 	s32 force_resolution;
 	u32 mode;
 	u32 default_auto_trigger;
@@ -55,6 +54,12 @@ struct hid_haptic_device {
 };
 
 #if IS_ENABLED(CONFIG_HID_HAPTIC)
+static inline bool hid_haptic_connected_to_input(struct hid_haptic_device *haptic,
+						 struct input_dev *input)
+{
+	return haptic->input_dev == input;
+}
+
 void hid_haptic_feature_mapping(struct hid_device *hdev,
 				struct hid_haptic_device *haptic,
 				struct hid_field *field, struct hid_usage
@@ -76,6 +81,12 @@ void hid_haptic_pressure_reset(struct hid_haptic_device *haptic);
 void hid_haptic_pressure_increase(struct hid_haptic_device *haptic,
 				  __s32 pressure);
 #else
+static inline bool hid_haptic_connected_to_input(struct hid_haptic_device *haptic,
+						 struct input_dev *input)
+{
+	return false;
+}
+
 static inline
 void hid_haptic_feature_mapping(struct hid_device *hdev,
 				struct hid_haptic_device *haptic,
@@ -102,7 +113,7 @@ int hid_haptic_input_configured(struct hid_device *hdev,
 				struct hid_haptic_device *haptic,
 				struct hid_input *hi)
 {
-	return 0;
+	return -EOPNOTSUPP;
 }
 static inline
 void hid_haptic_reset(struct hid_device *hdev, struct hid_haptic_device *haptic)
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index f63d6f6550bd..eaa0b36a9dce 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -1085,7 +1085,7 @@ static void mt_sync_frame(struct mt_device *td, struct mt_application *app,
 
 	app->num_received = 0;
 	app->left_button_state = 0;
-	if (td->is_haptic_touchpad)
+	if (td->is_haptic_touchpad && hid_haptic_connected_to_input(td->haptic, input))
 		hid_haptic_pressure_reset(td->haptic);
 }
 
@@ -1238,7 +1238,7 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input,
 			minor = minor >> 1;
 		}
 
-		if (td->is_haptic_touchpad)
+		if (td->is_haptic_touchpad && hid_haptic_connected_to_input(td->haptic, input))
 			hid_haptic_pressure_increase(td->haptic, *slot->p);
 
 		x = hdev->quirks & HID_QUIRK_X_INVERT ?
@@ -1441,7 +1441,7 @@ static int mt_touch_input_configured(struct hid_device *hdev,
 	if (cls->is_indirect)
 		app->mt_flags |= INPUT_MT_POINTER;
 
-	if (td->is_haptic_touchpad)
+	if (td->is_haptic_touchpad && hid_haptic_connected_to_input(td->haptic, input))
 		app->mt_flags |= INPUT_MT_TOTAL_FORCE;
 
 	if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP)
@@ -1954,14 +1954,8 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
 	struct hid_report *report;
 	int ret;
 
-	if (td->is_haptic_touchpad && (td->mtclass.name == MT_CLS_WIN_8 ||
-	    td->mtclass.name == MT_CLS_WIN_8_FORCE_MULTI_INPUT ||
-	    td->mtclass.name == MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE)) {
-		if (hid_haptic_input_configured(hdev, td->haptic, hi) == 0)
-			td->is_haptic_touchpad = false;
-	} else {
-		td->is_haptic_touchpad = false;
-	}
+	if (td->is_haptic_touchpad && hid_haptic_connected_to_input(td->haptic, hi->input))
+		td->is_haptic_touchpad = !hid_haptic_input_configured(hdev, td->haptic, hi);
 
 	list_for_each_entry(report, &hi->reports, hidinput_list) {
 		rdata = mt_find_report_data(td, report);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 04/13] HID: haptic: Postpone GET_REPORT to init
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
                   ` (2 preceding siblings ...)
  2026-12-02 18:33 ` [PATCH v6 03/13] HID: haptic, multitouch: Check haptic prerequisite properly Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 05/13] HID: Add hid-plugin framework for loadable plugin modules Rong Zhang
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang

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@rong.moe>
---
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 c396a817ec6e..43e9aa60fca9 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


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 05/13] HID: Add hid-plugin framework for loadable plugin modules
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
                   ` (3 preceding siblings ...)
  2026-12-02 18:33 ` [PATCH v6 04/13] HID: haptic: Postpone GET_REPORT to init Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 06/13] HID: haptic: Convert to a loadable plugin module Rong Zhang
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang

Some devices support some additional HID usage pages which enhance their
capabilities. The support code for these usage pages is called "HID
plugin".

The corresponding HID driver calls functions provided by the plugin to
take the advantage of such enhancements. Without the framework, the HID
driver must have a linkage dependence on the plugin, which is not
optimal because the plugin is always loaded into memory even if no
device actually supports it.

Logically, the dependence should be reversed, i.e., the plugin should be
an optional component of the HID driver and is only loaded by the HID
driver when the device has the usage page.

Introduce hid-plugin framework for loadable plugin modules to achieve
the said logical dependence. Each plugin has a unique hid_plugin_id when
enabled, so that HID drivers can connect to it accordingly.

Plugins can be either builtin or modules. A plugin module is requested
asynchronously when a HID device tries to use it. If the module is not
available yet, the device is probed without the plugin and reprobed once
the plugin registers itself. The reprobe procedure is inspired by commit
c17a7476e4c4 ("HID: core: rewrite the hid-generic automatic unbind").

Once a plugin is fully loaded (or if the plugin is builtin), subsequent
plugin connection attempts only require RCU dereferences and module
refcount increments, without the need of requesting a module.

The plugin's private data is automatically initialized on connection
with its pointer stored into hid_device. Disconnection also frees it
automatically. When the HID device is about to finish probe, unbound
plugins are automatically disconnected, and HID driver removal
disconnects all plugins. When a plugin turns out to be unsuitable for
the associated HID device, it can also be disconnected early to prevent
further use of the plugin.

When a plugin is disabled, its ID maps to HID_PLUGIN_DISABLED, and calls
to the plugin helper functions are eliminated by the compiler.

When all plugins are disabled or when the plugin framework is disabled,
NR_HID_PLUGINS equals 0, and all plugin infrastructures as well as their
call sites are eliminated by the compiler. Note that in this case,
hid_device.plugins[NR_HID_PLUGINS] is still safe as it's not a flexible
array member thanks to -fstrict-flex-arrays=3. Thus, no #ifdef is added
around it.

The Kconfig option HID_PLUGIN is solely used to provide a menuconfig.
Plugins need to select HID_PLUGIN_CORE to really enable the framework.
This aims to ease the migration of existing Kconfig options, so that
olddefconfig won't accidentally disable them after the following
conversion. This also makes sure the hid-plugin framework is not built
when no plugin is enabled.

I volunteer to maintain the framework as well as plugins.

Thanks Benjamin Tissoires for the inspiration for the implementation.

Suggested-by: Benjamin Tissoires <bentiss@kernel.org>
Link: https://lore.kernel.org/linux-input/auypydfkhx2eg7vp764way4batdilzc35inqda3exwzs3tk3ff@oagat6g46zto/
Signed-off-by: Rong Zhang <i@rong.moe>
---
Changes in v6:
- Use request_module_nowait() instead of request_module(), as the latter
  can't be used within aysnc context where some i2c-hid drivers add
  devices
- Disconnect unbound plugins automatically by consulting the
  newly-introduced bound() callback, so that the following patch doesn't
  need hid_haptic_disconnect() in hid-input
- Free plugins' private data in their disconnect() callback for correct
  semantics, i.e., release resources wherever they were allocated
- Check mandatory callbacks on registration
- Add device_lock_assert() annotations
- Constify struct hid_plugin

Changes in v5:
- Manage HID plugins' private data in the framework
- Disconnect all connected HID plugins on HID driver removal
- Add debug printk()s to track (dis)connection and (un)registration
- Only use HID_PLUGIN to build Kconfig menuconfig, rather than having
  plugins depend on it
  - Enable HID_PLUGIN by default to ease Kconfig migration
  - Build the hid-plugin framework only if HID_PLUGIN_CORE is selected
  - HID_HAPTIC will select it in the following change, so that
    olddefconfig preserves HID_HAPTIC's value
  - HID_PLUGIN shows an empty menu yet. if-endif will be added later

Changes in v4:
- Drop synchronize_rcu() during registration as other drivers do, as
there is nothing to protect

Changes in v3:
- Add missing Return: to hid_plugin_register()'s kernel-doc (thanks
  Sashiko)
---
 MAINTAINERS              |   6 +
 drivers/hid/Kconfig      |  17 +++
 drivers/hid/Makefile     |   2 +
 drivers/hid/hid-core.c   |   6 +
 drivers/hid/hid-plugin.c | 301 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-plugin.h | 257 ++++++++++++++++++++++++++++++++++++++++
 include/linux/hid.h      |  14 +++
 7 files changed, 603 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index a5b2219bf508..cf24f0499ee2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11908,6 +11908,12 @@ L:	linux-input@vger.kernel.org
 S:	Supported
 F:	drivers/hid/hid-playstation.c
 
+HID PLUGINS
+M:	Rong Zhang <i@rong.moe>
+L:	linux-input@vger.kernel.org
+S:	Maintained
+F:	drivers/hid/hid-plugin.*
+
 HID PULSAR DRIVER
 M:	Nikolas Koesling <nikolas@koesling.info>
 L:	linux-input@vger.kernel.org
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 51d31368125c..b500b1e392c8 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -92,6 +92,23 @@ config HID_GENERIC
 
 	If unsure, say Y.
 
+menuconfig HID_PLUGIN
+	bool "HID plugins"
+	default y
+	help
+	Support for HID plugins, which enhance associated HID drivers by
+	providing support for additional HID usage pages.
+
+	Plugins can be either builtin or modules. A plugin module is requested
+	asynchronously when a HID device tries to use it. If the module is not
+	available yet, the device is probed without the plugin and reprobed once
+	the plugin registers itself.
+
+	If unsure, say Y.
+
+config HID_PLUGIN_CORE
+	bool
+
 config HID_HAPTIC
 	bool "Haptic touchpad support"
 	default n
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 2257eb2ee2e4..315e337b9ec7 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -4,6 +4,8 @@
 #
 hid-y			:= hid-core.o hid-input.o hid-quirks.o
 hid-$(CONFIG_DEBUG_FS)		+= hid-debug.o
+hid-$(CONFIG_HID_PLUGIN_CORE)	+= hid-plugin.o
+
 hid-$(CONFIG_HID_HAPTIC)	+= hid-haptic.o
 
 obj-$(CONFIG_HID_BPF)		+= bpf/
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index ceff3c80d996..318ddb9c76cb 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -34,6 +34,7 @@
 
 #include "hid-core.h"
 #include "hid-ids.h"
+#include "hid-plugin.h"
 #include "hidraw.h"
 
 /*
@@ -2857,7 +2858,10 @@ static int __hid_device_probe(struct hid_device *hdev, struct hid_driver *hdrv)
 			hid_device_io_stop(hdev);
 		devres_release_group(&hdev->dev, hdev->devres_group_id);
 		hid_close_report(hdev);
+		hid_plugin_cleanup(hdev);
 		hdev->driver = NULL;
+	} else {
+		hid_plugin_prune(hdev);
 	}
 
 	return ret;
@@ -2903,6 +2907,7 @@ static void hid_device_remove(struct device *dev)
 		devres_release_group(&hdev->dev, hdev->devres_group_id);
 
 		hid_close_report(hdev);
+		hid_plugin_cleanup(hdev);
 		hdev->driver = NULL;
 	}
 
@@ -3279,6 +3284,7 @@ static void __exit hid_exit(void)
 #ifdef CONFIG_HID_BPF
 	hid_ops = NULL;
 #endif
+	hid_plugin_exit();
 	hid_debug_exit();
 	hidraw_exit();
 	bus_unregister(&hid_bus_type);
diff --git a/drivers/hid/hid-plugin.c b/drivers/hid/hid-plugin.c
new file mode 100644
index 000000000000..63e4afca4f3a
--- /dev/null
+++ b/drivers/hid/hid-plugin.c
@@ -0,0 +1,301 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ *  HID plugin helpers
+ *
+ *  Copyright (c) 2026 Rong Zhang <i@rong.moe>
+ */
+
+#define pr_fmt(fmt) "hid-plugin: " fmt
+#define dev_fmt pr_fmt
+
+#include <linux/bitmap.h>
+#include <linux/bug.h>
+#include <linux/cleanup.h>
+#include <linux/compiler.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/hid.h>
+#include <linux/jiffies.h>
+#include <linux/module.h>
+#include <linux/printk.h>
+#include <linux/rcupdate.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/workqueue.h>
+
+#include "hid-plugin.h"
+
+static const char * const hid_plugin_mod_names[NR_HID_PLUGINS] = {
+};
+
+static const struct hid_plugin __rcu *hid_plugins[NR_HID_PLUGINS];
+
+static const struct hid_plugin *hid_plugin_try_module_get(enum hid_plugin_id id)
+{
+	const struct hid_plugin *plugin;
+
+	guard(rcu)();
+
+	plugin = rcu_dereference(hid_plugins[id]);
+	if (!plugin)
+		return NULL;
+
+	/*
+	 * If the module is unloading, defer the plugin without requesting the
+	 * module again, so that the device can still be reprobed once the
+	 * plugin module is somehow loaded by others.
+	 */
+	return try_module_get(plugin->owner) ? plugin : ERR_PTR(-EAGAIN);
+}
+
+static const struct hid_plugin *hid_plugin_request(struct hid_device *hdev, enum hid_plugin_id id)
+{
+	const struct hid_plugin *plugin;
+	const char *mod_name;
+	int ret;
+
+	plugin = hid_plugin_try_module_get(id);
+	if (plugin)
+		return plugin;
+
+	mod_name = hid_plugin_mod_names[id];
+	if (WARN_ON(!mod_name)) /* Huh? Builtin plugins can't reach here. */
+		return ERR_PTR(-ENXIO);
+
+	ret = request_module_nowait("%s", mod_name);
+
+	/*
+	 * Errors could be transient, so always return -EAGAIN even on error.
+	 * See also hid_plugin_try_module_get().
+	 */
+	if (ret)
+		hid_warn(hdev, "Failed to request [%d]%s: %d\n", id, mod_name, ret);
+	else
+		hid_dbg(hdev, "Requested [%d]%s\n", id, mod_name);
+
+	/*
+	 * There is a chance that the module may have been ready due to others
+	 * loading the same module at the same time or reschedule latency. Retry
+	 * optimistically, otherwise defer the plugin.
+	 */
+	plugin = hid_plugin_try_module_get(id);
+
+	return plugin ?: ERR_PTR(-EAGAIN);
+}
+
+void *__hid_plugin_connect(struct hid_device *hdev, enum hid_plugin_id id)
+{
+	const struct hid_plugin *plugin;
+	void *priv;
+
+	device_lock_assert(&hdev->dev);
+
+	if (WARN_ON(hdev->plugins[id]))
+		return ERR_PTR(-EEXIST);
+
+	plugin = hid_plugin_request(hdev, id);
+	if (IS_ERR(plugin)) {
+		hdev->plugins[id] = ERR_CAST(plugin);
+		return ERR_CAST(plugin);
+	}
+
+	priv = plugin->connect(hdev);
+	if (WARN_ON(!priv))
+		priv = ERR_PTR(-ENOTCONN);
+	if (IS_ERR(priv)) {
+		module_put(plugin->owner);
+		hid_warn(hdev, "Failed to connect [%d]: %pe\n", id, priv);
+	} else {
+		hid_dbg(hdev, "Connected [%d]\n", id);
+	}
+
+	hdev->plugins[id] = priv;
+	return priv;
+}
+EXPORT_SYMBOL_GPL(__hid_plugin_connect);
+
+static void hid_plugin_disconnect_with_err(struct hid_device *hdev, enum hid_plugin_id id,
+					   int err, bool force)
+{
+	const struct hid_plugin *plugin;
+
+	if (IS_ERR_OR_NULL(hdev->plugins[id])) {
+		if (force)
+			hdev->plugins[id] = ERR_PTR(err);
+		return;
+	}
+
+	/*
+	 * The HID device still holds the plugin's module refcount and protects
+	 * our access.
+	 */
+	plugin = rcu_dereference_protected(hid_plugins[id], true);
+
+	if (!force && plugin->bound(hdev, hdev->plugins[id]))
+		return;
+
+	plugin->disconnect(hdev, hdev->plugins[id]);
+	hdev->plugins[id] = ERR_PTR(err);
+	module_put(plugin->owner);
+
+	hid_dbg(hdev, "Disconnected [%d]: %d\n", id, err);
+}
+
+void __hid_plugin_disconnect(struct hid_device *hdev, enum hid_plugin_id id)
+{
+	device_lock_assert(&hdev->dev);
+
+	hid_plugin_disconnect_with_err(hdev, id, -EIDRM, true);
+}
+EXPORT_SYMBOL_GPL(__hid_plugin_disconnect);
+
+void __hid_plugin_prune(struct hid_device *hdev)
+{
+	device_lock_assert(&hdev->dev);
+
+	for (int i = 0; i < NR_HID_PLUGINS; i++)
+		hid_plugin_disconnect_with_err(hdev, i, -EIDRM, false);
+}
+
+void __hid_plugin_cleanup(struct hid_device *hdev)
+{
+	device_lock_assert(&hdev->dev);
+
+	for (int i = 0; i < NR_HID_PLUGINS; i++)
+		hid_plugin_disconnect_with_err(hdev, i, 0, true);
+}
+
+static unsigned long hid_plugin_reprobe_mask;
+static_assert(NR_HID_PLUGINS > 0 && NR_HID_PLUGINS <= BITS_PER_LONG);
+
+static bool hid_plugin_is_deferred(struct hid_device *hdev, unsigned long *mask)
+{
+	int i;
+
+	/*
+	 * Driver probe and exit may manipulate hdev->plugins. We need to wait
+	 * until their values stabilize to prevent missing any deferral.
+	 */
+	scoped_guard(device, &hdev->dev) {
+		for_each_set_bit(i, mask, NR_HID_PLUGINS) {
+			void *priv = hdev->plugins[i];
+
+			if (IS_ERR(priv) && PTR_ERR(priv) == -EAGAIN)
+				return true;
+		}
+	}
+
+	return false;
+}
+
+static int hid_plugin_reprobe_waiting(struct device *dev, void *data)
+{
+	struct hid_device *hdev = to_hid_device(dev);
+	unsigned long *mask = data;
+	int ret;
+
+	if (!hid_plugin_is_deferred(hdev, mask))
+		return 0;
+
+	/*
+	 * In the small window here, the device lock is dropped and the device
+	 * may be reprobed due to other reasons. The rare extra reprobe should
+	 * be fine as long as no deferral is missed.
+	 */
+
+	ret = device_reprobe(dev);
+	hid_dbg(hdev, "Reprobed due to deferred plugin registration: %d\n", ret);
+
+	/*
+	 * Ignore errors. The device can still be used without the plugin, and
+	 * a later plugin (re)registration or driver binding will retry probing.
+	 */
+	return 0;
+}
+
+static void hid_plugin_reprobe_worker(struct work_struct *work)
+{
+	unsigned long mask = xchg(&hid_plugin_reprobe_mask, 0);
+	int ret, i;
+
+	/*
+	 * Rule out unregistering plugins, otherwise temporarily prohibit
+	 * module unloading until we've done.
+	 */
+	for_each_set_bit(i, &mask, NR_HID_PLUGINS) {
+		ret = IS_ERR_OR_NULL(hid_plugin_try_module_get(i));
+		if (ret)
+			__clear_bit(i, &mask);
+	}
+
+	if (!mask)
+		return;
+
+	ret = bus_for_each_dev(&hid_bus_type, NULL, &mask, hid_plugin_reprobe_waiting);
+	if (ret)
+		pr_warn("Failed to scan devices for [%*pbl] registration: %d\n",
+			NR_HID_PLUGINS, &mask, ret);
+
+	for_each_set_bit(i, &mask, NR_HID_PLUGINS) {
+		/* Protected by module refcount. */
+		const struct hid_plugin *plugin = rcu_dereference_protected(hid_plugins[i], true);
+
+		module_put(plugin->owner);
+	}
+}
+
+#define REPROBE_DELAY msecs_to_jiffies(200)
+static DECLARE_DELAYED_WORK(hid_plugin_reprobe_dwork, hid_plugin_reprobe_worker);
+
+int __hid_plugin_register(enum hid_plugin_id id, const struct hid_plugin *plugin)
+{
+	if (WARN_ON(!plugin->connect || !plugin->disconnect || !plugin->bound))
+		return -EINVAL;
+
+	/*
+	 * The corresponding plugin is the only writer of hid_plugins[id], so
+	 * there is no need to protect the our access during registration, as
+	 * any reader in prior must have got NULL, i.e., there is nothing to
+	 * protect or synchronize.
+	 *
+	 * However, try our best to do some sanity checks.
+	 */
+	if (WARN_ON(rcu_access_pointer(hid_plugins[id])))
+		return -EEXIST;
+
+	rcu_assign_pointer(hid_plugins[id], plugin);
+
+	/* Builtin plugins are registered before driver probe. */
+	if (plugin->owner) {
+		/*
+		 * If an HID device happens to request multiple plugins, wait
+		 * for a while to hopefully merge successive reprobe requests.
+		 */
+		WARN_ON(test_and_set_bit(id, &hid_plugin_reprobe_mask));
+		mod_delayed_work(system_dfl_wq, &hid_plugin_reprobe_dwork, REPROBE_DELAY);
+	}
+
+	pr_debug("Registered [%d]\n", id);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(__hid_plugin_register);
+
+void __hid_plugin_unregister(enum hid_plugin_id id, const struct hid_plugin *plugin)
+{
+	if (WARN_ON(rcu_access_pointer(hid_plugins[id]) != plugin))
+		return;
+
+	clear_bit(id, &hid_plugin_reprobe_mask);
+
+	rcu_assign_pointer(hid_plugins[id], NULL);
+	synchronize_rcu();
+
+	pr_debug("Unregistered [%d]\n", id);
+}
+EXPORT_SYMBOL_GPL(__hid_plugin_unregister);
+
+void __hid_plugin_exit(void)
+{
+	disable_delayed_work_sync(&hid_plugin_reprobe_dwork);
+}
diff --git a/drivers/hid/hid-plugin.h b/drivers/hid/hid-plugin.h
new file mode 100644
index 000000000000..2d411e970285
--- /dev/null
+++ b/drivers/hid/hid-plugin.h
@@ -0,0 +1,257 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ *  HID plugin helpers
+ *
+ *  Copyright (c) 2026 Rong Zhang <i@rong.moe>
+ */
+
+#ifndef __HID_PLUGIN_H
+#define __HID_PLUGIN_H
+
+#include <linux/build_bug.h>
+#include <linux/compiler.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/hid.h>
+#include <linux/init.h>
+#include <linux/module.h>
+
+/**
+ * struct hid_plugin - HID plugin
+ *
+ * @owner:	Plugin's owner module
+ * @connect:	Called on plugin connection to allocate and initialize the
+ *		plugin's private data. Usually the private data stores a pointer
+ *		to the plugin itself to expose plugin-specific methods. Context:
+ *		process context during driver probe.
+ * @disconnect:	Called on plugin disconnection to release all allocated
+ *		resources. Must be safe to call no matter the plugin is
+ *		currently bound or not. Context: process context during driver
+ *		probe or removal.
+ * @bound:	Called when driver probe is about to finish. Return true if the
+ *		plugin has bound something to the HID device, otherwise the
+ *		plugin framework will automatically disconnect the plugin.
+ *		Context: process context during driver probe.
+ */
+struct hid_plugin {
+	struct module *owner;
+	void *(*connect)(struct hid_device *hdev);
+	void (*disconnect)(struct hid_device *hdev, void *priv);
+	bool (*bound)(struct hid_device *hdev, void *priv);
+};
+
+void *__hid_plugin_connect(struct hid_device *hdev, enum hid_plugin_id id);
+void __hid_plugin_disconnect(struct hid_device *hdev, enum hid_plugin_id id);
+void __hid_plugin_prune(struct hid_device *hdev);
+void __hid_plugin_cleanup(struct hid_device *hdev);
+int __hid_plugin_register(enum hid_plugin_id id, const struct hid_plugin *plugin);
+void __hid_plugin_unregister(enum hid_plugin_id id, const struct hid_plugin *plugin);
+void __hid_plugin_exit(void);
+
+/**
+ * hid_plugin_is_enabled() - Check if a plugin is enabled
+ * @id: Unique ID of the desired HID plugin, must be a constant expression
+ *
+ * Return: Boolean.
+ */
+static __always_inline bool hid_plugin_is_enabled(enum hid_plugin_id id)
+{
+	BUILD_BUG_ON(!__builtin_constant_p(id) || id >= NR_HID_PLUGINS || id < HID_PLUGIN_DISABLED);
+
+	return id != HID_PLUGIN_DISABLED;
+}
+
+/**
+ * hid_plugin_to_priv() - Retrieve a plugin's private data
+ * @hdev: HID device
+ * @id: Unique ID of the HID plugin
+ *
+ * Retrieve the private data of a connected HID plugin.
+ *
+ * Context: Any context. Concurrent calls to hid_plugin_connect() or
+ * hid_plugin_disconnect() are forbidden, see also the said methods' context.
+ *
+ * Return: Pointer to the private data of the HID plugin. NULL if the plugin has
+ * not been connected. ERR_PTR() if the plugin is disabled, disconnected early,
+ * failed to connect, or is just requested.
+ */
+static __always_inline void *hid_plugin_to_priv(struct hid_device *hdev, enum hid_plugin_id id)
+{
+	if (!hid_plugin_is_enabled(id))
+		return ERR_PTR(-EOPNOTSUPP);
+
+	return hdev->plugins[id];
+}
+
+/**
+ * hid_plugin_connect() - Connect a plugin to an HID device
+ * @hdev: HID device
+ * @id: Unique ID of the HID plugin
+ *
+ * Connect the plugin to @hdev with the plugin's module refcount incremented.
+ * If the plugin's module is not loaded yet, it is requested asynchronously and
+ * the device continues to probe without the plugin. The device is reprobed once
+ * the plugin registers, at which point the plugin is connected.
+ *
+ * Must call hid_plugin_to_priv() in prior to try retrieving the plugin's
+ * private data, and only call this when it turns out to be not connected.
+ *
+ * Context: Process context. Can only be called while probing @hdev driver.
+ *
+ * Return: Pointer to the private data of the HID plugin, or ERR_PTR(). In the
+ * latter case, subsequent calls to hid_plugin_to_priv() also returns ERR_PTR()
+ * to prevent further connection attempts.
+ */
+static __always_inline void *hid_plugin_connect(struct hid_device *hdev, enum hid_plugin_id id)
+{
+	if (!hid_plugin_is_enabled(id))
+		return ERR_PTR(-EOPNOTSUPP);
+
+	return __hid_plugin_connect(hdev, id);
+}
+
+/**
+ * hid_plugin_disconnect() - Disconnect a plugin from an HID device early
+ * @hdev: HID device
+ * @id: Unique ID of the HID plugin
+ *
+ * Disconnect a connected HID plugin from @hdev, and decrement the plugin's
+ * module refcount. Calling this when the plugin is not currently connected is a
+ * no-op, except that ERR_PTR(-EIDRM) is still propagated (see below).
+ *
+ * Usually plugins are automatically disconnected by the HID core. This is
+ * provided to disconnect a plugin early to prevent further use of the plugin.
+ * After disconnection, the plugin's private data is freed and any subsequent
+ * calls to hid_plugin_to_priv() will return ERR_PTR(-EIDRM).
+ *
+ * Context: Any context outside the plugin module. Can only be called while
+ * probing or removing @hdev driver.
+ */
+static __always_inline void hid_plugin_disconnect(struct hid_device *hdev, enum hid_plugin_id id)
+{
+	if (!hid_plugin_is_enabled(id))
+		return;
+
+	__hid_plugin_disconnect(hdev, id);
+}
+
+/**
+ * hid_plugin_prune() - Disconnect unbound plugins from an HID device
+ * @hdev: HID device
+ *
+ * Disconnect all unbound HID plugins from @hdev. Similar to calling
+ * hid_plugin_disconnect() on every connected but unbound plugin. IOW, this does
+ * not affect any plugin that is not currently connected.
+ *
+ * Context: Any context. Called while HID core is about to finish @hdev probe.
+ * Plugins should use hid_plugin_disconnect() instead.
+ */
+static __always_inline void hid_plugin_prune(struct hid_device *hdev)
+{
+	if (!NR_HID_PLUGINS)
+		return;
+
+	__hid_plugin_prune(hdev);
+}
+
+/**
+ * hid_plugin_cleanup() - Disconnect all plugins from an HID device
+ * @hdev: HID device
+ *
+ * Disconnect all connected HID plugins from @hdev. Unlike
+ * hid_plugin_disconnect(), this permits (or reenables) further connection
+ * attempts.
+ *
+ * Context: Any context. Called while HID core is removing @hdev driver.
+ * Plugins should use hid_plugin_disconnect() instead.
+ */
+static __always_inline void hid_plugin_cleanup(struct hid_device *hdev)
+{
+	if (!NR_HID_PLUGINS)
+		return;
+
+	__hid_plugin_cleanup(hdev);
+}
+
+/**
+ * hid_plugin_register() - Register a plugin
+ * @id: Unique ID of @plugin
+ * @plugin: Pointer to the HID plugin
+ *
+ * This also reprobes all HID devices that have requested the plugin, so that
+ * they can connect to it.
+ *
+ * Context: Any context.
+ *
+ * Return: 0 on success, or an error.
+ */
+static __always_inline int hid_plugin_register(enum hid_plugin_id id,
+					       const struct hid_plugin *plugin)
+{
+	BUILD_BUG_ON(!hid_plugin_is_enabled(id));
+
+	return __hid_plugin_register(id, plugin);
+}
+
+/**
+ * hid_plugin_unregister() - Unregister a plugin
+ * @id: Unique ID of @plugin
+ * @plugin: Pointer to the HID plugin
+ *
+ * Context: Process context.
+ */
+static __always_inline void hid_plugin_unregister(enum hid_plugin_id id,
+						  const struct hid_plugin *plugin)
+{
+	BUILD_BUG_ON(!hid_plugin_is_enabled(id));
+
+	__hid_plugin_unregister(id, plugin);
+}
+
+/**
+ * hid_plugin_exit() - Disable device reprobe on plugin registration
+ *
+ * Context: Any context. Called before removing the HID bus.
+ */
+static __always_inline void hid_plugin_exit(void)
+{
+	if (!NR_HID_PLUGINS)
+		return;
+
+	__hid_plugin_exit();
+}
+
+/*
+ * Usage:
+ *
+ *	struct hid_foo_plugin {
+ *		struct hid_plugin hp;
+ *		void (*bar)(struct hid_device *hdev);
+ *	};
+ *
+ *	static const struct hid_foo_plugin hid_foo_plugin = {
+ *		.hp = {
+ *			.owner = THIS_MODULE,
+ *			.connect = foo_plugin_connect,
+ *			.disconnect = foo_plugin_disconnect,
+ *			.bound = foo_plugin_bound,
+ *		},
+ *		.bar = hid_foo_bar,
+ *	};
+ *	module_hid_plugin(hid_foo, HID_PLUGIN_FOO, &hid_foo_plugin.hp);
+ *
+ * Must also update hid_plugin_id and hid_plugin_mod_names.
+ */
+#define module_hid_plugin(_name, _id, _plugin)		\
+static int __init hid_plugin_##_name##_init(void)	\
+{							\
+	return hid_plugin_register(_id, _plugin);	\
+}							\
+subsys_initcall(hid_plugin_##_name##_init);		\
+static void __exit hid_plugin_##_name##_exit(void)	\
+{							\
+	hid_plugin_unregister(_id, _plugin);		\
+}							\
+module_exit(hid_plugin_##_name##_exit)
+
+#endif /* __HID_PLUGIN_H */
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 4b58e9b4ae43..f881f5631cfe 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -15,6 +15,7 @@
 
 
 #include <linux/bitops.h>
+#include <linux/build_bug.h>
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/list.h>
@@ -22,6 +23,7 @@
 #include <linux/timer.h>
 #include <linux/workqueue.h>
 #include <linux/input.h>
+#include <linux/kconfig.h>
 #include <linux/semaphore.h>
 #include <linux/mutex.h>
 #include <linux/power_supply.h>
@@ -671,6 +673,16 @@ struct hid_battery {
 struct hid_driver;
 struct hid_ll_driver;
 
+enum hid_plugin_id {
+	HID_PLUGIN_DISABLED	= -1,
+
+	NR_HID_PLUGINS,
+};
+
+#if !IS_ENABLED(CONFIG_HID_PLUGIN_CORE)
+static_assert(NR_HID_PLUGINS == 0);
+#endif
+
 struct hid_device {
 	const __u8 *dev_rdesc;						/* device report descriptor */
 	const __u8 *bpf_rdesc;						/* bpf modified report descriptor, if any */
@@ -752,6 +764,8 @@ struct hid_device {
 #ifdef CONFIG_HID_BPF
 	struct hid_bpf bpf;						/* hid-bpf data */
 #endif /* CONFIG_HID_BPF */
+
+	struct hid_plugin_private *plugins[NR_HID_PLUGINS];
 };
 
 void hiddev_free(struct kref *ref);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 06/13] HID: haptic: Convert to a loadable plugin module
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
                   ` (4 preceding siblings ...)
  2026-12-02 18:33 ` [PATCH v6 05/13] HID: Add hid-plugin framework for loadable plugin modules Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  2026-12-02 19:07   ` sashiko-bot
  2026-12-02 18:33 ` [PATCH v6 07/13] HID: haptic: Adopt pr_fmt, dev_fmt and hid_*() printk helpers Rong Zhang
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang

Commit 083a4f3f3cc7 ("HID: Kconfig: Fix build error from
CONFIG_HID_HAPTIC") built hid-haptic into vmlinux or hid.ko. This is not
optimal for generic kernel images, as a platform with no multitouch
device doesn't need it anyway. It's also a bit harsh for enabling it in
distribution kernels.

With the new hid-plugin framework, convert hid-haptic into a loadable
plugin module, which is only requested on demand.

The plugin provides complicated methods as callbacks, which can be
called by using the associated static inline wrappers. Simple methods
are moved to the header file as static inline ones, too.

The plugin now connects to hid-input instead of hid-multitouch, only
leaving several hooks in the latter. Despite that, it still only works
on hid-multitouch devices. The limitation will be lifted in the future.

If the HID driver provides EV_FF itself or ask the HID core not to
register FF devices, no haptic FF device is registered. Ditto if the
device supports PIDFF, or if the input device is unpopulated.

When hid-haptic is disabled, the hid-plugin framework's helper functions
will ensure that all calls to its methods are subject to dead code
elimination during compilation.

The redaundent `default n' statement in Kconfig is also removed for
tidiness since we are anyway touching its context.

Suggested-by: Benjamin Tissoires <bentiss@kernel.org>
Link: https://lore.kernel.org/linux-input/auypydfkhx2eg7vp764way4batdilzc35inqda3exwzs3tk3ff@oagat6g46zto/
Signed-off-by: Rong Zhang <i@rong.moe>
---
Changes in v6:
- Do not attach haptic FF to unpopulated input (thanks Sashiko)
- Prefer PIDFF over hid-haptic
- Drop hid_haptic_disconnect() from hidinput_connect() in favor of
  hid_plugin_prune()
  - hid_haptic_input_configured() still calls it to disconnect the
    plugin on error

Changes in v5:
- Adopt the new hid-plugin design
- Connect to hid-input
- Alloc hid_haptic_device in hid_haptic_feature_mapping()
- Don't move complicated methods to the header file
---
 MAINTAINERS                  |   1 +
 drivers/hid/Kconfig          |   8 +-
 drivers/hid/Makefile         |   2 +-
 drivers/hid/hid-haptic.c     |  97 ++++++++++++++----------
 drivers/hid/hid-haptic.h     | 172 ++++++++++++++++++++++++++-----------------
 drivers/hid/hid-input.c      |  40 +++++++++-
 drivers/hid/hid-multitouch.c |  35 ++-------
 drivers/hid/hid-plugin.c     |   3 +
 include/linux/hid.h          |   8 +-
 9 files changed, 227 insertions(+), 139 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index cf24f0499ee2..a405151c7a12 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11912,6 +11912,7 @@ HID PLUGINS
 M:	Rong Zhang <i@rong.moe>
 L:	linux-input@vger.kernel.org
 S:	Maintained
+F:	drivers/hid/hid-haptic.*
 F:	drivers/hid/hid-plugin.*
 
 HID PULSAR DRIVER
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index b500b1e392c8..04ab152b3d54 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -106,12 +106,14 @@ menuconfig HID_PLUGIN
 
 	If unsure, say Y.
 
+if HID_PLUGIN
+
 config HID_PLUGIN_CORE
 	bool
 
 config HID_HAPTIC
-	bool "Haptic touchpad support"
-	default n
+	tristate "Haptic touchpad support"
+	select HID_PLUGIN_CORE
 	help
 	Support for touchpads with force sensors and haptic actuators instead of a
 	traditional button.
@@ -120,6 +122,8 @@ config HID_HAPTIC
 
 	If unsure, say N.
 
+endif # HID_PLUGIN
+
 menu "Special HID drivers"
 
 config HID_A4TECH
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 315e337b9ec7..0c7e2fb9fe8f 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -6,7 +6,7 @@ hid-y			:= hid-core.o hid-input.o hid-quirks.o
 hid-$(CONFIG_DEBUG_FS)		+= hid-debug.o
 hid-$(CONFIG_HID_PLUGIN_CORE)	+= hid-plugin.o
 
-hid-$(CONFIG_HID_HAPTIC)	+= hid-haptic.o
+obj-$(CONFIG_HID_HAPTIC)	+= hid-haptic.o
 
 obj-$(CONFIG_HID_BPF)		+= bpf/
 
diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index 43e9aa60fca9..ab2366a58de4 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -5,14 +5,14 @@
  *  Copyright (c) 2021 Angela Czubak <acz@semihalf.com>
  */
 
+#include <linux/err.h>
 #include <linux/input/mt.h>
 #include <linux/module.h>
 
 #include "hid-haptic.h"
 
-void hid_haptic_feature_mapping(struct hid_device *hdev,
-				struct hid_haptic_device *haptic,
-				struct hid_field *field, struct hid_usage *usage)
+static void __hid_haptic_feature_mapping(struct hid_device *hdev, struct hid_haptic_device *haptic,
+					 struct hid_field *field, struct hid_usage *usage)
 {
 	u16 usage_hid;
 
@@ -39,10 +39,9 @@ void hid_haptic_feature_mapping(struct hid_device *hdev,
 		}
 	}
 }
-EXPORT_SYMBOL_GPL(hid_haptic_feature_mapping);
 
-bool hid_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
-				    struct hid_input *hi, struct hid_field *field)
+static bool __hid_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
+					     struct hid_input *hi, struct hid_field *field)
 {
 	if (IS_ERR(haptic->input_dev))
 		return false;
@@ -78,23 +77,6 @@ bool hid_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
 	haptic->input_dev = ERR_PTR(-EPROTO);
 	return false;
 }
-EXPORT_SYMBOL_GPL(hid_haptic_check_pressure_unit);
-
-int hid_haptic_input_mapping(struct hid_device *hdev,
-			     struct hid_haptic_device *haptic,
-			     struct hid_input *hi,
-			     struct hid_field *field, struct hid_usage *usage,
-			     unsigned long **bit, int *max)
-{
-	if (usage->hid == HID_HP_MANUALTRIGGER) {
-		haptic->manual_trigger_report = field->report;
-		/* we don't really want to map these fields */
-		return -1;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(hid_haptic_input_mapping);
 
 static void parse_auto_trigger_field(struct hid_haptic_device *haptic,
 				     struct hid_field *field)
@@ -396,6 +378,9 @@ static void hid_haptic_destroy(struct ff_device *ff)
 
 	kfree(haptic->hid_usage_map);
 	haptic->hid_usage_map = NULL;
+
+	/* Our private data is managed by hid-plugin. */
+	ff->private = NULL;
 }
 
 static void hid_haptic_get_reports(struct hid_device *hdev, struct hid_haptic_device *haptic)
@@ -408,9 +393,8 @@ static void hid_haptic_get_reports(struct hid_device *hdev, struct hid_haptic_de
 	hid_device_io_stop(hdev);
 }
 
-int hid_haptic_init(struct hid_device *hdev,
-		    struct hid_haptic_device *haptic,
-		    struct input_dev *dev)
+static int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *haptic,
+			   struct input_dev *dev)
 {
 	struct ff_device *ff;
 	int ret = 0, r;
@@ -531,7 +515,6 @@ int hid_haptic_init(struct hid_device *hdev,
 	hid_warn(hdev, "Cannot allocate haptic for %s: %d\n", hdev->name, ret);
 	return ret;
 }
-EXPORT_SYMBOL_GPL(hid_haptic_init);
 
 static int hid_haptic_check_prerequisites(struct hid_device *hdev,
 					  struct hid_haptic_device *haptic, struct hid_input *hi)
@@ -542,14 +525,18 @@ static int hid_haptic_check_prerequisites(struct hid_device *hdev,
 	if (IS_ERR_OR_NULL(haptic->input_dev))
 		return PTR_ERR(haptic->input_dev) ?: -EXDEV;
 
+	/* Check the prerequisites only. */
+	if (!hi)
+		return 1;
+
 	if (haptic->input_dev == hi->input)
 		return 0;
 
 	return 1; /* Waiting for the relevant input device. */
 }
 
-int hid_haptic_input_configured(struct hid_device *hdev,
-				struct hid_haptic_device *haptic, struct hid_input *hi)
+static int __hid_haptic_input_configured(struct hid_device *hdev,
+					 struct hid_haptic_device *haptic, struct hid_input *hi)
 {
 	int ret;
 
@@ -566,17 +553,53 @@ int hid_haptic_input_configured(struct hid_device *hdev,
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(hid_haptic_input_configured);
 
-void hid_haptic_pressure_reset(struct hid_haptic_device *haptic)
+static const struct hid_plugin_haptic hid_plugin_haptic;
+
+static void *hid_haptic_plugin_connect(struct hid_device *hdev)
 {
-	haptic->pressure_sum = 0;
+	struct hid_haptic_device *haptic = kzalloc_obj(*haptic);
+
+	if (!haptic)
+		return ERR_PTR(-ENOMEM);
+
+	haptic->hdev = hdev;
+	haptic->plugin = &hid_plugin_haptic;
+	return haptic;
 }
-EXPORT_SYMBOL_GPL(hid_haptic_pressure_reset);
 
-void hid_haptic_pressure_increase(struct hid_haptic_device *haptic,
-				 __s32 pressure)
+static bool hid_haptic_plugin_bound(struct hid_device *hdev, void *data)
 {
-	haptic->pressure_sum += pressure;
+	struct hid_haptic_device *haptic = data;
+
+	return !!haptic->wq;
 }
-EXPORT_SYMBOL_GPL(hid_haptic_pressure_increase);
+
+static void hid_haptic_plugin_disconnect(struct hid_device *hdev, void *data)
+{
+	/*
+	 * The FF device must have been destroyed when we reach here, but if
+	 * something goes wrong, leak our private data and pray...
+	 */
+	if (!WARN_ON(hid_haptic_plugin_bound(hdev, data)))
+		kfree(data);
+}
+
+static const struct hid_plugin_haptic hid_plugin_haptic = {
+	.hp = {
+		.owner = THIS_MODULE,
+		.connect = hid_haptic_plugin_connect,
+		.disconnect = hid_haptic_plugin_disconnect,
+		.bound = hid_haptic_plugin_bound,
+	},
+	.feature_mapping = __hid_haptic_feature_mapping,
+	.check_pressure_unit = __hid_haptic_check_pressure_unit,
+	.input_configured = __hid_haptic_input_configured,
+};
+module_hid_plugin(haptic, HID_PLUGIN_HAPTIC, &hid_plugin_haptic.hp);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Angela Czubak <aczubak@google.com>");
+MODULE_AUTHOR("Jonathan Denose <jdenose@google.com>");
+MODULE_AUTHOR("Rong Zhang <i@rong.moe>");
+MODULE_DESCRIPTION("HID helpers for Haptics Page");
diff --git a/drivers/hid/hid-haptic.h b/drivers/hid/hid-haptic.h
index e39104f75229..18cf4505f719 100644
--- a/drivers/hid/hid-haptic.h
+++ b/drivers/hid/hid-haptic.h
@@ -5,8 +5,13 @@
  *  Copyright (c) 2021 Angela Czubak <acz@semihalf.com>
  */
 
+#include <linux/compiler.h>
+#include <linux/container_of.h>
+#include <linux/err.h>
 #include <linux/hid.h>
 
+#include "hid-plugin.h"
+
 #define HID_HAPTIC_ORDINAL_WAVEFORMNONE 1
 #define HID_HAPTIC_ORDINAL_WAVEFORMSTOP 2
 
@@ -51,90 +56,123 @@ struct hid_haptic_device {
 	u16 release_ordinal;
 	struct hid_haptic_effect *effect;
 	struct hid_haptic_effect stop_effect;
+
+	const struct hid_plugin_haptic *plugin;
+};
+
+struct hid_plugin_haptic {
+	struct hid_plugin hp;
+	void (*feature_mapping)(struct hid_device *hdev, struct hid_haptic_device *haptic,
+				struct hid_field *field, struct hid_usage *usage);
+	bool (*check_pressure_unit)(struct hid_haptic_device *haptic,
+				    struct hid_input *hi, struct hid_field *field);
+	int (*input_configured)(struct hid_device *hdev, struct hid_haptic_device *haptic,
+				struct hid_input *hi);
 };
 
-#if IS_ENABLED(CONFIG_HID_HAPTIC)
-static inline bool hid_haptic_connected_to_input(struct hid_haptic_device *haptic,
-						 struct input_dev *input)
+static inline struct hid_haptic_device *hid_plugin_to_haptic(struct hid_device *hdev)
 {
+	return hid_plugin_to_priv(hdev, HID_PLUGIN_HAPTIC);
+}
+
+static inline bool hid_haptic_connected_to_input(struct hid_device *hdev, struct input_dev *input)
+{
+	struct hid_haptic_device *haptic = hid_plugin_to_haptic(hdev);
+
+	if (IS_ERR_OR_NULL(haptic))
+		return false;
+
 	return haptic->input_dev == input;
 }
 
-void hid_haptic_feature_mapping(struct hid_device *hdev,
-				struct hid_haptic_device *haptic,
-				struct hid_field *field, struct hid_usage
-				*usage);
-bool hid_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
-				    struct hid_input *hi, struct hid_field *field);
-int hid_haptic_input_mapping(struct hid_device *hdev,
-			     struct hid_haptic_device *haptic,
-			     struct hid_input *hi,
-			     struct hid_field *field, struct hid_usage *usage,
-			     unsigned long **bit, int *max);
-int hid_haptic_input_configured(struct hid_device *hdev,
-				struct hid_haptic_device *haptic,
-				struct hid_input *hi);
-int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *haptic,
-		    struct input_dev *dev);
-void hid_haptic_handle_press_release(struct hid_haptic_device *haptic);
-void hid_haptic_pressure_reset(struct hid_haptic_device *haptic);
-void hid_haptic_pressure_increase(struct hid_haptic_device *haptic,
-				  __s32 pressure);
-#else
-static inline bool hid_haptic_connected_to_input(struct hid_haptic_device *haptic,
-						 struct input_dev *input)
+static inline struct hid_haptic_device *hid_haptic_connect(struct hid_device *hdev)
 {
-	return false;
+	return hid_plugin_connect(hdev, HID_PLUGIN_HAPTIC);
 }
 
-static inline
-void hid_haptic_feature_mapping(struct hid_device *hdev,
-				struct hid_haptic_device *haptic,
-				struct hid_field *field, struct hid_usage
-				*usage)
-{}
-static inline
-bool hid_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
-				    struct hid_input *hi, struct hid_field *field)
+static inline void hid_haptic_disconnect(struct hid_device *hdev)
 {
-	return false;
+	hid_plugin_disconnect(hdev, HID_PLUGIN_HAPTIC);
 }
-static inline
-int hid_haptic_input_mapping(struct hid_device *hdev,
-			     struct hid_haptic_device *haptic,
-			     struct hid_input *hi,
-			     struct hid_field *field, struct hid_usage *usage,
-			     unsigned long **bit, int *max)
+
+static inline void hid_haptic_feature_mapping(struct hid_device *hdev, struct hid_field *field,
+					      struct hid_usage *usage)
 {
-	return 0;
+	struct hid_haptic_device *haptic;
+
+	if ((field->logical & HID_USAGE_PAGE) != HID_UP_HAPTIC &&
+	    (usage->hid & HID_USAGE_PAGE) != HID_UP_HAPTIC)
+		return;
+
+	haptic = hid_plugin_to_haptic(hdev);
+	if (unlikely(!haptic))
+		haptic = hid_haptic_connect(hdev);
+	if (IS_ERR(haptic))
+		return;
+
+	haptic->plugin->feature_mapping(hdev, haptic, field, usage);
 }
-static inline
-int hid_haptic_input_configured(struct hid_device *hdev,
-				struct hid_haptic_device *haptic,
-				struct hid_input *hi)
+
+static inline bool hid_haptic_check_pressure_unit(struct hid_device *hdev, struct hid_input *hi,
+						  struct hid_field *field)
 {
-	return -EOPNOTSUPP;
+	struct hid_haptic_device *haptic = hid_plugin_to_haptic(hdev);
+
+	if (IS_ERR_OR_NULL(haptic))
+		return false;
+
+	return haptic->plugin->check_pressure_unit(haptic, hi, field);
 }
-static inline
-void hid_haptic_reset(struct hid_device *hdev, struct hid_haptic_device *haptic)
-{}
-static inline
-int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *haptic,
-		    struct input_dev *dev)
+
+static inline int hid_haptic_input_mapping(struct hid_device *hdev, struct hid_input *hi,
+					   struct hid_field *field, struct hid_usage *usage,
+					   unsigned long **bit, int *max)
 {
+	struct hid_haptic_device *haptic = hid_plugin_to_haptic(hdev);
+
+	if (IS_ERR_OR_NULL(haptic))
+		return 0;
+
+	if (usage->hid == HID_HP_MANUALTRIGGER) {
+		haptic->manual_trigger_report = field->report;
+		/* we don't really want to map these fields */
+		return -1;
+	}
+
 	return 0;
 }
-static inline
-void hid_haptic_handle_press_release(struct hid_haptic_device *haptic) {}
-static inline
-bool hid_haptic_handle_input(struct hid_haptic_device *haptic)
+
+static inline int hid_haptic_input_configured(struct hid_device *hdev, struct hid_input *hi)
 {
-	return false;
+	struct hid_haptic_device *haptic = hid_plugin_to_haptic(hdev);
+	int ret;
+
+	if (IS_ERR_OR_NULL(haptic))
+		return -EOPNOTSUPP;
+
+	ret = haptic->plugin->input_configured(hdev, haptic, hi);
+	if (ret < 0)
+		hid_haptic_disconnect(hdev);
+
+	return ret;
+}
+
+static inline void hid_haptic_pressure_reset(struct hid_device *hdev)
+{
+	struct hid_haptic_device *haptic = hid_plugin_to_haptic(hdev);
+
+	if (IS_ERR_OR_NULL(haptic))
+		return;
+
+	haptic->pressure_sum = 0;
+}
+
+static inline void hid_haptic_pressure_increase(struct hid_device *hdev, __s32 pressure)
+{
+	struct hid_haptic_device *haptic = hid_plugin_to_haptic(hdev);
+
+	if (IS_ERR_OR_NULL(haptic))
+		return;
+
+	haptic->pressure_sum += pressure;
 }
-static inline
-void hid_haptic_pressure_reset(struct hid_haptic_device *haptic) {}
-static inline
-void hid_haptic_pressure_increase(struct hid_haptic_device *haptic,
-				  __s32 pressure)
-{}
-#endif
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 80cdd2f2beff..847621d53a61 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -21,6 +21,7 @@
 #include <linux/hid-debug.h>
 
 #include "hid-core.h"
+#include "hid-haptic.h"
 #include "hid-ids.h"
 
 #define unk	KEY_UNKNOWN
@@ -1354,6 +1355,17 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
 		}
 		break;
 
+	case HID_UP_HAPTIC: {
+		int ret = hid_haptic_input_mapping(device, hidinput, field, usage, &bit, &max);
+
+		if (ret > 0)
+			goto mapped;
+		if (ret < 0)
+			goto ignore;
+
+		break;
+	}
+
 	case HID_UP_HPVENDOR:	/* Reported on a Dutch layout HP5308 */
 		set_bit(EV_REP, input->evbit);
 		switch (usage->hid & HID_USAGE) {
@@ -2054,6 +2066,8 @@ static void report_features(struct hid_device *hid)
 					hidinput_setup_battery(hid, HID_FEATURE_REPORT,
 							       rep->field[i], false);
 
+				hid_haptic_feature_mapping(hid, rep->field[i], usage);
+
 				if (drv->feature_mapping)
 					drv->feature_mapping(hid, rep->field[i], usage);
 			}
@@ -2346,6 +2360,7 @@ int hidinput_connect(struct hid_device *hid, unsigned int connect_mask)
 	struct hid_driver *drv = hid->driver;
 	struct hid_report *report;
 	struct hid_input *next, *hidinput = NULL;
+	bool haptic_ff, driver_ff = false;
 	unsigned int application;
 	int i, k;
 
@@ -2409,21 +2424,38 @@ int hidinput_connect(struct hid_device *hid, unsigned int connect_mask)
 
 	hidinput_change_resolution_multipliers(hid);
 
+	haptic_ff = hid_haptic_input_configured(hid, NULL) >= 0;
+
 	list_for_each_entry_safe(hidinput, next, &hid->inputs, list) {
+		bool first = list_is_first(&hidinput->list, &hid->inputs);
+
 		if (drv->input_configured &&
 		    drv->input_configured(hid, hidinput))
 			goto out_unwind;
 
+		if (first) {
+			driver_ff = hid_has_ff_input(hid) || !(connect_mask & HID_CONNECT_FF);
+			if (haptic_ff && driver_ff) {
+				hid_info(hid, "prefer driver's FF over haptic\n");
+				haptic_ff = false;
+			}
+		}
+
 		if (!hidinput_has_been_populated(hidinput)) {
 			/* no need to register an input device not populated */
 			hidinput_cleanup_hidinput(hid, hidinput);
 			continue;
 		}
 
-		if (list_is_first(&hidinput->list, &hid->inputs) &&
-		    (connect_mask & HID_CONNECT_FF) && hid->ff_init &&
-		    !hid_has_ff_input(hid))
-			hid->ff_init(hid);
+		if (first && !driver_ff && hid->ff_init)
+			driver_ff = !hid->ff_init(hid);
+
+		if (haptic_ff && driver_ff) {
+			hid_info(hid, "prefer PIDFF over haptic\n");
+			haptic_ff = false;
+		} else if (haptic_ff) {
+			haptic_ff = hid_haptic_input_configured(hid, hidinput) >= 0;
+		}
 
 		if (input_register_device(hidinput->input))
 			goto out_unwind;
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index eaa0b36a9dce..b8299a1a2bb9 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -173,7 +173,6 @@ struct mt_report_data {
 struct mt_device {
 	struct mt_class mtclass;	/* our mt device class */
 	struct timer_list release_timer;	/* to release sticky fingers */
-	struct hid_haptic_device *haptic;	/* haptic related configuration */
 	struct hid_device *hdev;	/* hid_device we're attached to */
 	unsigned long mt_io_flags;	/* mt flags (MT_IO_FLAGS_RUNNING) */
 	unsigned long *active_slots;	/* bitmap of slots with an active
@@ -604,8 +603,6 @@ static void mt_feature_mapping(struct hid_device *hdev,
 			mt_get_feature(hdev, field->report);
 		break;
 	}
-
-	hid_haptic_feature_mapping(hdev, td->haptic, field, usage);
 }
 
 static void set_abs(struct input_dev *input, unsigned int code,
@@ -961,9 +958,7 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 		case HID_DG_TIPPRESSURE:
 			set_abs(hi->input, ABS_MT_PRESSURE, field,
 				cls->sn_pressure);
-			td->is_haptic_touchpad =
-				hid_haptic_check_pressure_unit(td->haptic,
-							       hi, field);
+			td->is_haptic_touchpad = hid_haptic_check_pressure_unit(hdev, hi, field);
 			MT_STORE_FIELD(p);
 			return 1;
 		case HID_DG_SCANTIME:
@@ -1074,6 +1069,8 @@ static void mt_release_pending_palms(struct mt_device *td,
 static void mt_sync_frame(struct mt_device *td, struct mt_application *app,
 			  struct input_dev *input)
 {
+	struct hid_device *hdev = td->hdev;
+
 	if (app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS)
 		input_event(input, EV_KEY, BTN_LEFT, app->left_button_state);
 
@@ -1085,8 +1082,8 @@ static void mt_sync_frame(struct mt_device *td, struct mt_application *app,
 
 	app->num_received = 0;
 	app->left_button_state = 0;
-	if (td->is_haptic_touchpad && hid_haptic_connected_to_input(td->haptic, input))
-		hid_haptic_pressure_reset(td->haptic);
+	if (td->is_haptic_touchpad && hid_haptic_connected_to_input(hdev, input))
+		hid_haptic_pressure_reset(hdev);
 }
 
 static int mt_compute_timestamp(struct mt_application *app, __s32 value)
@@ -1238,8 +1235,8 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input,
 			minor = minor >> 1;
 		}
 
-		if (td->is_haptic_touchpad && hid_haptic_connected_to_input(td->haptic, input))
-			hid_haptic_pressure_increase(td->haptic, *slot->p);
+		if (td->is_haptic_touchpad && hid_haptic_connected_to_input(hdev, input))
+			hid_haptic_pressure_increase(hdev, *slot->p);
 
 		x = hdev->quirks & HID_QUIRK_X_INVERT ?
 			input_abs_get_max(input, ABS_MT_POSITION_X) - *slot->x :
@@ -1441,7 +1438,7 @@ static int mt_touch_input_configured(struct hid_device *hdev,
 	if (cls->is_indirect)
 		app->mt_flags |= INPUT_MT_POINTER;
 
-	if (td->is_haptic_touchpad && hid_haptic_connected_to_input(td->haptic, input))
+	if (td->is_haptic_touchpad && hid_haptic_connected_to_input(hdev, input))
 		app->mt_flags |= INPUT_MT_TOTAL_FORCE;
 
 	if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP)
@@ -1490,7 +1487,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 	struct mt_device *td = hid_get_drvdata(hdev);
 	struct mt_application *application;
 	struct mt_report_data *rdata;
-	int ret;
 
 	rdata = mt_find_report_data(td, field->report);
 	if (!rdata) {
@@ -1553,11 +1549,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 	if (field->physical == HID_DG_STYLUS)
 		hi->application = HID_DG_STYLUS;
 
-	ret = hid_haptic_input_mapping(hdev, td->haptic, hi, field, usage, bit,
-				       max);
-	if (ret != 0)
-		return ret;
-
 	/* let hid-core decide for the others */
 	return 0;
 }
@@ -1954,9 +1945,6 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
 	struct hid_report *report;
 	int ret;
 
-	if (td->is_haptic_touchpad && hid_haptic_connected_to_input(td->haptic, hi->input))
-		td->is_haptic_touchpad = !hid_haptic_input_configured(hdev, td->haptic, hi);
-
 	list_for_each_entry(report, &hi->reports, hidinput_list) {
 		rdata = mt_find_report_data(td, report);
 		if (!rdata) {
@@ -2125,11 +2113,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		dev_err(&hdev->dev, "cannot allocate multitouch data\n");
 		return -ENOMEM;
 	}
-	td->haptic = devm_kzalloc_obj(&hdev->dev, *(td->haptic));
-	if (!td->haptic)
-		return -ENOMEM;
 
-	td->haptic->hdev = hdev;
 	td->hdev = hdev;
 	td->mtclass = *mtclass;
 	td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN;
@@ -2198,9 +2182,6 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
 	mt_set_modes(hdev, HID_LATENCY_NORMAL, TOUCHPAD_REPORT_ALL);
 
-	if (!td->is_haptic_touchpad)
-		devm_kfree(&hdev->dev, td->haptic);
-
 	return 0;
 }
 
diff --git a/drivers/hid/hid-plugin.c b/drivers/hid/hid-plugin.c
index 63e4afca4f3a..b2a382a03083 100644
--- a/drivers/hid/hid-plugin.c
+++ b/drivers/hid/hid-plugin.c
@@ -26,6 +26,9 @@
 #include "hid-plugin.h"
 
 static const char * const hid_plugin_mod_names[NR_HID_PLUGINS] = {
+#if IS_MODULE(CONFIG_HID_HAPTIC)
+	[HID_PLUGIN_HAPTIC] = "hid-haptic",
+#endif
 };
 
 static const struct hid_plugin __rcu *hid_plugins[NR_HID_PLUGINS];
diff --git a/include/linux/hid.h b/include/linux/hid.h
index f881f5631cfe..4ea9cb4b49f9 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -676,6 +676,12 @@ struct hid_ll_driver;
 enum hid_plugin_id {
 	HID_PLUGIN_DISABLED	= -1,
 
+#if IS_ENABLED(CONFIG_HID_HAPTIC)
+	HID_PLUGIN_HAPTIC,
+#else
+#define HID_PLUGIN_HAPTIC	HID_PLUGIN_DISABLED
+#endif
+
 	NR_HID_PLUGINS,
 };
 
@@ -765,7 +771,7 @@ struct hid_device {
 	struct hid_bpf bpf;						/* hid-bpf data */
 #endif /* CONFIG_HID_BPF */
 
-	struct hid_plugin_private *plugins[NR_HID_PLUGINS];
+	void *plugins[NR_HID_PLUGINS];
 };
 
 void hiddev_free(struct kref *ref);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 07/13] HID: haptic: Adopt pr_fmt, dev_fmt and hid_*() printk helpers
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
                   ` (5 preceding siblings ...)
  2026-12-02 18:33 ` [PATCH v6 06/13] HID: haptic: Convert to a loadable plugin module Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 08/13] HID: Add Ordinal page defines Rong Zhang
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang

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@rong.moe>
---
 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 ab2366a58de4..bd2f72e94b12 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -5,6 +5,9 @@
  *  Copyright (c) 2021 Angela Czubak <acz@semihalf.com>
  */
 
+#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


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 08/13] HID: Add Ordinal page defines
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
                   ` (6 preceding siblings ...)
  2026-12-02 18:33 ` [PATCH v6 07/13] HID: haptic: Adopt pr_fmt, dev_fmt and hid_*() printk helpers Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 09/13] HID: haptic: Handle list reports separately and make auto trigger optional Rong Zhang
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang

Currently, the only macro for the HID Ordinal Page is HID_UP_ORDINAL,
which only matches the usage page itself.

This leads to inconvenience when drivers need to match both Ordinal and
non-Ordinal HID usages at once. They must use either nested switch
statements (usage pages, and then usages) or mixed if-else and switch
statements, which are hard to read and maintain.

Meanwhile, only usage 0x1-0xffff within the page is defined, and usage 0
is reserved and should be rejected, so simply matching the Ordinal page
and extracting the usage ID is essentially not the correct way to match
valid Ordinal usages.

Introduce HID_OD_MINIMUM and HID_OD_MAXIMUM to properly describe the
valid range of Ordinal usages, as well as providing HID_OD_RANGE for
switch statements to match Ordinal usages with ease.

Link: https://usb.org/sites/default/files/hut1_7.pdf
Signed-off-by: Rong Zhang <i@rong.moe>
---
 include/linux/hid.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/hid.h b/include/linux/hid.h
index 4ea9cb4b49f9..e877a6cdca48 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -231,6 +231,11 @@ struct hid_item {
 
 #define HID_DC_BATTERYSTRENGTH	0x00060020
 
+#define HID_OD_MINIMUM		0x000a0001
+#define HID_OD_MAXIMUM		0x000affff
+/* Use in switch statements. */
+#define HID_OD_RANGE		HID_OD_MINIMUM ... HID_OD_MAXIMUM
+
 #define HID_CP_CONSUMER_CONTROL	0x000c0001
 #define HID_CP_AC_PAN		0x000c0238
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 09/13] HID: haptic: Handle list reports separately and make auto trigger optional
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
                   ` (7 preceding siblings ...)
  2026-12-02 18:33 ` [PATCH v6 08/13] HID: Add Ordinal page defines Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 10/13] HID: haptic: Decouple from hid-multitouch and support other devices Rong Zhang
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang

The Waveform List and Duration List collections are read-only and
inherently different from the Auto Trigger freture, which is read-write.
The latter may use a dedicated report or even missing [1] on some device
due to the difference.

Handle list reports separately to decouple them from the auto trigger
report, so that the latter becomes optional.

According to [1][2], Waveform Vendor Page and ID shall be declared
within the Waveform List. The requirement is now enforced to
intentionally ignore malformed Vendor Page and ID and further simplify
the code to make it more readable.

Also adopt the newly introduced HID_OD_RANGE macro to get rid of mixed
if-else and switch statements.

Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/input-haptics-implementation-guide [1]
Link: https://usb.org/sites/default/files/hutrr63b_-_haptics_page_redline_0.pdf [2]
Signed-off-by: Rong Zhang <i@rong.moe>
---
 drivers/hid/hid-haptic.c | 134 ++++++++++++++++++++++++++++++++---------------
 drivers/hid/hid-haptic.h |   2 +
 2 files changed, 93 insertions(+), 43 deletions(-)

diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index bd2f72e94b12..40bb641fc1f5 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -8,9 +8,11 @@
 #define pr_fmt(fmt) "hid-haptic: " fmt
 #define dev_fmt pr_fmt
 
+#include <linux/bitmap.h>
 #include <linux/err.h>
 #include <linux/input/mt.h>
 #include <linux/module.h>
+#include <linux/types.h>
 
 #include "hid-haptic.h"
 
@@ -19,26 +21,33 @@ static void __hid_haptic_feature_mapping(struct hid_device *hdev, struct hid_hap
 {
 	u16 usage_hid;
 
-	if (usage->hid == HID_HP_AUTOTRIGGER) {
+	switch (usage->hid) {
+	case HID_HP_AUTOTRIGGER:
 		if (usage->usage_index >= field->report_count) {
 			hid_err(hdev, "HID_HP_AUTOTRIGGER out of range\n");
 			return;
 		}
 		haptic->auto_trigger_report = field->report;
-	} else if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ORDINAL) {
+		break;
+	case HID_OD_RANGE:
 		usage_hid = usage->hid & HID_USAGE;
 		switch (field->logical) {
 		case HID_HP_WAVEFORMLIST:
+			haptic->waveform_list_report = field->report;
 			if (usage_hid > haptic->max_waveform_id)
 				haptic->max_waveform_id = usage_hid;
 			break;
 		case HID_HP_DURATIONLIST:
+			haptic->duration_list_report = field->report;
 			if (usage_hid > haptic->max_duration_id)
 				haptic->max_duration_id = usage_hid;
 			break;
 		default:
 			break;
 		}
+		break;
+	default:
+		break;
 	}
 }
 
@@ -80,53 +89,69 @@ static bool __hid_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
 	return false;
 }
 
-static void parse_auto_trigger_field(struct hid_haptic_device *haptic,
-				     struct hid_field *field)
+static void parse_waveform_list(struct hid_haptic_device *haptic, struct hid_field *field)
 {
 	int count = field->report_count;
 	int n;
 	u16 usage_hid;
 
+	if (field->logical != HID_HP_WAVEFORMLIST)
+		return;
+
 	for (n = 0; n < count; n++) {
-		switch (field->usage[n].hid & HID_USAGE_PAGE) {
-		case HID_UP_ORDINAL:
+		switch (field->usage[n].hid) {
+		case HID_OD_RANGE:
 			usage_hid = field->usage[n].hid & HID_USAGE;
-			switch (field->logical) {
-			case HID_HP_WAVEFORMLIST:
-				haptic->hid_usage_map[usage_hid] = field->value[n];
-				if (field->value[n] ==
-				    (HID_HP_WAVEFORMPRESS & HID_USAGE)) {
-					haptic->press_ordinal = usage_hid;
-				} else if (field->value[n] ==
-					   (HID_HP_WAVEFORMRELEASE & HID_USAGE)) {
-					haptic->release_ordinal = usage_hid;
-				}
-				break;
-			case HID_HP_DURATIONLIST:
-				haptic->duration_map[usage_hid] =
-					field->value[n];
-				break;
-			default:
-				break;
-			}
+			haptic->hid_usage_map[usage_hid] = field->value[n];
+			if (field->value[n] == (HID_HP_WAVEFORMPRESS & HID_USAGE))
+				haptic->press_ordinal = usage_hid;
+			else if (field->value[n] == (HID_HP_WAVEFORMRELEASE & HID_USAGE))
+				haptic->release_ordinal = usage_hid;
 			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;
-			case HID_HP_WAVEFORMVENDORPAGE:
-				haptic->vendor_page = field->value[n];
-				break;
-			default:
-				break;
-			}
+		case HID_HP_WAVEFORMVENDORID:
+			haptic->vendor_id = field->value[n];
+			break;
+		case HID_HP_WAVEFORMVENDORPAGE:
+			haptic->vendor_page = field->value[n];
+			break;
+		default:
+			break;
+		}
+	}
+}
+
+static void parse_duration_list(struct hid_haptic_device *haptic, struct hid_field *field)
+{
+	int count = field->report_count;
+	int n;
+	u16 usage_hid;
+
+	if (field->logical != HID_HP_DURATIONLIST)
+		return;
+
+	for (n = 0; n < count; n++) {
+		switch (field->usage[n].hid) {
+		case HID_OD_RANGE:
+			usage_hid = field->usage[n].hid & HID_USAGE;
+			haptic->duration_map[usage_hid] = field->value[n];
+			break;
+		default:
+			break;
+		}
+	}
+}
+
+static void parse_auto_trigger_field(struct hid_haptic_device *haptic, struct hid_field *field)
+{
+	int count = field->report_count;
+	int n;
+
+	for (n = 0; n < count; n++) {
+		switch (field->usage[n].hid) {
+		case HID_HP_AUTOTRIGGER:
+			haptic->default_auto_trigger = field->value[n];
 			break;
 		default:
-			/* Should not really happen */
 			break;
 		}
 	}
@@ -194,6 +219,9 @@ static void switch_mode(struct hid_device *hdev, struct hid_haptic_device *hapti
 	s32 value;
 	int i, j;
 
+	if (!rep)
+		return;
+
 	if (mode == HID_HAPTIC_MODE_HOST)
 		value = HID_HAPTIC_ORDINAL_WAVEFORMSTOP;
 	else
@@ -387,11 +415,26 @@ static void hid_haptic_destroy(struct ff_device *ff)
 
 static void hid_haptic_get_reports(struct hid_device *hdev, struct hid_haptic_device *haptic)
 {
+	DECLARE_BITMAP(usage_map, HID_MAX_IDS) = {};
+	int i;
+
+	__set_bit(haptic->waveform_list_report->id, usage_map);
+	__set_bit(haptic->duration_list_report->id, usage_map);
+	if (haptic->auto_trigger_report)
+		__set_bit(haptic->auto_trigger_report->id, usage_map);
+
 	hid_device_io_start(hdev);
 
-	hid_hw_request(hdev, haptic->auto_trigger_report, HID_REQ_GET_REPORT);
+	/*
+	 * The three collections/usages may share the same report, or use
+	 * dedicated ones. Skip duplicate GET_REPORT requests.
+	 */
+	for_each_set_bit(i, usage_map, HID_MAX_IDS) {
+		hid_hw_request(hdev, hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[i],
+			       HID_REQ_GET_REPORT);
+		hid_hw_wait(hdev);
+	}
 
-	hid_hw_wait(hdev);
 	hid_device_io_stop(hdev);
 }
 
@@ -433,7 +476,11 @@ static int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *ha
 
 	hid_haptic_get_reports(hdev, haptic);
 
-	for (r = 0; r < haptic->auto_trigger_report->maxfield; r++)
+	for (r = 0; r < haptic->waveform_list_report->maxfield; r++)
+		parse_waveform_list(haptic, haptic->waveform_list_report->field[r]);
+	for (r = 0; r < haptic->duration_list_report->maxfield; r++)
+		parse_duration_list(haptic, haptic->duration_list_report->field[r]);
+	for (r = 0; haptic->auto_trigger_report && r < haptic->auto_trigger_report->maxfield; r++)
 		parse_auto_trigger_field(haptic, haptic->auto_trigger_report->field[r]);
 
 	haptic->input_dev = dev;
@@ -519,7 +566,8 @@ static int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *ha
 static int hid_haptic_check_prerequisites(struct hid_device *hdev,
 					  struct hid_haptic_device *haptic, struct hid_input *hi)
 {
-	if (!haptic->auto_trigger_report || !haptic->manual_trigger_report)
+	if (!haptic->waveform_list_report || !haptic->duration_list_report ||
+	    !haptic->manual_trigger_report)
 		return -ENOENT;
 
 	if (IS_ERR_OR_NULL(haptic->input_dev))
diff --git a/drivers/hid/hid-haptic.h b/drivers/hid/hid-haptic.h
index 18cf4505f719..009133ac50ba 100644
--- a/drivers/hid/hid-haptic.h
+++ b/drivers/hid/hid-haptic.h
@@ -34,6 +34,8 @@ struct hid_haptic_effect_node {
 struct hid_haptic_device {
 	struct input_dev *input_dev;
 	struct hid_device *hdev;
+	struct hid_report *waveform_list_report;
+	struct hid_report *duration_list_report;
 	struct hid_report *auto_trigger_report;
 	struct mutex auto_trigger_mutex;
 	struct workqueue_struct *wq;

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 10/13] HID: haptic: Decouple from hid-multitouch and support other devices
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
                   ` (8 preceding siblings ...)
  2026-12-02 18:33 ` [PATCH v6 09/13] HID: haptic: Handle list reports separately and make auto trigger optional Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  2026-12-02 19:08   ` sashiko-bot
  2026-12-02 18:33 ` [PATCH v6 11/13] HID: haptic: Add quirk table Rong Zhang
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang

Currently, hid-haptic only works on multitouch devices that have passed
the pressure unit check.

According to [1], a Simple Haptic Controller may be either a Collection
Application (CA) or a Collection Logical (CL):

A CA is a dedicated HID application, i.e., not associated with other HID
applications. Choose the first HID input device to attach the FF device,
as other FF drivers do. Haptic Mouse usually falls into this category as
long as it follows the example in [2].

A CL is contained within another HID application. The HID input device
handling the manual trigger report must be the one handling the
associated HID application. Haptic Touchpad and Stylus usually fall into
this category as long as they follow the examples in [2][3].

When HID_QUIRK_MULTI_INPUT is set, the quirky collection hierarchy makes
no sense anyway, so the first input device is chosen instead.

Fall back to the above strategy when hid-multitouch didn't choose an
input device due to pressure unit check failure or non-multitouch
device. In this case, hid-haptic works without the integration with
hid-multitouch.

With these, hid-plugin now becomes a generic plugin, so also add an info
message for device identification after haptic is connected.

Link: https://usb.org/sites/default/files/hutrr63b_-_haptics_page_redline_0.pdf [1]
Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/input-haptics-implementation-guide [2]
Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/haptic-pen-implementation-guide [3]
Signed-off-by: Rong Zhang <i@rong.moe>
---
Changes in v6:
- Print dev_name(&hi->input->dev) instead of hi->input->name. The former
  is its kobject name and is unique, while the latter is not unique
- Update the Kconfig help string to reflect the fact that hid-haptic
  becomes generic
---
 drivers/hid/Kconfig      | 11 +++++-----
 drivers/hid/hid-haptic.c | 54 ++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 54 insertions(+), 11 deletions(-)

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 04ab152b3d54..a804bee08cce 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -112,13 +112,14 @@ config HID_PLUGIN_CORE
 	bool
 
 config HID_HAPTIC
-	tristate "Haptic touchpad support"
+	tristate "Haptic usage page support"
 	select HID_PLUGIN_CORE
 	help
-	Support for touchpads with force sensors and haptic actuators instead of a
-	traditional button.
-	Adds extra parsing and FF device for the hid multitouch driver.
-	It can be used for Elan 2703 haptic touchpad.
+	Support for devices that implement the HID Haptic usage page, for
+	example, touchpads with force sensors and haptic actuators instead of a
+	traditional button, as well as mouses and styli with haptic feedback.
+
+	The plugin adds extra parsing and FF device for the these devices.
 
 	If unsure, say N.
 
diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index 40bb641fc1f5..aae4ff1f0cca 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -9,6 +9,7 @@
 #define dev_fmt pr_fmt
 
 #include <linux/bitmap.h>
+#include <linux/device.h>
 #include <linux/err.h>
 #include <linux/input/mt.h>
 #include <linux/module.h>
@@ -566,19 +567,55 @@ static int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *ha
 static int hid_haptic_check_prerequisites(struct hid_device *hdev,
 					  struct hid_haptic_device *haptic, struct hid_input *hi)
 {
+	struct hid_report *report;
+
 	if (!haptic->waveform_list_report || !haptic->duration_list_report ||
 	    !haptic->manual_trigger_report)
 		return -ENOENT;
 
-	if (IS_ERR_OR_NULL(haptic->input_dev))
-		return PTR_ERR(haptic->input_dev) ?: -EXDEV;
-
 	/* Check the prerequisites only. */
 	if (!hi)
 		return 1;
 
-	if (haptic->input_dev == hi->input)
-		return 0;
+	/*
+	 * Honor the HID driver's choice.
+	 *
+	 * If the driver didn't choose an input device or failed its
+	 * prerequisites check, initialize the haptic device without the
+	 * integration with the driver.
+	 */
+	if (IS_ERR_OR_NULL(haptic->input_dev))
+		haptic->input_dev = NULL;
+	else
+		return haptic->input_dev != hi->input;
+
+	/*
+	 * A Simple Haptic Controller may be either a Collection Application
+	 * (CA) or a Collection Logical (CL):
+	 *
+	 * A CA is a dedicated HID application, i.e., not associated with other
+	 * HID applications. Choose the first HID input device to attach the FF
+	 * device, as other FF drivers do. Haptic Mouse usually falls into this
+	 * category.
+	 *
+	 * A CL is contained within another HID application. The HID input
+	 * device handling the manual trigger report must be the one handling
+	 * the associated HID application. Haptic Touchpad and Stylus usually
+	 * fall into this category.
+	 *
+	 * When HID_QUIRK_MULTI_INPUT is set, the quirky collection hierarchy
+	 * makes no sense anyway, so the first input device is chosen instead.
+	 */
+	if (haptic->manual_trigger_report->application == HID_HP_SIMPLECONTROLLER ||
+	    hdev->quirks & HID_QUIRK_MULTI_INPUT) {
+		if (list_is_first(&hi->list, &hdev->inputs))
+			return 0;
+	} else {
+		list_for_each_entry(report, &hi->reports, hidinput_list) {
+			if (report == haptic->manual_trigger_report)
+				return 0;
+		}
+	}
 
 	return 1; /* Waiting for the relevant input device. */
 }
@@ -586,17 +623,22 @@ static int hid_haptic_check_prerequisites(struct hid_device *hdev,
 static int __hid_haptic_input_configured(struct hid_device *hdev,
 					 struct hid_haptic_device *haptic, struct hid_input *hi)
 {
+	bool driver_integration;
 	int ret;
 
 	ret = hid_haptic_check_prerequisites(hdev, haptic, hi);
 	if (ret)
 		return ret;
 
+	driver_integration = haptic->input_dev == hi->input;
+
 	ret = hid_haptic_init(hdev, haptic, hi->input);
 	if (ret)
 		return ret;
 
-	if (hi->application == HID_DG_TOUCHPAD)
+	hid_info(hdev, "Haptic FF connected to %s\n", dev_name(&hi->input->dev));
+
+	if (driver_integration && hi->application == HID_DG_TOUCHPAD)
 		__set_bit(INPUT_PROP_PRESSUREPAD, hi->input->propbit);
 
 	return 0;

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 11/13] HID: haptic: Add quirk table
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
                   ` (9 preceding siblings ...)
  2026-12-02 18:33 ` [PATCH v6 10/13] HID: haptic: Decouple from hid-multitouch and support other devices Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 12/13] HID: haptic: Add HID_HAPTIC_QUIRK_NO_RETRIGGER to disable retriggering Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 13/13] HID: haptic: Add quirk flag for Logitech MX Master 4 Rong Zhang
  12 siblings, 0 replies; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang

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@rong.moe>
---
 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@semihalf.com>
  */
 
+#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


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 12/13] HID: haptic: Add HID_HAPTIC_QUIRK_NO_RETRIGGER to disable retriggering
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
                   ` (10 preceding siblings ...)
  2026-12-02 18:33 ` [PATCH v6 11/13] HID: haptic: Add quirk table Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  2026-12-02 18:33 ` [PATCH v6 13/13] HID: haptic: Add quirk flag for Logitech MX Master 4 Rong Zhang
  12 siblings, 0 replies; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang

Some devices do not support retriggering. If the relevant fields are
set, they do not trigger at all, as if no FF effect is played.

Add a new quirk flag HID_HAPTIC_QUIRK_NO_RETRIGGER to zero the relevant
fields before filling the effect buf, so that faulty devices is always
triggered normally.

Signed-off-by: Rong Zhang <i@rong.moe>
---
 drivers/hid/hid-haptic.c | 8 ++++++++
 drivers/hid/hid-haptic.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index f3118876d1b2..0b75dff9fcc7 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -28,6 +28,9 @@ static u32 hid_haptic_match_quirks(struct hid_device *hdev)
 
 	quirks = id ? id->driver_data : 0;
 
+	if (quirks & HID_HAPTIC_QUIRK_NO_RETRIGGER)
+		hid_notice(hdev, "Device does not support retriggering\n");
+
 	return quirks;
 }
 
@@ -287,6 +290,11 @@ static int hid_haptic_upload_effect(struct input_dev *dev, struct ff_effect *eff
 	if (ordinal < 1)
 		return -EINVAL;
 
+	if (haptic->quirks & HID_HAPTIC_QUIRK_NO_RETRIGGER) {
+		effect->u.haptic.repeat_count = 0;
+		effect->u.haptic.retrigger_period = 0;
+	}
+
 	/* Fill the buffer for the effect id */
 	fill_effect_buf(haptic, &effect->u.haptic, &haptic->effect[effect->id],
 			ordinal);
diff --git a/drivers/hid/hid-haptic.h b/drivers/hid/hid-haptic.h
index 3464766def08..044f91851357 100644
--- a/drivers/hid/hid-haptic.h
+++ b/drivers/hid/hid-haptic.h
@@ -19,6 +19,8 @@
 #define HID_HAPTIC_MODE_DEVICE 0
 #define HID_HAPTIC_MODE_HOST 1
 
+#define HID_HAPTIC_QUIRK_NO_RETRIGGER	BIT(0)
+
 struct hid_haptic_effect {
 	u8 *report_buf;
 	struct input_dev *input_dev;

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 13/13] HID: haptic: Add quirk flag for Logitech MX Master 4
  2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
                   ` (11 preceding siblings ...)
  2026-12-02 18:33 ` [PATCH v6 12/13] HID: haptic: Add HID_HAPTIC_QUIRK_NO_RETRIGGER to disable retriggering Rong Zhang
@ 2026-12-02 18:33 ` Rong Zhang
  12 siblings, 0 replies; 16+ messages in thread
From: Rong Zhang @ 2026-12-02 18:33 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Angela Czubak, Henrik Rydberg,
	Dmitry Torokhov
  Cc: Aaron Erhardt, linux-input, linux-kernel, Rong Zhang

The Logitech MX Master 4 is a mouse with haptic feedback. Its report
descriptor mimics the example in [1], and thus declares Repeat Count and
Retrigger Period usages.

However, its retriggering functionality is completely broken. When
filling Repeat Count with a non-zero value, it simply ignores the report
and plays nothing.

Add HID_HAPTIC_QUIRK_NO_RETRIGGER for Logitech MX Master 4 to prevent
the said field from breaking the FF device.

Note that the Logitech Bolt receiver is also matched, as no other
Logitech device supports HID haptic.

Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/input-haptics-implementation-guide [1]
Signed-off-by: Rong Zhang <i@rong.moe>
---
 drivers/hid/hid-haptic.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index 0b75dff9fcc7..5b276215f72b 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -16,8 +16,15 @@
 #include <linux/types.h>
 
 #include "hid-haptic.h"
+#include "hid-ids.h"
 
 static const struct hid_device_id hid_haptic_quirks[] = {
+	/* Logitech MX Master 4 over Logitech Bolt receiver */
+	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_BOLT_RECEIVER),
+		.driver_data = HID_HAPTIC_QUIRK_NO_RETRIGGER },
+	/* Logitech MX Master 4 over Bluetooth */
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb042),
+		.driver_data = HID_HAPTIC_QUIRK_NO_RETRIGGER },
 	{ }
 };
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 06/13] HID: haptic: Convert to a loadable plugin module
  2026-12-02 18:33 ` [PATCH v6 06/13] HID: haptic: Convert to a loadable plugin module Rong Zhang
@ 2026-12-02 19:07   ` sashiko-bot
  0 siblings, 0 replies; 16+ messages in thread
From: sashiko-bot @ 2026-12-02 19:07 UTC (permalink / raw)
  To: Rong Zhang; +Cc: linux-input, dmitry.torokhov

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: input: drv->input_configured() runs before haptic FF
  checks
--

commit 8be6fb5c6f2eedc7e241b2c32350b9e02e719950
Author: Rong Zhang <i@rong.moe>

HID: haptic: Convert to a loadable plugin module

This commit converts hid-haptic into a loadable hid-plugin module and
moves the haptic initialization hooks from hid-multitouch into hid-input.

Link: https://lore.kernel.org/linux-input/auypydfkhx2eg7vp764way4batdilzc35inqda3exwzs3tk3ff@oagat6g46zto/

> diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> index 80cdd2f2beffe..847621d53a61b 100644
> --- a/drivers/hid/hid-input.c
> +++ b/drivers/hid/hid-input.c
[ ... ]
> @@ -2409,21 +2424,38 @@ int hidinput_connect(struct hid_device *hid, unsigned int connect_mask)
>  
>  	hidinput_change_resolution_multipliers(hid);
>  
> +	haptic_ff = hid_haptic_input_configured(hid, NULL) >= 0;
> +
>  	list_for_each_entry_safe(hidinput, next, &hid->inputs, list) {
> +		bool first = list_is_first(&hidinput->list, &hid->inputs);
> +
>  		if (drv->input_configured &&
>  		    drv->input_configured(hid, hidinput))
>  			goto out_unwind;
>  
> +		if (first) {
> +			driver_ff = hid_has_ff_input(hid) || !(connect_mask & HID_CONNECT_FF);
> +			if (haptic_ff && driver_ff) {
> +				hid_info(hid, "prefer driver's FF over haptic\n");
> +				haptic_ff = false;
> +			}
> +		}
> +
>  		if (!hidinput_has_been_populated(hidinput)) {
>  			/* no need to register an input device not populated */
>  			hidinput_cleanup_hidinput(hid, hidinput);
>  			continue;
>  		}
>  
> -		if (list_is_first(&hidinput->list, &hid->inputs) &&
> -		    (connect_mask & HID_CONNECT_FF) && hid->ff_init &&
> -		    !hid_has_ff_input(hid))
> -			hid->ff_init(hid);
> +		if (first && !driver_ff && hid->ff_init)
> +			driver_ff = !hid->ff_init(hid);
> +
> +		if (haptic_ff && driver_ff) {
> +			hid_info(hid, "prefer PIDFF over haptic\n");
> +			haptic_ff = false;
> +		} else if (haptic_ff) {
> +			haptic_ff = hid_haptic_input_configured(hid, hidinput) >= 0;
> +		}
>  
>  		if (input_register_device(hidinput->input))
>  			goto out_unwind;

[Severity: Medium]
Can calling drv->input_configured() before hid_haptic_input_configured()
and the driver_ff checks leave the multitouch device configured with
INPUT_MT_TOTAL_FORCE and td->is_haptic_touchpad set when haptic FF is
skipped or fails to initialize?

Before this commit, mt_input_configured() ran
hid_haptic_input_configured() and updated td->is_haptic_touchpad before
calling mt_touch_input_configured().  Now, hid_haptic_input_configured()
with NULL only checks prerequisites, so haptic->input_dev is still equal
to hi->input when drv->input_configured() runs:

drivers/hid/hid-multitouch.c:mt_touch_input_configured() {
    ...
	if (td->is_haptic_touchpad && hid_haptic_connected_to_input(hdev, input))
		app->mt_flags |= INPUT_MT_TOTAL_FORCE;
    ...
	ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags);
    ...
}

If haptic FF is then skipped because driver_ff is true, or if
hid_haptic_init() fails inside hid_haptic_input_configured(hid, hidinput),
the input device is registered with INPUT_MT_TOTAL_FORCE enabled (changing
ABS_PRESSURE pointer emulation) without FF_HAPTIC or
INPUT_PROP_PRESSUREPAD, and td->is_haptic_touchpad stays true for the life
of the device.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-hid-haptic-kmod-v6-0-95a1273b9e40@rong.moe?part=6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 10/13] HID: haptic: Decouple from hid-multitouch and support other devices
  2026-12-02 18:33 ` [PATCH v6 10/13] HID: haptic: Decouple from hid-multitouch and support other devices Rong Zhang
@ 2026-12-02 19:08   ` sashiko-bot
  0 siblings, 0 replies; 16+ messages in thread
From: sashiko-bot @ 2026-12-02 19:08 UTC (permalink / raw)
  To: Rong Zhang; +Cc: linux-input, dmitry.torokhov

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: haptic: stylus matching fails in
  hid_haptic_check_prerequisites()
--

commit bd7794227e36fff25c1aaa191f88aebef47dc33b
Author: Rong Zhang <i@rong.moe>

HID: haptic: Decouple from hid-multitouch and support other devices

This commit adds fallback input device selection for hid-haptic so that
haptic devices with Collection Application or Collection Logical
hierarchies can initialize without requiring hid-multitouch integration.

Link: https://usb.org/sites/default/files/hutrr63b_-_haptics_page_redline_0.pdf [1]
Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/input-haptics-implementation-guide [2]
Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/haptic-pen-implementation-guide [3]

> diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
> index 40bb641fc1f5d..aae4ff1f0ccaa 100644
> --- a/drivers/hid/hid-haptic.c
> +++ b/drivers/hid/hid-haptic.c

[ ... ]

> @@ -566,19 +567,55 @@ static int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *ha
>  static int hid_haptic_check_prerequisites(struct hid_device *hdev,
>  					  struct hid_haptic_device *haptic, struct hid_input *hi)
>  {
> +	struct hid_report *report;
> +
>  	if (!haptic->waveform_list_report || !haptic->duration_list_report ||
>  	    !haptic->manual_trigger_report)
>  		return -ENOENT;
>  
> -	if (IS_ERR_OR_NULL(haptic->input_dev))
> -		return PTR_ERR(haptic->input_dev) ?: -EXDEV;
> -
>  	/* Check the prerequisites only. */
>  	if (!hi)
>  		return 1;
>  
> -	if (haptic->input_dev == hi->input)
> -		return 0;
> +	/*
> +	 * Honor the HID driver's choice.
> +	 *
> +	 * If the driver didn't choose an input device or failed its
> +	 * prerequisites check, initialize the haptic device without the
> +	 * integration with the driver.
> +	 */
> +	if (IS_ERR_OR_NULL(haptic->input_dev))
> +		haptic->input_dev = NULL;
> +	else
> +		return haptic->input_dev != hi->input;
> +
> +	/*
> +	 * A Simple Haptic Controller may be either a Collection Application
> +	 * (CA) or a Collection Logical (CL):
> +	 *
> +	 * A CA is a dedicated HID application, i.e., not associated with other
> +	 * HID applications. Choose the first HID input device to attach the FF
> +	 * device, as other FF drivers do. Haptic Mouse usually falls into this
> +	 * category.
> +	 *
> +	 * A CL is contained within another HID application. The HID input
> +	 * device handling the manual trigger report must be the one handling
> +	 * the associated HID application. Haptic Touchpad and Stylus usually
> +	 * fall into this category.
> +	 *
> +	 * When HID_QUIRK_MULTI_INPUT is set, the quirky collection hierarchy
> +	 * makes no sense anyway, so the first input device is chosen instead.
> +	 */
> +	if (haptic->manual_trigger_report->application == HID_HP_SIMPLECONTROLLER ||
> +	    hdev->quirks & HID_QUIRK_MULTI_INPUT) {
> +		if (list_is_first(&hi->list, &hdev->inputs))
> +			return 0;
> +	} else {
> +		list_for_each_entry(report, &hi->reports, hidinput_list) {
> +			if (report == haptic->manual_trigger_report)
> +				return 0;
> +		}
> +	}

[Severity: Medium]
Can this match haptic->manual_trigger_report for a haptic stylus on a
composite touchscreen and pen device bound to hid-multitouch?

In descriptors following the Microsoft Haptic Pen Implementation Guide,
the top-level application collection is HID_DG_PEN, containing a
HID_DG_STYLUS physical collection for the stylus input fields and a
HID_HP_SIMPLECONTROLLER logical collection for the manual trigger output
report.

When hidinput_connect() processes HID_INPUT_REPORT first,
hidinput_allocate() sets hi->application to HID_DG_PEN, and then
mt_input_mapping() overwrites it:

drivers/hid/hid-multitouch.c:mt_input_mapping() {
	...
	if (field->physical == HID_DG_STYLUS)
		hi->application = HID_DG_STYLUS;
	...
}

When HID_OUTPUT_REPORT is processed next, manual_trigger_report still has
report->application == HID_DG_PEN.  Because mt_probe() sets
HID_QUIRK_INPUT_PER_APP, hidinput_match_application() compares
hidinput->application (now HID_DG_STYLUS) against report->application
(HID_DG_PEN), fails to match the stylus hid_input, and places
manual_trigger_report on a newly allocated hid_input with no input usages.

As a result, manual_trigger_report is absent from the stylus hi->reports
list, hid_haptic_check_prerequisites() returns 1 for the stylus, and the
unpopulated hid_input holding manual_trigger_report is later freed by
hidinput_cleanup_hidinput(), leaving the stylus without haptic force
feedback.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-hid-haptic-kmod-v6-0-95a1273b9e40@rong.moe?part=10

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-12-02 19:08 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
2026-12-02 18:33 ` [PATCH v6 01/13] HID: haptic: Get rid of input_ff_destroy() in error paths Rong Zhang
2026-12-02 18:33 ` [PATCH v6 02/13] HID: haptic: Fix use-after-free when draining workqueue Rong Zhang
2026-12-02 18:33 ` [PATCH v6 03/13] HID: haptic, multitouch: Check haptic prerequisite properly Rong Zhang
2026-12-02 18:33 ` [PATCH v6 04/13] HID: haptic: Postpone GET_REPORT to init Rong Zhang
2026-12-02 18:33 ` [PATCH v6 05/13] HID: Add hid-plugin framework for loadable plugin modules Rong Zhang
2026-12-02 18:33 ` [PATCH v6 06/13] HID: haptic: Convert to a loadable plugin module Rong Zhang
2026-12-02 19:07   ` sashiko-bot
2026-12-02 18:33 ` [PATCH v6 07/13] HID: haptic: Adopt pr_fmt, dev_fmt and hid_*() printk helpers Rong Zhang
2026-12-02 18:33 ` [PATCH v6 08/13] HID: Add Ordinal page defines Rong Zhang
2026-12-02 18:33 ` [PATCH v6 09/13] HID: haptic: Handle list reports separately and make auto trigger optional Rong Zhang
2026-12-02 18:33 ` [PATCH v6 10/13] HID: haptic: Decouple from hid-multitouch and support other devices Rong Zhang
2026-12-02 19:08   ` sashiko-bot
2026-12-02 18:33 ` [PATCH v6 11/13] HID: haptic: Add quirk table Rong Zhang
2026-12-02 18:33 ` [PATCH v6 12/13] HID: haptic: Add HID_HAPTIC_QUIRK_NO_RETRIGGER to disable retriggering Rong Zhang
2026-12-02 18:33 ` [PATCH v6 13/13] HID: haptic: Add quirk flag for Logitech MX Master 4 Rong Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.