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 <dmitry.torokhov@gmail.com>
---
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 f107f5103b35..2767a171eae9 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2287,6 +2287,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",@@ -2336,7 +2348,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;
--
2.55.0.629.g250fe7f194-goog