aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-magicmouse.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-06 12:30:36 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-06 12:30:36 -0400
commit22e04f6b4b04a8afe9af9239224591d06ba3b24d (patch)
tree9bb72350400153ab232e227a378f94e95ad27569 /drivers/hid/hid-magicmouse.c
parentec0ad730802173ec17e942f4b652a1819b1025b2 (diff)
parent4e5a494e4b4ba7e6aa1a8a285e98e3665fcb396e (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull HID updates from Jiri Kosina: "Highlights: - conversion of HID subsystem to use devm-based resource management, from Benjamin Tissoires - i2c-hid support for DT bindings, from Benjamin Tissoires - much improved support for Win8-multitouch devices, from Benjamin Tissoires - cleanup of core code using common hidinput_input_event(), from David Herrmann - fix for bug in implement() access to the bit stream (causing oops) that has been present in the code for ages, but devices that are able to trigger it have started to appear only now, from Jiri Kosina - fixes for CVE-2013-2899, CVE-2013-2898, CVE-2013-2896, CVE-2013-2892, CVE-2013-2888 (all triggerable only by specially crafted malicious HW devices plugged into the system), from Kees Cook - hidraw oops fix, from Manoj Chourasia - various smaller fixes here and there, support for a bunch of new devices by various contributors" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (53 commits) HID: MAINTAINERS: add roccat drivers HID: hid-sensor-hub: change kmalloc + memcpy by kmemdup HID: hid-sensor-hub: move to devm_kzalloc HID: hid-sensor-hub: fix indentation accross the code HID: move HID_REPORT_TYPES closer to the report-definitions HID: check for NULL field when setting values HID: picolcd_core: validate output report details HID: sensor-hub: validate feature report details HID: ntrig: validate feature report details HID: pantherlord: validate output report details HID: hid-wiimote: print small buffers via %*phC HID: uhid: improve uhid example client HID: Correct the USB IDs for the new Macbook Air 6 HID: wiimote: add support for Guitar-Hero guitars HID: wiimote: add support for Guitar-Hero drums Input: introduce BTN/ABS bits for drums and guitars HID: battery: don't do DMA from stack HID: roccat: add support for KonePureOptical v2 HID: picolcd: Prevent NULL pointer dereference on _remove() HID: usbhid: quirk for N-Trig DuoSense Touch Screen ...
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,