From be978be17296d8b304c252933bcb13324173c2d2 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 3 Aug 2026 11:46:26 -0700 Subject: [PATCH] HID: core: automatically initialize generic FF if no other FF is present Some HID drivers initialize their own force-feedback support within their .input_configured() callback. In such cases, we should skip the generic PID force-feedback initialization to avoid conflicts and redundant setup. Add hid_has_ff_input() helper and use it to check for existing FF capabilities before calling hdev->ff_init(). Since we now have a dynamic way to detect if force-feedback is needed, the HID_CONNECT_FF flag is redundant for conflict resolution and can be ignored in the core initialization logic. Generic PID support will now be attempted by default for any claimed input device that doesn't already have FF capabilities. Assisted-by: Gemini:gemini-3.1-pro Signed-off-by: Dmitry Torokhov Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index cb9a67b5c535..f26a499a99bd 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2280,6 +2280,18 @@ static const BIN_ATTR_RO(report_descriptor, HID_MAX_DESCRIPTOR_SIZE); static const DEVICE_ATTR_RO(country); +static bool hid_has_ff_input(struct hid_device *hdev) +{ + struct hid_input *hidinput; + + list_for_each_entry(hidinput, &hdev->inputs, list) { + if (test_bit(EV_FF, hidinput->input->evbit)) + return true; + } + + return false; +} + int hid_connect(struct hid_device *hdev, unsigned int connect_mask) { static const char *types[] = { "Device", "Pointer", "Mouse", "Device", @@ -2329,7 +2341,8 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) hid_process_ordering(hdev); if ((hdev->claimed & HID_CLAIMED_INPUT) && - (connect_mask & HID_CONNECT_FF) && hdev->ff_init) + (connect_mask & HID_CONNECT_FF) && hdev->ff_init && + !hid_has_ff_input(hdev)) hdev->ff_init(hdev); len = 0;