Skip to content

Commit c67ee52

Browse files
committed
Merge: HID: hyperv: streamline driver probe to avoid devres issues
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/43 JIRA: https://issues.redhat.com/browse/RHEL-67329 Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Approved-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Approved-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Approved-by: Cathy Avery <cavery@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents 4944f66 + 1b5d7e0 commit c67ee52

File tree

1 file changed

+41
-17
lines changed

1 file changed

+41
-17
lines changed

drivers/hid/hid-hyperv.c

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,25 @@ static int mousevsc_hid_raw_request(struct hid_device *hid,
422422
return 0;
423423
}
424424

425+
static int mousevsc_hid_probe(struct hid_device *hid_dev, const struct hid_device_id *id)
426+
{
427+
int ret;
428+
429+
ret = hid_parse(hid_dev);
430+
if (ret) {
431+
hid_err(hid_dev, "parse failed\n");
432+
return ret;
433+
}
434+
435+
ret = hid_hw_start(hid_dev, HID_CONNECT_HIDINPUT | HID_CONNECT_HIDDEV);
436+
if (ret) {
437+
hid_err(hid_dev, "hw start failed\n");
438+
return ret;
439+
}
440+
441+
return 0;
442+
}
443+
425444
static const struct hid_ll_driver mousevsc_ll_driver = {
426445
.parse = mousevsc_hid_parse,
427446
.open = mousevsc_hid_open,
@@ -431,7 +450,16 @@ static const struct hid_ll_driver mousevsc_ll_driver = {
431450
.raw_request = mousevsc_hid_raw_request,
432451
};
433452

434-
static struct hid_driver mousevsc_hid_driver;
453+
static const struct hid_device_id mousevsc_devices[] = {
454+
{ HID_DEVICE(BUS_VIRTUAL, HID_GROUP_ANY, 0x045E, 0x0621) },
455+
{ }
456+
};
457+
458+
static struct hid_driver mousevsc_hid_driver = {
459+
.name = "hid-hyperv",
460+
.id_table = mousevsc_devices,
461+
.probe = mousevsc_hid_probe,
462+
};
435463

436464
static int mousevsc_probe(struct hv_device *device,
437465
const struct hv_vmbus_device_id *dev_id)
@@ -473,7 +501,6 @@ static int mousevsc_probe(struct hv_device *device,
473501
}
474502

475503
hid_dev->ll_driver = &mousevsc_ll_driver;
476-
hid_dev->driver = &mousevsc_hid_driver;
477504
hid_dev->bus = BUS_VIRTUAL;
478505
hid_dev->vendor = input_dev->hid_dev_info.vendor;
479506
hid_dev->product = input_dev->hid_dev_info.product;
@@ -488,20 +515,6 @@ static int mousevsc_probe(struct hv_device *device,
488515
if (ret)
489516
goto probe_err2;
490517

491-
492-
ret = hid_parse(hid_dev);
493-
if (ret) {
494-
hid_err(hid_dev, "parse failed\n");
495-
goto probe_err2;
496-
}
497-
498-
ret = hid_hw_start(hid_dev, HID_CONNECT_HIDINPUT | HID_CONNECT_HIDDEV);
499-
500-
if (ret) {
501-
hid_err(hid_dev, "hw start failed\n");
502-
goto probe_err2;
503-
}
504-
505518
device_init_wakeup(&device->device, true);
506519

507520
input_dev->connected = true;
@@ -579,12 +592,23 @@ static struct hv_driver mousevsc_drv = {
579592

580593
static int __init mousevsc_init(void)
581594
{
582-
return vmbus_driver_register(&mousevsc_drv);
595+
int ret;
596+
597+
ret = hid_register_driver(&mousevsc_hid_driver);
598+
if (ret)
599+
return ret;
600+
601+
ret = vmbus_driver_register(&mousevsc_drv);
602+
if (ret)
603+
hid_unregister_driver(&mousevsc_hid_driver);
604+
605+
return ret;
583606
}
584607

585608
static void __exit mousevsc_exit(void)
586609
{
587610
vmbus_driver_unregister(&mousevsc_drv);
611+
hid_unregister_driver(&mousevsc_hid_driver);
588612
}
589613

590614
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)