diff options
author | Heiner Kallweit <hkallweit1@gmail.com> | 2016-06-22 16:04:36 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2016-06-23 02:48:42 -0400 |
commit | 38b09c030b91c368a839b4783abab51a9745a633 (patch) | |
tree | 0d191163fe2f7bf045f2bb9a9e0c1d0a2e5756bc | |
parent | 007414e8fbc8894f33a548874946b6edd2a2918e (diff) |
HID: remove ThingM blink(1) driver
Now that support for ThingM blink(1) was merged into the hid-led driver
the dedicated driver for this device can be removed.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | MAINTAINERS | 5 | ||||
-rw-r--r-- | drivers/hid/Kconfig | 8 | ||||
-rw-r--r-- | drivers/hid/Makefile | 1 | ||||
-rw-r--r-- | drivers/hid/hid-thingm.c | 263 |
4 files changed, 4 insertions, 273 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 1dd9335de071..ca05aacdf94e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -11042,11 +11042,6 @@ F: Documentation/thermal/cpu-cooling-api.txt | |||
11042 | F: drivers/thermal/cpu_cooling.c | 11042 | F: drivers/thermal/cpu_cooling.c |
11043 | F: include/linux/cpu_cooling.h | 11043 | F: include/linux/cpu_cooling.h |
11044 | 11044 | ||
11045 | THINGM BLINK(1) USB RGB LED DRIVER | ||
11046 | M: Vivien Didelot <vivien.didelot@savoirfairelinux.com> | ||
11047 | S: Maintained | ||
11048 | F: drivers/hid/hid-thingm.c | ||
11049 | |||
11050 | THINKPAD ACPI EXTRAS DRIVER | 11045 | THINKPAD ACPI EXTRAS DRIVER |
11051 | M: Henrique de Moraes Holschuh <ibm-acpi@hmh.eng.br> | 11046 | M: Henrique de Moraes Holschuh <ibm-acpi@hmh.eng.br> |
11052 | L: ibm-acpi-devel@lists.sourceforge.net | 11047 | L: ibm-acpi-devel@lists.sourceforge.net |
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 0fecf8f0bb9d..8b1eb47930bc 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
@@ -832,11 +832,11 @@ config HID_THINGM | |||
832 | tristate "ThingM blink(1) USB RGB LED" | 832 | tristate "ThingM blink(1) USB RGB LED" |
833 | depends on HID | 833 | depends on HID |
834 | depends on LEDS_CLASS | 834 | depends on LEDS_CLASS |
835 | select HID_LED | ||
835 | ---help--- | 836 | ---help--- |
836 | Support for the ThingM blink(1) USB RGB LED. This driver registers a | 837 | Support for the ThingM blink(1) USB RGB LED. This driver has been |
837 | Linux LED class instance, plus additional sysfs attributes to control | 838 | merged into the generic hid led driver. Config symbol HID_THINGM |
838 | RGB colors, fade time and playing. The device is exposed through hidraw | 839 | just selects HID_LED and will be removed soon. |
839 | to access other functions. | ||
840 | 840 | ||
841 | config HID_THRUSTMASTER | 841 | config HID_THRUSTMASTER |
842 | tristate "ThrustMaster devices support" | 842 | tristate "ThrustMaster devices support" |
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 86d71f60a967..ab5a5b005e5d 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile | |||
@@ -90,7 +90,6 @@ obj-$(CONFIG_HID_SPEEDLINK) += hid-speedlink.o | |||
90 | obj-$(CONFIG_HID_STEELSERIES) += hid-steelseries.o | 90 | obj-$(CONFIG_HID_STEELSERIES) += hid-steelseries.o |
91 | obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o | 91 | obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o |
92 | obj-$(CONFIG_HID_GREENASIA) += hid-gaff.o | 92 | obj-$(CONFIG_HID_GREENASIA) += hid-gaff.o |
93 | obj-$(CONFIG_HID_THINGM) += hid-thingm.o | ||
94 | obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o | 93 | obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o |
95 | obj-$(CONFIG_HID_TIVO) += hid-tivo.o | 94 | obj-$(CONFIG_HID_TIVO) += hid-tivo.o |
96 | obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o | 95 | obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o |
diff --git a/drivers/hid/hid-thingm.c b/drivers/hid/hid-thingm.c deleted file mode 100644 index 9ad9c6ec5bba..000000000000 --- a/drivers/hid/hid-thingm.c +++ /dev/null | |||
@@ -1,263 +0,0 @@ | |||
1 | /* | ||
2 | * ThingM blink(1) USB RGB LED driver | ||
3 | * | ||
4 | * Copyright 2013-2014 Savoir-faire Linux Inc. | ||
5 | * Vivien Didelot <vivien.didelot@savoirfairelinux.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License as | ||
9 | * published by the Free Software Foundation, version 2. | ||
10 | */ | ||
11 | |||
12 | #include <linux/hid.h> | ||
13 | #include <linux/hidraw.h> | ||
14 | #include <linux/leds.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/mutex.h> | ||
17 | |||
18 | #include "hid-ids.h" | ||
19 | |||
20 | #define REPORT_ID 1 | ||
21 | #define REPORT_SIZE 9 | ||
22 | |||
23 | /* Firmware major number of supported devices */ | ||
24 | #define THINGM_MAJOR_MK1 '1' | ||
25 | #define THINGM_MAJOR_MK2 '2' | ||
26 | |||
27 | struct thingm_fwinfo { | ||
28 | char major; | ||
29 | unsigned numrgb; | ||
30 | unsigned first; | ||
31 | }; | ||
32 | |||
33 | static const struct thingm_fwinfo thingm_fwinfo[] = { | ||
34 | { | ||
35 | .major = THINGM_MAJOR_MK1, | ||
36 | .numrgb = 1, | ||
37 | .first = 0, | ||
38 | }, { | ||
39 | .major = THINGM_MAJOR_MK2, | ||
40 | .numrgb = 2, | ||
41 | .first = 1, | ||
42 | } | ||
43 | }; | ||
44 | |||
45 | /* A red, green or blue channel, part of an RGB chip */ | ||
46 | struct thingm_led { | ||
47 | struct thingm_rgb *rgb; | ||
48 | struct led_classdev ldev; | ||
49 | char name[32]; | ||
50 | }; | ||
51 | |||
52 | /* Basically a WS2812 5050 RGB LED chip */ | ||
53 | struct thingm_rgb { | ||
54 | struct thingm_device *tdev; | ||
55 | struct thingm_led red; | ||
56 | struct thingm_led green; | ||
57 | struct thingm_led blue; | ||
58 | u8 num; | ||
59 | }; | ||
60 | |||
61 | struct thingm_device { | ||
62 | struct hid_device *hdev; | ||
63 | struct { | ||
64 | char major; | ||
65 | char minor; | ||
66 | } version; | ||
67 | const struct thingm_fwinfo *fwinfo; | ||
68 | struct mutex lock; | ||
69 | struct thingm_rgb *rgb; | ||
70 | }; | ||
71 | |||
72 | static int thingm_send(struct thingm_device *tdev, u8 buf[REPORT_SIZE]) | ||
73 | { | ||
74 | int ret; | ||
75 | |||
76 | hid_dbg(tdev->hdev, "-> %d %c %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx\n", | ||
77 | buf[0], buf[1], buf[2], buf[3], buf[4], | ||
78 | buf[5], buf[6], buf[7], buf[8]); | ||
79 | |||
80 | mutex_lock(&tdev->lock); | ||
81 | |||
82 | ret = hid_hw_raw_request(tdev->hdev, buf[0], buf, REPORT_SIZE, | ||
83 | HID_FEATURE_REPORT, HID_REQ_SET_REPORT); | ||
84 | |||
85 | mutex_unlock(&tdev->lock); | ||
86 | |||
87 | return ret < 0 ? ret : 0; | ||
88 | } | ||
89 | |||
90 | static int thingm_recv(struct thingm_device *tdev, u8 buf[REPORT_SIZE]) | ||
91 | { | ||
92 | int ret; | ||
93 | |||
94 | /* | ||
95 | * A read consists of two operations: sending the read command | ||
96 | * and the actual read from the device. Use the mutex to protect | ||
97 | * the full sequence of both operations. | ||
98 | */ | ||
99 | mutex_lock(&tdev->lock); | ||
100 | |||
101 | ret = hid_hw_raw_request(tdev->hdev, buf[0], buf, REPORT_SIZE, | ||
102 | HID_FEATURE_REPORT, HID_REQ_SET_REPORT); | ||
103 | if (ret < 0) | ||
104 | goto err; | ||
105 | |||
106 | ret = hid_hw_raw_request(tdev->hdev, buf[0], buf, REPORT_SIZE, | ||
107 | HID_FEATURE_REPORT, HID_REQ_GET_REPORT); | ||
108 | if (ret < 0) | ||
109 | goto err; | ||
110 | |||
111 | ret = 0; | ||
112 | |||
113 | hid_dbg(tdev->hdev, "<- %d %c %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx\n", | ||
114 | buf[0], buf[1], buf[2], buf[3], buf[4], | ||
115 | buf[5], buf[6], buf[7], buf[8]); | ||
116 | err: | ||
117 | mutex_unlock(&tdev->lock); | ||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | static int thingm_version(struct thingm_device *tdev) | ||
122 | { | ||
123 | u8 buf[REPORT_SIZE] = { REPORT_ID, 'v', 0, 0, 0, 0, 0, 0, 0 }; | ||
124 | int err; | ||
125 | |||
126 | err = thingm_recv(tdev, buf); | ||
127 | if (err) | ||
128 | return err; | ||
129 | |||
130 | tdev->version.major = buf[3]; | ||
131 | tdev->version.minor = buf[4]; | ||
132 | |||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | static int thingm_write_color(struct thingm_rgb *rgb) | ||
137 | { | ||
138 | u8 buf[REPORT_SIZE] = { REPORT_ID, 'c', 0, 0, 0, 0, 0, rgb->num, 0 }; | ||
139 | |||
140 | buf[2] = rgb->red.ldev.brightness; | ||
141 | buf[3] = rgb->green.ldev.brightness; | ||
142 | buf[4] = rgb->blue.ldev.brightness; | ||
143 | |||
144 | return thingm_send(rgb->tdev, buf); | ||
145 | } | ||
146 | |||
147 | static int thingm_led_set(struct led_classdev *ldev, | ||
148 | enum led_brightness brightness) | ||
149 | { | ||
150 | struct thingm_led *led = container_of(ldev, struct thingm_led, ldev); | ||
151 | |||
152 | return thingm_write_color(led->rgb); | ||
153 | } | ||
154 | |||
155 | static int thingm_init_led(struct thingm_led *led, const char *color_name, | ||
156 | struct thingm_rgb *rgb, int minor) | ||
157 | { | ||
158 | snprintf(led->name, sizeof(led->name), "thingm%d:%s:led%d", | ||
159 | minor, color_name, rgb->num); | ||
160 | led->ldev.name = led->name; | ||
161 | led->ldev.max_brightness = 255; | ||
162 | led->ldev.brightness_set_blocking = thingm_led_set; | ||
163 | led->ldev.flags = LED_HW_PLUGGABLE; | ||
164 | led->rgb = rgb; | ||
165 | return devm_led_classdev_register(&rgb->tdev->hdev->dev, &led->ldev); | ||
166 | } | ||
167 | |||
168 | static int thingm_init_rgb(struct thingm_rgb *rgb) | ||
169 | { | ||
170 | const int minor = ((struct hidraw *) rgb->tdev->hdev->hidraw)->minor; | ||
171 | int err; | ||
172 | |||
173 | /* Register the red diode */ | ||
174 | err = thingm_init_led(&rgb->red, "red", rgb, minor); | ||
175 | if (err) | ||
176 | return err; | ||
177 | |||
178 | /* Register the green diode */ | ||
179 | err = thingm_init_led(&rgb->green, "green", rgb, minor); | ||
180 | if (err) | ||
181 | return err; | ||
182 | |||
183 | /* Register the blue diode */ | ||
184 | return thingm_init_led(&rgb->blue, "blue", rgb, minor); | ||
185 | } | ||
186 | |||
187 | static int thingm_probe(struct hid_device *hdev, const struct hid_device_id *id) | ||
188 | { | ||
189 | struct thingm_device *tdev; | ||
190 | int i, err; | ||
191 | |||
192 | tdev = devm_kzalloc(&hdev->dev, sizeof(struct thingm_device), | ||
193 | GFP_KERNEL); | ||
194 | if (!tdev) | ||
195 | return -ENOMEM; | ||
196 | |||
197 | tdev->hdev = hdev; | ||
198 | hid_set_drvdata(hdev, tdev); | ||
199 | |||
200 | err = hid_parse(hdev); | ||
201 | if (err) | ||
202 | return err; | ||
203 | |||
204 | mutex_init(&tdev->lock); | ||
205 | |||
206 | err = thingm_version(tdev); | ||
207 | if (err) | ||
208 | return err; | ||
209 | |||
210 | hid_dbg(hdev, "firmware version: %c.%c\n", | ||
211 | tdev->version.major, tdev->version.minor); | ||
212 | |||
213 | for (i = 0; i < ARRAY_SIZE(thingm_fwinfo) && !tdev->fwinfo; ++i) | ||
214 | if (thingm_fwinfo[i].major == tdev->version.major) | ||
215 | tdev->fwinfo = &thingm_fwinfo[i]; | ||
216 | |||
217 | if (!tdev->fwinfo) { | ||
218 | hid_err(hdev, "unsupported firmware %c\n", tdev->version.major); | ||
219 | return -ENODEV; | ||
220 | } | ||
221 | |||
222 | tdev->rgb = devm_kzalloc(&hdev->dev, | ||
223 | sizeof(struct thingm_rgb) * tdev->fwinfo->numrgb, | ||
224 | GFP_KERNEL); | ||
225 | if (!tdev->rgb) | ||
226 | return -ENOMEM; | ||
227 | |||
228 | err = hid_hw_start(hdev, HID_CONNECT_HIDRAW); | ||
229 | if (err) | ||
230 | return err; | ||
231 | |||
232 | for (i = 0; i < tdev->fwinfo->numrgb; ++i) { | ||
233 | struct thingm_rgb *rgb = tdev->rgb + i; | ||
234 | |||
235 | rgb->tdev = tdev; | ||
236 | rgb->num = tdev->fwinfo->first + i; | ||
237 | err = thingm_init_rgb(rgb); | ||
238 | if (err) { | ||
239 | hid_hw_stop(hdev); | ||
240 | return err; | ||
241 | } | ||
242 | } | ||
243 | |||
244 | return 0; | ||
245 | } | ||
246 | |||
247 | static const struct hid_device_id thingm_table[] = { | ||
248 | { HID_USB_DEVICE(USB_VENDOR_ID_THINGM, USB_DEVICE_ID_BLINK1) }, | ||
249 | { } | ||
250 | }; | ||
251 | MODULE_DEVICE_TABLE(hid, thingm_table); | ||
252 | |||
253 | static struct hid_driver thingm_driver = { | ||
254 | .name = "thingm", | ||
255 | .probe = thingm_probe, | ||
256 | .id_table = thingm_table, | ||
257 | }; | ||
258 | |||
259 | module_hid_driver(thingm_driver); | ||
260 | |||
261 | MODULE_LICENSE("GPL"); | ||
262 | MODULE_AUTHOR("Vivien Didelot <vivien.didelot@savoirfairelinux.com>"); | ||
263 | MODULE_DESCRIPTION("ThingM blink(1) USB RGB LED driver"); | ||