aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-magicmouse.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-magicmouse.c')
-rw-r--r--drivers/hid/hid-magicmouse.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 5bc37343eb22..3b43d1cfa936 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -36,7 +36,7 @@ MODULE_PARM_DESC(emulate_scroll_wheel, "Emulate a scroll wheel");
36static unsigned int scroll_speed = 32; 36static unsigned int scroll_speed = 32;
37static int param_set_scroll_speed(const char *val, struct kernel_param *kp) { 37static int param_set_scroll_speed(const char *val, struct kernel_param *kp) {
38 unsigned long speed; 38 unsigned long speed;
39 if (!val || strict_strtoul(val, 0, &speed) || speed > 63) 39 if (!val || kstrtoul(val, 0, &speed) || speed > 63)
40 return -EINVAL; 40 return -EINVAL;
41 scroll_speed = speed; 41 scroll_speed = speed;
42 return 0; 42 return 0;
@@ -484,7 +484,7 @@ static int magicmouse_probe(struct hid_device *hdev,
484 struct hid_report *report; 484 struct hid_report *report;
485 int ret; 485 int ret;
486 486
487 msc = kzalloc(sizeof(*msc), GFP_KERNEL); 487 msc = devm_kzalloc(&hdev->dev, sizeof(*msc), GFP_KERNEL);
488 if (msc == NULL) { 488 if (msc == NULL) {
489 hid_err(hdev, "can't alloc magicmouse descriptor\n"); 489 hid_err(hdev, "can't alloc magicmouse descriptor\n");
490 return -ENOMEM; 490 return -ENOMEM;
@@ -498,13 +498,13 @@ static int magicmouse_probe(struct hid_device *hdev,
498 ret = hid_parse(hdev); 498 ret = hid_parse(hdev);
499 if (ret) { 499 if (ret) {
500 hid_err(hdev, "magicmouse hid parse failed\n"); 500 hid_err(hdev, "magicmouse hid parse failed\n");
501 goto err_free; 501 return ret;
502 } 502 }
503 503
504 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 504 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
505 if (ret) { 505 if (ret) {
506 hid_err(hdev, "magicmouse hw start failed\n"); 506 hid_err(hdev, "magicmouse hw start failed\n");
507 goto err_free; 507 return ret;
508 } 508 }
509 509
510 if (!msc->input) { 510 if (!msc->input) {
@@ -548,19 +548,9 @@ static int magicmouse_probe(struct hid_device *hdev,
548 return 0; 548 return 0;
549err_stop_hw: 549err_stop_hw:
550 hid_hw_stop(hdev); 550 hid_hw_stop(hdev);
551err_free:
552 kfree(msc);
553 return ret; 551 return ret;
554} 552}
555 553
556static void magicmouse_remove(struct hid_device *hdev)
557{
558 struct magicmouse_sc *msc = hid_get_drvdata(hdev);
559
560 hid_hw_stop(hdev);
561 kfree(msc);
562}
563
564static const struct hid_device_id magic_mice[] = { 554static const struct hid_device_id magic_mice[] = {
565 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 555 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
566 USB_DEVICE_ID_APPLE_MAGICMOUSE), .driver_data = 0 }, 556 USB_DEVICE_ID_APPLE_MAGICMOUSE), .driver_data = 0 },
@@ -574,7 +564,6 @@ static struct hid_driver magicmouse_driver = {
574 .name = "magicmouse", 564 .name = "magicmouse",
575 .id_table = magic_mice, 565 .id_table = magic_mice,
576 .probe = magicmouse_probe, 566 .probe = magicmouse_probe,
577 .remove = magicmouse_remove,
578 .raw_event = magicmouse_raw_event, 567 .raw_event = magicmouse_raw_event,
579 .input_mapping = magicmouse_input_mapping, 568 .input_mapping = magicmouse_input_mapping,
580 .input_configured = magicmouse_input_configured, 569 .input_configured = magicmouse_input_configured,