aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-magicmouse.c
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2013-04-02 05:11:52 -0400
committerJiri Kosina <jkosina@suse.cz>2013-04-04 03:49:56 -0400
commitf1a9a149abc86903e81dd1b2e720f3f89874384b (patch)
treee0afda3a56352eec1afed013171e0a4d55ca9399 /drivers/hid/hid-magicmouse.c
parent30b29537bcba070b3df8d7d24c1975676a1a6a4f (diff)
HID: magicmouse: fix race between input_register() and probe()
Since kernel 3.7, it appears that the input registration occured before the end of magicmouse_setup_input(). This is shown by receiving a lot of "EV_SYN SYN_REPORT 1" instead of normal "EV_SYN SYN_REPORT 0". This value means that the output buffer is full, and the user space is loosing events. Using .input_configured guarantees that the race is not occuring, and that the call of "input_set_events_per_packet(input, 60)" is taken into account by input_register(). Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=908604 Cc: stable@vger.kernel.org Reported-and-Tested-By: Clarke Wixon <cwixon@usa.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-magicmouse.c')
-rw-r--r--drivers/hid/hid-magicmouse.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index f7f113ba083e..a8ce44296cfd 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -462,6 +462,21 @@ static int magicmouse_input_mapping(struct hid_device *hdev,
462 return 0; 462 return 0;
463} 463}
464 464
465static void magicmouse_input_configured(struct hid_device *hdev,
466 struct hid_input *hi)
467
468{
469 struct magicmouse_sc *msc = hid_get_drvdata(hdev);
470
471 int ret = magicmouse_setup_input(msc->input, hdev);
472 if (ret) {
473 hid_err(hdev, "magicmouse setup input failed (%d)\n", ret);
474 /* clean msc->input to notify probe() of the failure */
475 msc->input = NULL;
476 }
477}
478
479
465static int magicmouse_probe(struct hid_device *hdev, 480static int magicmouse_probe(struct hid_device *hdev,
466 const struct hid_device_id *id) 481 const struct hid_device_id *id)
467{ 482{
@@ -493,15 +508,10 @@ static int magicmouse_probe(struct hid_device *hdev,
493 goto err_free; 508 goto err_free;
494 } 509 }
495 510
496 /* We do this after hid-input is done parsing reports so that 511 if (!msc->input) {
497 * hid-input uses the most natural button and axis IDs. 512 hid_err(hdev, "magicmouse input not registered\n");
498 */ 513 ret = -ENOMEM;
499 if (msc->input) { 514 goto err_stop_hw;
500 ret = magicmouse_setup_input(msc->input, hdev);
501 if (ret) {
502 hid_err(hdev, "magicmouse setup input failed (%d)\n", ret);
503 goto err_stop_hw;
504 }
505 } 515 }
506 516
507 if (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE) 517 if (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE)
@@ -568,6 +578,7 @@ static struct hid_driver magicmouse_driver = {
568 .remove = magicmouse_remove, 578 .remove = magicmouse_remove,
569 .raw_event = magicmouse_raw_event, 579 .raw_event = magicmouse_raw_event,
570 .input_mapping = magicmouse_input_mapping, 580 .input_mapping = magicmouse_input_mapping,
581 .input_configured = magicmouse_input_configured,
571}; 582};
572module_hid_driver(magicmouse_driver); 583module_hid_driver(magicmouse_driver);
573 584