hid-magicmouse.c (dfc450b55d6b9215da27c5dc2c5f3ca1865575a6) | hid-magicmouse.c (abf832bfc349b54fd500f1e3b612f7f3cd9dfcc6) |
---|---|
1/* 2 * Apple "Magic" Wireless Mouse driver 3 * 4 * Copyright (c) 2010 Michael Poole <mdpoole@troilus.org> 5 * Copyright (c) 2010 Chase Douglas <chase.douglas@canonical.com> 6 */ 7 8/* --- 22 unchanged lines hidden (view full) --- 31 32static bool emulate_scroll_wheel = true; 33module_param(emulate_scroll_wheel, bool, 0644); 34MODULE_PARM_DESC(emulate_scroll_wheel, "Emulate a scroll wheel"); 35 36static unsigned int scroll_speed = 32; 37static int param_set_scroll_speed(const char *val, struct kernel_param *kp) { 38 unsigned long speed; | 1/* 2 * Apple "Magic" Wireless Mouse driver 3 * 4 * Copyright (c) 2010 Michael Poole <mdpoole@troilus.org> 5 * Copyright (c) 2010 Chase Douglas <chase.douglas@canonical.com> 6 */ 7 8/* --- 22 unchanged lines hidden (view full) --- 31 32static bool emulate_scroll_wheel = true; 33module_param(emulate_scroll_wheel, bool, 0644); 34MODULE_PARM_DESC(emulate_scroll_wheel, "Emulate a scroll wheel"); 35 36static unsigned int scroll_speed = 32; 37static int param_set_scroll_speed(const char *val, struct kernel_param *kp) { 38 unsigned long speed; |
39 if (!val || kstrtoul(val, 0, &speed) || speed > 63) | 39 if (!val || strict_strtoul(val, 0, &speed) || speed > 63) |
40 return -EINVAL; 41 scroll_speed = speed; 42 return 0; 43} 44module_param_call(scroll_speed, param_set_scroll_speed, param_get_uint, &scroll_speed, 0644); 45MODULE_PARM_DESC(scroll_speed, "Scroll speed, value from 0 (slow) to 63 (fast)"); 46 47static bool scroll_acceleration = false; --- 431 unchanged lines hidden (view full) --- 479static int magicmouse_probe(struct hid_device *hdev, 480 const struct hid_device_id *id) 481{ 482 __u8 feature[] = { 0xd7, 0x01 }; 483 struct magicmouse_sc *msc; 484 struct hid_report *report; 485 int ret; 486 | 40 return -EINVAL; 41 scroll_speed = speed; 42 return 0; 43} 44module_param_call(scroll_speed, param_set_scroll_speed, param_get_uint, &scroll_speed, 0644); 45MODULE_PARM_DESC(scroll_speed, "Scroll speed, value from 0 (slow) to 63 (fast)"); 46 47static bool scroll_acceleration = false; --- 431 unchanged lines hidden (view full) --- 479static int magicmouse_probe(struct hid_device *hdev, 480 const struct hid_device_id *id) 481{ 482 __u8 feature[] = { 0xd7, 0x01 }; 483 struct magicmouse_sc *msc; 484 struct hid_report *report; 485 int ret; 486 |
487 msc = kzalloc(sizeof(*msc), GFP_KERNEL); | 487 msc = devm_kzalloc(&hdev->dev, sizeof(*msc), GFP_KERNEL); |
488 if (msc == NULL) { 489 hid_err(hdev, "can't alloc magicmouse descriptor\n"); 490 return -ENOMEM; 491 } 492 493 msc->scroll_accel = SCROLL_ACCEL_DEFAULT; 494 495 msc->quirks = id->driver_data; 496 hid_set_drvdata(hdev, msc); 497 498 ret = hid_parse(hdev); 499 if (ret) { 500 hid_err(hdev, "magicmouse hid parse failed\n"); | 488 if (msc == NULL) { 489 hid_err(hdev, "can't alloc magicmouse descriptor\n"); 490 return -ENOMEM; 491 } 492 493 msc->scroll_accel = SCROLL_ACCEL_DEFAULT; 494 495 msc->quirks = id->driver_data; 496 hid_set_drvdata(hdev, msc); 497 498 ret = hid_parse(hdev); 499 if (ret) { 500 hid_err(hdev, "magicmouse hid parse failed\n"); |
501 goto err_free; | 501 return ret; |
502 } 503 504 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 505 if (ret) { 506 hid_err(hdev, "magicmouse hw start failed\n"); | 502 } 503 504 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 505 if (ret) { 506 hid_err(hdev, "magicmouse hw start failed\n"); |
507 goto err_free; | 507 return ret; |
508 } 509 510 if (!msc->input) { 511 hid_err(hdev, "magicmouse input not registered\n"); 512 ret = -ENOMEM; 513 goto err_stop_hw; 514 } 515 --- 27 unchanged lines hidden (view full) --- 543 if (ret != -EIO && ret != sizeof(feature)) { 544 hid_err(hdev, "unable to request touch data (%d)\n", ret); 545 goto err_stop_hw; 546 } 547 548 return 0; 549err_stop_hw: 550 hid_hw_stop(hdev); | 508 } 509 510 if (!msc->input) { 511 hid_err(hdev, "magicmouse input not registered\n"); 512 ret = -ENOMEM; 513 goto err_stop_hw; 514 } 515 --- 27 unchanged lines hidden (view full) --- 543 if (ret != -EIO && ret != sizeof(feature)) { 544 hid_err(hdev, "unable to request touch data (%d)\n", ret); 545 goto err_stop_hw; 546 } 547 548 return 0; 549err_stop_hw: 550 hid_hw_stop(hdev); |
551err_free: 552 kfree(msc); | |
553 return ret; 554} 555 | 551 return ret; 552} 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[] = { 565 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 566 USB_DEVICE_ID_APPLE_MAGICMOUSE), .driver_data = 0 }, 567 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 568 USB_DEVICE_ID_APPLE_MAGICTRACKPAD), .driver_data = 0 }, 569 { } 570}; 571MODULE_DEVICE_TABLE(hid, magic_mice); 572 573static struct hid_driver magicmouse_driver = { 574 .name = "magicmouse", 575 .id_table = magic_mice, 576 .probe = magicmouse_probe, | 554static const struct hid_device_id magic_mice[] = { 555 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 556 USB_DEVICE_ID_APPLE_MAGICMOUSE), .driver_data = 0 }, 557 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 558 USB_DEVICE_ID_APPLE_MAGICTRACKPAD), .driver_data = 0 }, 559 { } 560}; 561MODULE_DEVICE_TABLE(hid, magic_mice); 562 563static struct hid_driver magicmouse_driver = { 564 .name = "magicmouse", 565 .id_table = magic_mice, 566 .probe = magicmouse_probe, |
577 .remove = magicmouse_remove, | |
578 .raw_event = magicmouse_raw_event, 579 .input_mapping = magicmouse_input_mapping, 580 .input_configured = magicmouse_input_configured, 581}; 582module_hid_driver(magicmouse_driver); 583 584MODULE_LICENSE("GPL"); | 567 .raw_event = magicmouse_raw_event, 568 .input_mapping = magicmouse_input_mapping, 569 .input_configured = magicmouse_input_configured, 570}; 571module_hid_driver(magicmouse_driver); 572 573MODULE_LICENSE("GPL"); |