mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 12:13:51 -04:00
HID: emsff: 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:
committed by
Jiri Kosina
parent
2c73259c1b
commit
f083fa975b
@@ -43,29 +43,23 @@ static int emsff_play(struct input_dev *dev, void *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int emsff_init(struct hid_device *hid)
|
||||
static int ems_input_configured(struct hid_device *hid, struct hid_input *hidinput)
|
||||
{
|
||||
struct emsff_device *emsff;
|
||||
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_first_entry(&hid->inputs, 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 reports found\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
report = list_first_entry(report_list, struct hid_report, list);
|
||||
if (report->maxfield < 1) {
|
||||
hid_err(hid, "no fields in the report\n");
|
||||
return -ENODEV;
|
||||
@@ -80,6 +74,7 @@ static int emsff_init(struct hid_device *hid)
|
||||
if (!emsff)
|
||||
return -ENOMEM;
|
||||
|
||||
emsff->report = report;
|
||||
set_bit(FF_RUMBLE, dev->ffbit);
|
||||
|
||||
error = input_ff_create_memless(dev, emsff, emsff_play);
|
||||
@@ -88,7 +83,6 @@ static int emsff_init(struct hid_device *hid)
|
||||
return error;
|
||||
}
|
||||
|
||||
emsff->report = report;
|
||||
emsff->report->field[0]->value[0] = 0x01;
|
||||
emsff->report->field[0]->value[1] = 0x00;
|
||||
emsff->report->field[0]->value[2] = 0x00;
|
||||
@@ -103,34 +97,6 @@ static int emsff_init(struct hid_device *hid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ems_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;
|
||||
}
|
||||
|
||||
ret = emsff_init(hdev);
|
||||
if (ret) {
|
||||
dev_err(&hdev->dev, "force feedback init failed\n");
|
||||
hid_hw_stop(hdev);
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct hid_device_id ems_devices[] = {
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) },
|
||||
{ }
|
||||
@@ -140,7 +106,7 @@ MODULE_DEVICE_TABLE(hid, ems_devices);
|
||||
static struct hid_driver ems_driver = {
|
||||
.name = "hkems",
|
||||
.id_table = ems_devices,
|
||||
.probe = ems_probe,
|
||||
.input_configured = ems_input_configured,
|
||||
};
|
||||
module_hid_driver(ems_driver);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user