mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
HID: holtek: move FF initialization to .input_configured()
The driver currently initializes force-feedback in its probe() function after calling hid_hw_start() with HID_CONNECT_DEFAULT. This is racy as the input device is already registered and visible to userspace at that point. Move the FF initialization to the .input_configured() callback to ensure the device is fully prepared before registration. Assisted-by: Gemini:gemini-3.1-pro Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
parent
ec11e18d01
commit
5afaa58f3a
|
|
@ -120,30 +120,24 @@ static int holtekff_play(struct input_dev *dev, void *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int holtekff_init(struct hid_device *hid)
|
||||
static int holtek_input_configured(struct hid_device *hid, struct hid_input *hidinput)
|
||||
{
|
||||
struct holtekff_device *holtekff;
|
||||
struct hid_report *report;
|
||||
struct hid_input *hidinput;
|
||||
struct list_head *report_list =
|
||||
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
|
||||
struct input_dev *dev;
|
||||
struct input_dev *dev = hidinput->input;
|
||||
int error;
|
||||
|
||||
if (list_empty(&hid->inputs)) {
|
||||
hid_err(hid, "no inputs found\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
hidinput = list_entry(hid->inputs.next, struct hid_input, list);
|
||||
dev = hidinput->input;
|
||||
if (!list_is_first(&hidinput->list, &hid->inputs))
|
||||
return 0;
|
||||
|
||||
if (list_empty(report_list)) {
|
||||
report = list_first_entry_or_null(report_list, struct hid_report, list);
|
||||
if (!report) {
|
||||
hid_err(hid, "no output report found\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
report = list_entry(report_list->next, struct hid_report, list);
|
||||
|
||||
if (report->maxfield < 1 || report->field[0]->report_count != 7) {
|
||||
hid_err(hid, "unexpected output report layout\n");
|
||||
return -ENODEV;
|
||||
|
|
@ -172,35 +166,13 @@ static int holtekff_init(struct hid_device *hid)
|
|||
return 0;
|
||||
}
|
||||
#else
|
||||
static inline int holtekff_init(struct hid_device *hid)
|
||||
static inline int holtek_input_configured(struct hid_device *hid,
|
||||
struct hid_input *hidinput)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int holtek_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = hid_parse(hdev);
|
||||
if (ret) {
|
||||
hid_err(hdev, "parse failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
|
||||
if (ret) {
|
||||
hid_err(hdev, "hw start failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
holtekff_init(hdev);
|
||||
|
||||
return 0;
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct hid_device_id holtek_devices[] = {
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) },
|
||||
{ }
|
||||
|
|
@ -210,7 +182,7 @@ MODULE_DEVICE_TABLE(hid, holtek_devices);
|
|||
static struct hid_driver holtek_driver = {
|
||||
.name = "holtek",
|
||||
.id_table = holtek_devices,
|
||||
.probe = holtek_probe,
|
||||
.input_configured = holtek_input_configured,
|
||||
};
|
||||
module_hid_driver(holtek_driver);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user