hid-a4tech.c (bf61c8840efe60fd8f91446860b63338fb424158) | hid-a4tech.c (abf832bfc349b54fd500f1e3b612f7f3cd9dfcc6) |
---|---|
1/* 2 * HID driver for some a4tech "special" devices 3 * 4 * Copyright (c) 1999 Andreas Gal 5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 7 * Copyright (c) 2006-2007 Jiri Kosina 8 * Copyright (c) 2008 Jiri Slaby --- 76 unchanged lines hidden (view full) --- 85 return 0; 86} 87 88static int a4_probe(struct hid_device *hdev, const struct hid_device_id *id) 89{ 90 struct a4tech_sc *a4; 91 int ret; 92 | 1/* 2 * HID driver for some a4tech "special" devices 3 * 4 * Copyright (c) 1999 Andreas Gal 5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 7 * Copyright (c) 2006-2007 Jiri Kosina 8 * Copyright (c) 2008 Jiri Slaby --- 76 unchanged lines hidden (view full) --- 85 return 0; 86} 87 88static int a4_probe(struct hid_device *hdev, const struct hid_device_id *id) 89{ 90 struct a4tech_sc *a4; 91 int ret; 92 |
93 a4 = kzalloc(sizeof(*a4), GFP_KERNEL); | 93 a4 = devm_kzalloc(&hdev->dev, sizeof(*a4), GFP_KERNEL); |
94 if (a4 == NULL) { 95 hid_err(hdev, "can't alloc device descriptor\n"); | 94 if (a4 == NULL) { 95 hid_err(hdev, "can't alloc device descriptor\n"); |
96 ret = -ENOMEM; 97 goto err_free; | 96 return -ENOMEM; |
98 } 99 100 a4->quirks = id->driver_data; 101 102 hid_set_drvdata(hdev, a4); 103 104 ret = hid_parse(hdev); 105 if (ret) { 106 hid_err(hdev, "parse failed\n"); | 97 } 98 99 a4->quirks = id->driver_data; 100 101 hid_set_drvdata(hdev, a4); 102 103 ret = hid_parse(hdev); 104 if (ret) { 105 hid_err(hdev, "parse failed\n"); |
107 goto err_free; | 106 return ret; |
108 } 109 110 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 111 if (ret) { 112 hid_err(hdev, "hw start failed\n"); | 107 } 108 109 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 110 if (ret) { 111 hid_err(hdev, "hw start failed\n"); |
113 goto err_free; | 112 return ret; |
114 } 115 116 return 0; | 113 } 114 115 return 0; |
117err_free: 118 kfree(a4); 119 return ret; | |
120} 121 | 116} 117 |
122static void a4_remove(struct hid_device *hdev) 123{ 124 struct a4tech_sc *a4 = hid_get_drvdata(hdev); 125 126 hid_hw_stop(hdev); 127 kfree(a4); 128} 129 | |
130static const struct hid_device_id a4_devices[] = { 131 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU), 132 .driver_data = A4_2WHEEL_MOUSE_HACK_7 }, 133 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D), 134 .driver_data = A4_2WHEEL_MOUSE_HACK_B8 }, 135 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649), 136 .driver_data = A4_2WHEEL_MOUSE_HACK_B8 }, 137 { } 138}; 139MODULE_DEVICE_TABLE(hid, a4_devices); 140 141static struct hid_driver a4_driver = { 142 .name = "a4tech", 143 .id_table = a4_devices, 144 .input_mapped = a4_input_mapped, 145 .event = a4_event, 146 .probe = a4_probe, | 118static const struct hid_device_id a4_devices[] = { 119 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU), 120 .driver_data = A4_2WHEEL_MOUSE_HACK_7 }, 121 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D), 122 .driver_data = A4_2WHEEL_MOUSE_HACK_B8 }, 123 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649), 124 .driver_data = A4_2WHEEL_MOUSE_HACK_B8 }, 125 { } 126}; 127MODULE_DEVICE_TABLE(hid, a4_devices); 128 129static struct hid_driver a4_driver = { 130 .name = "a4tech", 131 .id_table = a4_devices, 132 .input_mapped = a4_input_mapped, 133 .event = a4_event, 134 .probe = a4_probe, |
147 .remove = a4_remove, | |
148}; 149module_hid_driver(a4_driver); 150 151MODULE_LICENSE("GPL"); | 135}; 136module_hid_driver(a4_driver); 137 138MODULE_LICENSE("GPL"); |