1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Force feedback support for Logitech Gaming Wheels
5 * Including G27, G25, DFP, DFGT, FFEX, Momo, Momo2 &
6 * Speed Force Wireless (WiiWheel)
8 * Copyright (c) 2010 Simon Wood <simon@mungewell.org>
15 #include <linux/input.h>
16 #include <linux/usb.h>
17 #include <linux/hid.h>
19 #include "usbhid/usbhid.h"
21 #include "hid-lg4ff.h"
24 #define LG4FF_MMODE_IS_MULTIMODE 0
25 #define LG4FF_MMODE_SWITCHED 1
26 #define LG4FF_MMODE_NOT_MULTIMODE 2
28 #define LG4FF_MODE_NATIVE_IDX 0
29 #define LG4FF_MODE_DFEX_IDX 1
30 #define LG4FF_MODE_DFP_IDX 2
31 #define LG4FF_MODE_G25_IDX 3
32 #define LG4FF_MODE_DFGT_IDX 4
33 #define LG4FF_MODE_G27_IDX 5
34 #define LG4FF_MODE_G29_IDX 6
35 #define LG4FF_MODE_MAX_IDX 7
37 #define LG4FF_MODE_NATIVE BIT(LG4FF_MODE_NATIVE_IDX)
38 #define LG4FF_MODE_DFEX BIT(LG4FF_MODE_DFEX_IDX)
39 #define LG4FF_MODE_DFP BIT(LG4FF_MODE_DFP_IDX)
40 #define LG4FF_MODE_G25 BIT(LG4FF_MODE_G25_IDX)
41 #define LG4FF_MODE_DFGT BIT(LG4FF_MODE_DFGT_IDX)
42 #define LG4FF_MODE_G27 BIT(LG4FF_MODE_G27_IDX)
43 #define LG4FF_MODE_G29 BIT(LG4FF_MODE_G29_IDX)
45 #define LG4FF_DFEX_TAG "DF-EX"
46 #define LG4FF_DFEX_NAME "Driving Force / Formula EX"
47 #define LG4FF_DFP_TAG "DFP"
48 #define LG4FF_DFP_NAME "Driving Force Pro"
49 #define LG4FF_G25_TAG "G25"
50 #define LG4FF_G25_NAME "G25 Racing Wheel"
51 #define LG4FF_G27_TAG "G27"
52 #define LG4FF_G27_NAME "G27 Racing Wheel"
53 #define LG4FF_G29_TAG "G29"
54 #define LG4FF_G29_NAME "G29 Racing Wheel"
55 #define LG4FF_DFGT_TAG "DFGT"
56 #define LG4FF_DFGT_NAME "Driving Force GT"
58 #define LG4FF_FFEX_REV_MAJ 0x21
59 #define LG4FF_FFEX_REV_MIN 0x00
61 static void lg4ff_set_range_dfp(struct hid_device *hid, u16 range);
62 static void lg4ff_set_range_g25(struct hid_device *hid, u16 range);
64 struct lg4ff_wheel_data {
70 #ifdef CONFIG_LEDS_CLASS
72 struct led_classdev *led[5];
74 const u32 alternate_modes;
75 const char * const real_tag;
76 const char * const real_name;
77 const u16 real_product_id;
79 void (*set_range)(struct hid_device *hid, u16 range);
82 struct lg4ff_device_entry {
83 spinlock_t report_lock; /* Protect output HID report */
84 struct hid_report *report;
85 struct lg4ff_wheel_data wdata;
88 static const signed short lg4ff_wheel_effects[] = {
94 static const signed short no_wheel_effects[] = {
100 const signed short *ff_effects;
103 void (*set_range)(struct hid_device *hid, u16 range);
106 struct lg4ff_compat_mode_switch {
107 const u8 cmd_count; /* Number of commands to send */
111 struct lg4ff_wheel_ident_info {
115 const u16 real_product_id;
118 struct lg4ff_multimode_wheel {
119 const u16 product_id;
120 const u32 alternate_modes;
121 const char *real_tag;
122 const char *real_name;
125 struct lg4ff_alternate_mode {
126 const u16 product_id;
131 static const struct lg4ff_wheel lg4ff_devices[] = {
132 {USB_DEVICE_ID_LOGITECH_WINGMAN_FG, no_wheel_effects, 40, 180, NULL},
133 {USB_DEVICE_ID_LOGITECH_WINGMAN_FFG, lg4ff_wheel_effects, 40, 180, NULL},
134 {USB_DEVICE_ID_LOGITECH_WHEEL, lg4ff_wheel_effects, 40, 270, NULL},
135 {USB_DEVICE_ID_LOGITECH_MOMO_WHEEL, lg4ff_wheel_effects, 40, 270, NULL},
136 {USB_DEVICE_ID_LOGITECH_DFP_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_dfp},
137 {USB_DEVICE_ID_LOGITECH_G25_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25},
138 {USB_DEVICE_ID_LOGITECH_DFGT_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25},
139 {USB_DEVICE_ID_LOGITECH_G27_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25},
140 {USB_DEVICE_ID_LOGITECH_G29_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25},
141 {USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2, lg4ff_wheel_effects, 40, 270, NULL},
142 {USB_DEVICE_ID_LOGITECH_WII_WHEEL, lg4ff_wheel_effects, 40, 270, NULL}
145 static const struct lg4ff_multimode_wheel lg4ff_multimode_wheels[] = {
146 {USB_DEVICE_ID_LOGITECH_DFP_WHEEL,
147 LG4FF_MODE_NATIVE | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
148 LG4FF_DFP_TAG, LG4FF_DFP_NAME},
149 {USB_DEVICE_ID_LOGITECH_G25_WHEEL,
150 LG4FF_MODE_NATIVE | LG4FF_MODE_G25 | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
151 LG4FF_G25_TAG, LG4FF_G25_NAME},
152 {USB_DEVICE_ID_LOGITECH_DFGT_WHEEL,
153 LG4FF_MODE_NATIVE | LG4FF_MODE_DFGT | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
154 LG4FF_DFGT_TAG, LG4FF_DFGT_NAME},
155 {USB_DEVICE_ID_LOGITECH_G27_WHEEL,
156 LG4FF_MODE_NATIVE | LG4FF_MODE_G27 | LG4FF_MODE_G25 | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
157 LG4FF_G27_TAG, LG4FF_G27_NAME},
158 {USB_DEVICE_ID_LOGITECH_G29_WHEEL,
159 LG4FF_MODE_NATIVE | LG4FF_MODE_G29 | LG4FF_MODE_G27 | LG4FF_MODE_G25 | LG4FF_MODE_DFGT | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
160 LG4FF_G29_TAG, LG4FF_G29_NAME},
163 static const struct lg4ff_alternate_mode lg4ff_alternate_modes[] = {
164 [LG4FF_MODE_NATIVE_IDX] = {0, "native", ""},
165 [LG4FF_MODE_DFEX_IDX] = {USB_DEVICE_ID_LOGITECH_WHEEL, LG4FF_DFEX_TAG, LG4FF_DFEX_NAME},
166 [LG4FF_MODE_DFP_IDX] = {USB_DEVICE_ID_LOGITECH_DFP_WHEEL, LG4FF_DFP_TAG, LG4FF_DFP_NAME},
167 [LG4FF_MODE_G25_IDX] = {USB_DEVICE_ID_LOGITECH_G25_WHEEL, LG4FF_G25_TAG, LG4FF_G25_NAME},
168 [LG4FF_MODE_DFGT_IDX] = {USB_DEVICE_ID_LOGITECH_DFGT_WHEEL, LG4FF_DFGT_TAG, LG4FF_DFGT_NAME},
169 [LG4FF_MODE_G27_IDX] = {USB_DEVICE_ID_LOGITECH_G27_WHEEL, LG4FF_G27_TAG, LG4FF_G27_NAME},
170 [LG4FF_MODE_G29_IDX] = {USB_DEVICE_ID_LOGITECH_G29_WHEEL, LG4FF_G29_TAG, LG4FF_G29_NAME},
173 /* Multimode wheel identificators */
174 static const struct lg4ff_wheel_ident_info lg4ff_dfp_ident_info = {
175 LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
178 USB_DEVICE_ID_LOGITECH_DFP_WHEEL
181 static const struct lg4ff_wheel_ident_info lg4ff_g25_ident_info = {
182 LG4FF_MODE_G25 | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
185 USB_DEVICE_ID_LOGITECH_G25_WHEEL
188 static const struct lg4ff_wheel_ident_info lg4ff_g27_ident_info = {
189 LG4FF_MODE_G27 | LG4FF_MODE_G25 | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
192 USB_DEVICE_ID_LOGITECH_G27_WHEEL
195 static const struct lg4ff_wheel_ident_info lg4ff_dfgt_ident_info = {
196 LG4FF_MODE_DFGT | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
199 USB_DEVICE_ID_LOGITECH_DFGT_WHEEL
202 static const struct lg4ff_wheel_ident_info lg4ff_g29_ident_info = {
203 LG4FF_MODE_G29 | LG4FF_MODE_G27 | LG4FF_MODE_G25 | LG4FF_MODE_DFGT | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
206 USB_DEVICE_ID_LOGITECH_G29_WHEEL
209 static const struct lg4ff_wheel_ident_info lg4ff_g29_ident_info2 = {
210 LG4FF_MODE_G29 | LG4FF_MODE_G27 | LG4FF_MODE_G25 | LG4FF_MODE_DFGT | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
213 USB_DEVICE_ID_LOGITECH_G29_WHEEL
216 /* Multimode wheel identification checklists */
217 static const struct lg4ff_wheel_ident_info *lg4ff_main_checklist[] = {
218 &lg4ff_g29_ident_info,
219 &lg4ff_g29_ident_info2,
220 &lg4ff_dfgt_ident_info,
221 &lg4ff_g27_ident_info,
222 &lg4ff_g25_ident_info,
223 &lg4ff_dfp_ident_info
226 /* Compatibility mode switching commands */
227 /* EXT_CMD9 - Understood by G27 and DFGT */
228 static const struct lg4ff_compat_mode_switch lg4ff_mode_switch_ext09_dfex = {
230 {0xf8, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, /* Revert mode upon USB reset */
231 0xf8, 0x09, 0x00, 0x01, 0x00, 0x00, 0x00} /* Switch mode to DF-EX with detach */
234 static const struct lg4ff_compat_mode_switch lg4ff_mode_switch_ext09_dfp = {
236 {0xf8, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, /* Revert mode upon USB reset */
237 0xf8, 0x09, 0x01, 0x01, 0x00, 0x00, 0x00} /* Switch mode to DFP with detach */
240 static const struct lg4ff_compat_mode_switch lg4ff_mode_switch_ext09_g25 = {
242 {0xf8, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, /* Revert mode upon USB reset */
243 0xf8, 0x09, 0x02, 0x01, 0x00, 0x00, 0x00} /* Switch mode to G25 with detach */
246 static const struct lg4ff_compat_mode_switch lg4ff_mode_switch_ext09_dfgt = {
248 {0xf8, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, /* Revert mode upon USB reset */
249 0xf8, 0x09, 0x03, 0x01, 0x00, 0x00, 0x00} /* Switch mode to DFGT with detach */
252 static const struct lg4ff_compat_mode_switch lg4ff_mode_switch_ext09_g27 = {
254 {0xf8, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, /* Revert mode upon USB reset */
255 0xf8, 0x09, 0x04, 0x01, 0x00, 0x00, 0x00} /* Switch mode to G27 with detach */
258 static const struct lg4ff_compat_mode_switch lg4ff_mode_switch_ext09_g29 = {
260 {0xf8, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, /* Revert mode upon USB reset */
261 0xf8, 0x09, 0x05, 0x01, 0x01, 0x00, 0x00} /* Switch mode to G29 with detach */
264 /* EXT_CMD1 - Understood by DFP, G25, G27 and DFGT */
265 static const struct lg4ff_compat_mode_switch lg4ff_mode_switch_ext01_dfp = {
267 {0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}
270 /* EXT_CMD16 - Understood by G25 and G27 */
271 static const struct lg4ff_compat_mode_switch lg4ff_mode_switch_ext16_g25 = {
273 {0xf8, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00}
276 /* Recalculates X axis value accordingly to currently selected range */
277 static s32 lg4ff_adjust_dfp_x_axis(s32 value, u16 range)
284 else if (range == 200)
286 else if (range < 200)
291 new_value = 8192 + mult_frac(value - 8192, max_range, range);
294 else if (new_value > 16383)
300 int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field,
301 struct hid_usage *usage, s32 value, struct lg_drv_data *drv_data)
303 struct lg4ff_device_entry *entry = drv_data->device_props;
307 hid_err(hid, "Device properties not found");
311 switch (entry->wdata.product_id) {
312 case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
313 switch (usage->code) {
315 new_value = lg4ff_adjust_dfp_x_axis(value, entry->wdata.range);
316 input_event(field->hidinput->input, usage->type, usage->code, new_value);
326 int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report,
327 u8 *rd, int size, struct lg_drv_data *drv_data)
330 struct lg4ff_device_entry *entry = drv_data->device_props;
335 /* adjust HID report present combined pedals data */
336 if (entry->wdata.combine) {
337 switch (entry->wdata.product_id) {
338 case USB_DEVICE_ID_LOGITECH_WHEEL:
342 case USB_DEVICE_ID_LOGITECH_WINGMAN_FG:
343 case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG:
344 case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL:
345 case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2:
349 case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
353 case USB_DEVICE_ID_LOGITECH_G25_WHEEL:
354 case USB_DEVICE_ID_LOGITECH_G27_WHEEL:
357 case USB_DEVICE_ID_LOGITECH_DFGT_WHEEL:
358 case USB_DEVICE_ID_LOGITECH_G29_WHEEL:
361 case USB_DEVICE_ID_LOGITECH_WII_WHEEL:
368 /* Compute a combined axis when wheel does not supply it */
369 rd[offset] = (0xFF + rd[offset] - rd[offset+1]) >> 1;
377 static void lg4ff_init_wheel_data(struct lg4ff_wheel_data * const wdata, const struct lg4ff_wheel *wheel,
378 const struct lg4ff_multimode_wheel *mmode_wheel,
379 const u16 real_product_id)
381 u32 alternate_modes = 0;
382 const char *real_tag = NULL;
383 const char *real_name = NULL;
386 alternate_modes = mmode_wheel->alternate_modes;
387 real_tag = mmode_wheel->real_tag;
388 real_name = mmode_wheel->real_name;
392 struct lg4ff_wheel_data t_wdata = { .product_id = wheel->product_id,
393 .real_product_id = real_product_id,
395 .min_range = wheel->min_range,
396 .max_range = wheel->max_range,
397 .set_range = wheel->set_range,
398 .alternate_modes = alternate_modes,
399 .real_tag = real_tag,
400 .real_name = real_name };
402 memcpy(wdata, &t_wdata, sizeof(t_wdata));
406 static int lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *effect)
408 struct hid_device *hid = input_get_drvdata(dev);
409 struct lg4ff_device_entry *entry;
410 struct lg_drv_data *drv_data;
415 drv_data = hid_get_drvdata(hid);
417 hid_err(hid, "Private driver data not found!\n");
421 entry = drv_data->device_props;
423 hid_err(hid, "Device properties not found!\n");
426 value = entry->report->field[0]->value;
428 #define CLAMP(x) do { if (x < 0) x = 0; else if (x > 0xff) x = 0xff; } while (0)
430 switch (effect->type) {
432 x = effect->u.ramp.start_level + 0x80; /* 0x80 is no force */
435 spin_lock_irqsave(&entry->report_lock, flags);
437 /* De-activate force in slot-1*/
446 hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
447 spin_unlock_irqrestore(&entry->report_lock, flags);
451 value[0] = 0x11; /* Slot 1 */
459 hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
460 spin_unlock_irqrestore(&entry->report_lock, flags);
466 /* Sends default autocentering command compatible with
467 * all wheels except Formula Force EX */
468 static void lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitude)
470 struct hid_device *hid = input_get_drvdata(dev);
472 u32 expand_a, expand_b;
473 struct lg4ff_device_entry *entry;
474 struct lg_drv_data *drv_data;
477 drv_data = hid_get_drvdata(hid);
479 hid_err(hid, "Private driver data not found!\n");
483 entry = drv_data->device_props;
485 hid_err(hid, "Device properties not found!\n");
488 value = entry->report->field[0]->value;
490 /* De-activate Auto-Center */
491 spin_lock_irqsave(&entry->report_lock, flags);
492 if (magnitude == 0) {
501 hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
502 spin_unlock_irqrestore(&entry->report_lock, flags);
506 if (magnitude <= 0xaaaa) {
507 expand_a = 0x0c * magnitude;
508 expand_b = 0x80 * magnitude;
510 expand_a = (0x0c * 0xaaaa) + 0x06 * (magnitude - 0xaaaa);
511 expand_b = (0x80 * 0xaaaa) + 0xff * (magnitude - 0xaaaa);
514 /* Adjust for non-MOMO wheels */
515 switch (entry->wdata.product_id) {
516 case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL:
517 case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2:
520 expand_a = expand_a >> 1;
526 value[2] = expand_a / 0xaaaa;
527 value[3] = expand_a / 0xaaaa;
528 value[4] = expand_b / 0xaaaa;
532 hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
534 /* Activate Auto-Center */
543 hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
544 spin_unlock_irqrestore(&entry->report_lock, flags);
547 /* Sends autocentering command compatible with Formula Force EX */
548 static void lg4ff_set_autocenter_ffex(struct input_dev *dev, u16 magnitude)
550 struct hid_device *hid = input_get_drvdata(dev);
551 struct lg4ff_device_entry *entry;
552 struct lg_drv_data *drv_data;
555 magnitude = magnitude * 90 / 65535;
557 drv_data = hid_get_drvdata(hid);
559 hid_err(hid, "Private driver data not found!\n");
563 entry = drv_data->device_props;
565 hid_err(hid, "Device properties not found!\n");
568 value = entry->report->field[0]->value;
570 spin_lock_irqsave(&entry->report_lock, flags);
573 value[2] = magnitude >> 14;
574 value[3] = magnitude >> 14;
575 value[4] = magnitude;
579 hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
580 spin_unlock_irqrestore(&entry->report_lock, flags);
583 /* Sends command to set range compatible with G25/G27/Driving Force GT */
584 static void lg4ff_set_range_g25(struct hid_device *hid, u16 range)
586 struct lg4ff_device_entry *entry;
587 struct lg_drv_data *drv_data;
591 drv_data = hid_get_drvdata(hid);
593 hid_err(hid, "Private driver data not found!\n");
597 entry = drv_data->device_props;
599 hid_err(hid, "Device properties not found!\n");
602 value = entry->report->field[0]->value;
603 dbg_hid("G25/G27/DFGT: setting range to %u\n", range);
605 spin_lock_irqsave(&entry->report_lock, flags);
608 value[2] = range & 0x00ff;
609 value[3] = (range & 0xff00) >> 8;
614 hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
615 spin_unlock_irqrestore(&entry->report_lock, flags);
618 /* Sends commands to set range compatible with Driving Force Pro wheel */
619 static void lg4ff_set_range_dfp(struct hid_device *hid, u16 range)
621 struct lg4ff_device_entry *entry;
622 struct lg_drv_data *drv_data;
624 int start_left, start_right, full_range;
627 drv_data = hid_get_drvdata(hid);
629 hid_err(hid, "Private driver data not found!\n");
633 entry = drv_data->device_props;
635 hid_err(hid, "Device properties not found!\n");
638 value = entry->report->field[0]->value;
639 dbg_hid("Driving Force Pro: setting range to %u\n", range);
641 /* Prepare "coarse" limit command */
642 spin_lock_irqsave(&entry->report_lock, flags);
644 value[1] = 0x00; /* Set later */
658 hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
660 /* Prepare "fine" limit command */
669 if (range == 200 || range == 900) { /* Do not apply any fine limit */
670 hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
671 spin_unlock_irqrestore(&entry->report_lock, flags);
675 /* Construct fine limit command */
676 start_left = (((full_range - range + 1) * 2047) / full_range);
677 start_right = 0xfff - start_left;
679 value[2] = start_left >> 4;
680 value[3] = start_right >> 4;
682 value[5] = (start_right & 0xe) << 4 | (start_left & 0xe);
685 hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
686 spin_unlock_irqrestore(&entry->report_lock, flags);
689 static const struct lg4ff_compat_mode_switch *lg4ff_get_mode_switch_command(const u16 real_product_id, const u16 target_product_id)
691 switch (real_product_id) {
692 case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
693 switch (target_product_id) {
694 case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
695 return &lg4ff_mode_switch_ext01_dfp;
696 /* DFP can only be switched to its native mode */
701 case USB_DEVICE_ID_LOGITECH_G25_WHEEL:
702 switch (target_product_id) {
703 case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
704 return &lg4ff_mode_switch_ext01_dfp;
705 case USB_DEVICE_ID_LOGITECH_G25_WHEEL:
706 return &lg4ff_mode_switch_ext16_g25;
707 /* G25 can only be switched to DFP mode or its native mode */
712 case USB_DEVICE_ID_LOGITECH_G27_WHEEL:
713 switch (target_product_id) {
714 case USB_DEVICE_ID_LOGITECH_WHEEL:
715 return &lg4ff_mode_switch_ext09_dfex;
716 case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
717 return &lg4ff_mode_switch_ext09_dfp;
718 case USB_DEVICE_ID_LOGITECH_G25_WHEEL:
719 return &lg4ff_mode_switch_ext09_g25;
720 case USB_DEVICE_ID_LOGITECH_G27_WHEEL:
721 return &lg4ff_mode_switch_ext09_g27;
722 /* G27 can only be switched to DF-EX, DFP, G25 or its native mode */
727 case USB_DEVICE_ID_LOGITECH_G29_WHEEL:
728 switch (target_product_id) {
729 case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
730 return &lg4ff_mode_switch_ext09_dfp;
731 case USB_DEVICE_ID_LOGITECH_DFGT_WHEEL:
732 return &lg4ff_mode_switch_ext09_dfgt;
733 case USB_DEVICE_ID_LOGITECH_G25_WHEEL:
734 return &lg4ff_mode_switch_ext09_g25;
735 case USB_DEVICE_ID_LOGITECH_G27_WHEEL:
736 return &lg4ff_mode_switch_ext09_g27;
737 case USB_DEVICE_ID_LOGITECH_G29_WHEEL:
738 return &lg4ff_mode_switch_ext09_g29;
739 /* G29 can only be switched to DF-EX, DFP, DFGT, G25, G27 or its native mode */
744 case USB_DEVICE_ID_LOGITECH_DFGT_WHEEL:
745 switch (target_product_id) {
746 case USB_DEVICE_ID_LOGITECH_WHEEL:
747 return &lg4ff_mode_switch_ext09_dfex;
748 case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
749 return &lg4ff_mode_switch_ext09_dfp;
750 case USB_DEVICE_ID_LOGITECH_DFGT_WHEEL:
751 return &lg4ff_mode_switch_ext09_dfgt;
752 /* DFGT can only be switched to DF-EX, DFP or its native mode */
757 /* No other wheels have multiple modes */
763 static int lg4ff_switch_compatibility_mode(struct hid_device *hid, const struct lg4ff_compat_mode_switch *s)
765 struct lg4ff_device_entry *entry;
766 struct lg_drv_data *drv_data;
771 drv_data = hid_get_drvdata(hid);
773 hid_err(hid, "Private driver data not found!\n");
777 entry = drv_data->device_props;
779 hid_err(hid, "Device properties not found!\n");
782 value = entry->report->field[0]->value;
784 spin_lock_irqsave(&entry->report_lock, flags);
785 for (i = 0; i < s->cmd_count; i++) {
788 for (j = 0; j < 7; j++)
789 value[j] = s->cmd[j + (7*i)];
791 hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
793 spin_unlock_irqrestore(&entry->report_lock, flags);
798 static ssize_t lg4ff_alternate_modes_show(struct device *dev, struct device_attribute *attr, char *buf)
800 struct hid_device *hid = to_hid_device(dev);
801 struct lg4ff_device_entry *entry;
802 struct lg_drv_data *drv_data;
806 drv_data = hid_get_drvdata(hid);
808 hid_err(hid, "Private driver data not found!\n");
812 entry = drv_data->device_props;
814 hid_err(hid, "Device properties not found!\n");
818 if (!entry->wdata.real_name) {
819 hid_err(hid, "NULL pointer to string\n");
823 for (i = 0; i < LG4FF_MODE_MAX_IDX; i++) {
824 if (entry->wdata.alternate_modes & BIT(i)) {
825 /* Print tag and full name */
826 count += scnprintf(buf + count, PAGE_SIZE - count, "%s: %s",
827 lg4ff_alternate_modes[i].tag,
828 !lg4ff_alternate_modes[i].product_id ? entry->wdata.real_name : lg4ff_alternate_modes[i].name);
829 if (count >= PAGE_SIZE - 1)
832 /* Mark the currently active mode with an asterisk */
833 if (lg4ff_alternate_modes[i].product_id == entry->wdata.product_id ||
834 (lg4ff_alternate_modes[i].product_id == 0 && entry->wdata.product_id == entry->wdata.real_product_id))
835 count += scnprintf(buf + count, PAGE_SIZE - count, " *\n");
837 count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
839 if (count >= PAGE_SIZE - 1)
847 static ssize_t lg4ff_alternate_modes_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
849 struct hid_device *hid = to_hid_device(dev);
850 struct lg4ff_device_entry *entry;
851 struct lg_drv_data *drv_data;
852 const struct lg4ff_compat_mode_switch *s;
853 u16 target_product_id = 0;
857 drv_data = hid_get_drvdata(hid);
859 hid_err(hid, "Private driver data not found!\n");
863 entry = drv_data->device_props;
865 hid_err(hid, "Device properties not found!\n");
869 /* Allow \n at the end of the input parameter */
870 lbuf = kasprintf(GFP_KERNEL, "%s", buf);
881 if (lbuf[i-1] == '\n') {
889 for (i = 0; i < LG4FF_MODE_MAX_IDX; i++) {
890 const u16 mode_product_id = lg4ff_alternate_modes[i].product_id;
891 const char *tag = lg4ff_alternate_modes[i].tag;
893 if (entry->wdata.alternate_modes & BIT(i)) {
894 if (!strcmp(tag, lbuf)) {
895 if (!mode_product_id)
896 target_product_id = entry->wdata.real_product_id;
898 target_product_id = mode_product_id;
904 if (i == LG4FF_MODE_MAX_IDX) {
905 hid_info(hid, "Requested mode \"%s\" is not supported by the device\n", lbuf);
909 kfree(lbuf); /* Not needed anymore */
911 if (target_product_id == entry->wdata.product_id) /* Nothing to do */
914 /* Automatic switching has to be disabled for the switch to DF-EX mode to work correctly */
915 if (target_product_id == USB_DEVICE_ID_LOGITECH_WHEEL && !lg4ff_no_autoswitch) {
916 hid_info(hid, "\"%s\" cannot be switched to \"DF-EX\" mode. Load the \"hid_logitech\" module with \"lg4ff_no_autoswitch=1\" parameter set and try again\n",
917 entry->wdata.real_name);
921 /* Take care of hardware limitations */
922 if ((entry->wdata.real_product_id == USB_DEVICE_ID_LOGITECH_DFP_WHEEL || entry->wdata.real_product_id == USB_DEVICE_ID_LOGITECH_G25_WHEEL) &&
923 entry->wdata.product_id > target_product_id) {
924 hid_info(hid, "\"%s\" cannot be switched back into \"%s\" mode\n", entry->wdata.real_name, lg4ff_alternate_modes[i].name);
928 s = lg4ff_get_mode_switch_command(entry->wdata.real_product_id, target_product_id);
930 hid_err(hid, "Invalid target product ID %X\n", target_product_id);
934 ret = lg4ff_switch_compatibility_mode(hid, s);
935 return (ret == 0 ? count : ret);
937 static DEVICE_ATTR(alternate_modes, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, lg4ff_alternate_modes_show, lg4ff_alternate_modes_store);
939 static ssize_t lg4ff_combine_show(struct device *dev, struct device_attribute *attr,
942 struct hid_device *hid = to_hid_device(dev);
943 struct lg4ff_device_entry *entry;
944 struct lg_drv_data *drv_data;
947 drv_data = hid_get_drvdata(hid);
949 hid_err(hid, "Private driver data not found!\n");
953 entry = drv_data->device_props;
955 hid_err(hid, "Device properties not found!\n");
959 count = scnprintf(buf, PAGE_SIZE, "%u\n", entry->wdata.combine);
963 static ssize_t lg4ff_combine_store(struct device *dev, struct device_attribute *attr,
964 const char *buf, size_t count)
966 struct hid_device *hid = to_hid_device(dev);
967 struct lg4ff_device_entry *entry;
968 struct lg_drv_data *drv_data;
969 u16 combine = simple_strtoul(buf, NULL, 10);
971 drv_data = hid_get_drvdata(hid);
973 hid_err(hid, "Private driver data not found!\n");
977 entry = drv_data->device_props;
979 hid_err(hid, "Device properties not found!\n");
986 entry->wdata.combine = combine;
989 static DEVICE_ATTR(combine_pedals, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, lg4ff_combine_show, lg4ff_combine_store);
991 /* Export the currently set range of the wheel */
992 static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *attr,
995 struct hid_device *hid = to_hid_device(dev);
996 struct lg4ff_device_entry *entry;
997 struct lg_drv_data *drv_data;
1000 drv_data = hid_get_drvdata(hid);
1002 hid_err(hid, "Private driver data not found!\n");
1006 entry = drv_data->device_props;
1008 hid_err(hid, "Device properties not found!\n");
1012 count = scnprintf(buf, PAGE_SIZE, "%u\n", entry->wdata.range);
1016 /* Set range to user specified value, call appropriate function
1017 * according to the type of the wheel */
1018 static ssize_t lg4ff_range_store(struct device *dev, struct device_attribute *attr,
1019 const char *buf, size_t count)
1021 struct hid_device *hid = to_hid_device(dev);
1022 struct lg4ff_device_entry *entry;
1023 struct lg_drv_data *drv_data;
1024 u16 range = simple_strtoul(buf, NULL, 10);
1026 drv_data = hid_get_drvdata(hid);
1028 hid_err(hid, "Private driver data not found!\n");
1032 entry = drv_data->device_props;
1034 hid_err(hid, "Device properties not found!\n");
1039 range = entry->wdata.max_range;
1041 /* Check if the wheel supports range setting
1042 * and that the range is within limits for the wheel */
1043 if (entry->wdata.set_range && range >= entry->wdata.min_range && range <= entry->wdata.max_range) {
1044 entry->wdata.set_range(hid, range);
1045 entry->wdata.range = range;
1050 static DEVICE_ATTR(range, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, lg4ff_range_show, lg4ff_range_store);
1052 static ssize_t lg4ff_real_id_show(struct device *dev, struct device_attribute *attr, char *buf)
1054 struct hid_device *hid = to_hid_device(dev);
1055 struct lg4ff_device_entry *entry;
1056 struct lg_drv_data *drv_data;
1059 drv_data = hid_get_drvdata(hid);
1061 hid_err(hid, "Private driver data not found!\n");
1065 entry = drv_data->device_props;
1067 hid_err(hid, "Device properties not found!\n");
1071 if (!entry->wdata.real_tag || !entry->wdata.real_name) {
1072 hid_err(hid, "NULL pointer to string\n");
1076 count = scnprintf(buf, PAGE_SIZE, "%s: %s\n", entry->wdata.real_tag, entry->wdata.real_name);
1080 static ssize_t lg4ff_real_id_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1082 /* Real ID is a read-only value */
1085 static DEVICE_ATTR(real_id, S_IRUGO, lg4ff_real_id_show, lg4ff_real_id_store);
1087 #ifdef CONFIG_LEDS_CLASS
1088 static void lg4ff_set_leds(struct hid_device *hid, u8 leds)
1090 struct lg_drv_data *drv_data;
1091 struct lg4ff_device_entry *entry;
1092 unsigned long flags;
1095 drv_data = hid_get_drvdata(hid);
1097 hid_err(hid, "Private driver data not found!\n");
1101 entry = drv_data->device_props;
1103 hid_err(hid, "Device properties not found!\n");
1106 value = entry->report->field[0]->value;
1108 spin_lock_irqsave(&entry->report_lock, flags);
1116 hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
1117 spin_unlock_irqrestore(&entry->report_lock, flags);
1120 static void lg4ff_led_set_brightness(struct led_classdev *led_cdev,
1121 enum led_brightness value)
1123 struct device *dev = led_cdev->dev->parent;
1124 struct hid_device *hid = to_hid_device(dev);
1125 struct lg_drv_data *drv_data = hid_get_drvdata(hid);
1126 struct lg4ff_device_entry *entry;
1130 hid_err(hid, "Device data not found.");
1134 entry = drv_data->device_props;
1137 hid_err(hid, "Device properties not found.");
1141 for (i = 0; i < 5; i++) {
1142 if (led_cdev != entry->wdata.led[i])
1144 state = (entry->wdata.led_state >> i) & 1;
1145 if (value == LED_OFF && state) {
1146 entry->wdata.led_state &= ~(1 << i);
1147 lg4ff_set_leds(hid, entry->wdata.led_state);
1148 } else if (value != LED_OFF && !state) {
1149 entry->wdata.led_state |= 1 << i;
1150 lg4ff_set_leds(hid, entry->wdata.led_state);
1156 static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cdev)
1158 struct device *dev = led_cdev->dev->parent;
1159 struct hid_device *hid = to_hid_device(dev);
1160 struct lg_drv_data *drv_data = hid_get_drvdata(hid);
1161 struct lg4ff_device_entry *entry;
1165 hid_err(hid, "Device data not found.");
1169 entry = drv_data->device_props;
1172 hid_err(hid, "Device properties not found.");
1176 for (i = 0; i < 5; i++)
1177 if (led_cdev == entry->wdata.led[i]) {
1178 value = (entry->wdata.led_state >> i) & 1;
1182 return value ? LED_FULL : LED_OFF;
1186 static u16 lg4ff_identify_multimode_wheel(struct hid_device *hid, const u16 reported_product_id, const u16 bcdDevice)
1191 /* identify current mode from USB PID */
1192 for (i = 1; i < ARRAY_SIZE(lg4ff_alternate_modes); i++) {
1193 dbg_hid("Testing whether PID is %X\n", lg4ff_alternate_modes[i].product_id);
1194 if (reported_product_id == lg4ff_alternate_modes[i].product_id)
1198 if (i == ARRAY_SIZE(lg4ff_alternate_modes))
1201 current_mode = BIT(i);
1203 for (i = 0; i < ARRAY_SIZE(lg4ff_main_checklist); i++) {
1204 const u16 mask = lg4ff_main_checklist[i]->mask;
1205 const u16 result = lg4ff_main_checklist[i]->result;
1206 const u16 real_product_id = lg4ff_main_checklist[i]->real_product_id;
1208 if ((current_mode & lg4ff_main_checklist[i]->modes) && \
1209 (bcdDevice & mask) == result) {
1210 dbg_hid("Found wheel with real PID %X whose reported PID is %X\n", real_product_id, reported_product_id);
1211 return real_product_id;
1215 /* No match found. This is either Driving Force or an unknown
1216 * wheel model, do not touch it */
1217 dbg_hid("Wheel with bcdDevice %X was not recognized as multimode wheel, leaving in its current mode\n", bcdDevice);
1221 static int lg4ff_handle_multimode_wheel(struct hid_device *hid, u16 *real_product_id, const u16 bcdDevice)
1223 const u16 reported_product_id = hid->product;
1226 *real_product_id = lg4ff_identify_multimode_wheel(hid, reported_product_id, bcdDevice);
1227 /* Probed wheel is not a multimode wheel */
1228 if (!*real_product_id) {
1229 *real_product_id = reported_product_id;
1230 dbg_hid("Wheel is not a multimode wheel\n");
1231 return LG4FF_MMODE_NOT_MULTIMODE;
1234 /* Switch from "Driving Force" mode to native mode automatically.
1235 * Otherwise keep the wheel in its current mode */
1236 if (reported_product_id == USB_DEVICE_ID_LOGITECH_WHEEL &&
1237 reported_product_id != *real_product_id &&
1238 !lg4ff_no_autoswitch) {
1239 const struct lg4ff_compat_mode_switch *s = lg4ff_get_mode_switch_command(*real_product_id, *real_product_id);
1242 hid_err(hid, "Invalid product id %X\n", *real_product_id);
1243 return LG4FF_MMODE_NOT_MULTIMODE;
1246 ret = lg4ff_switch_compatibility_mode(hid, s);
1248 /* Wheel could not have been switched to native mode,
1249 * leave it in "Driving Force" mode and continue */
1250 hid_err(hid, "Unable to switch wheel mode, errno %d\n", ret);
1251 return LG4FF_MMODE_IS_MULTIMODE;
1253 return LG4FF_MMODE_SWITCHED;
1256 return LG4FF_MMODE_IS_MULTIMODE;
1260 int lg4ff_init(struct hid_device *hid)
1262 struct hid_input *hidinput;
1263 struct input_dev *dev;
1264 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
1265 struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
1266 const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor);
1267 const u16 bcdDevice = le16_to_cpu(udesc->bcdDevice);
1268 const struct lg4ff_multimode_wheel *mmode_wheel = NULL;
1269 struct lg4ff_device_entry *entry;
1270 struct lg_drv_data *drv_data;
1272 int mmode_ret, mmode_idx = -1;
1273 u16 real_product_id;
1275 if (list_empty(&hid->inputs)) {
1276 hid_err(hid, "no inputs found\n");
1279 hidinput = list_entry(hid->inputs.next, struct hid_input, list);
1280 dev = hidinput->input;
1282 /* Check that the report looks ok */
1283 if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
1286 drv_data = hid_get_drvdata(hid);
1288 hid_err(hid, "Cannot add device, private driver data not allocated\n");
1291 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
1294 spin_lock_init(&entry->report_lock);
1295 entry->report = report;
1296 drv_data->device_props = entry;
1298 /* Check if a multimode wheel has been connected and
1299 * handle it appropriately */
1300 mmode_ret = lg4ff_handle_multimode_wheel(hid, &real_product_id, bcdDevice);
1302 /* Wheel has been told to switch to native mode. There is no point in going on
1303 * with the initialization as the wheel will do a USB reset when it switches mode
1305 if (mmode_ret == LG4FF_MMODE_SWITCHED)
1307 else if (mmode_ret < 0) {
1308 hid_err(hid, "Unable to switch device mode during initialization, errno %d\n", mmode_ret);
1313 /* Check what wheel has been connected */
1314 for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) {
1315 if (hid->product == lg4ff_devices[i].product_id) {
1316 dbg_hid("Found compatible device, product ID %04X\n", lg4ff_devices[i].product_id);
1321 if (i == ARRAY_SIZE(lg4ff_devices)) {
1322 hid_err(hid, "This device is flagged to be handled by the lg4ff module but this module does not know how to handle it. "
1323 "Please report this as a bug to LKML, Simon Wood <simon@mungewell.org> or "
1324 "Michal Maly <madcatxster@devoid-pointer.net>\n");
1329 if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) {
1330 for (mmode_idx = 0; mmode_idx < ARRAY_SIZE(lg4ff_multimode_wheels); mmode_idx++) {
1331 if (real_product_id == lg4ff_multimode_wheels[mmode_idx].product_id)
1335 if (mmode_idx == ARRAY_SIZE(lg4ff_multimode_wheels)) {
1336 hid_err(hid, "Device product ID %X is not listed as a multimode wheel", real_product_id);
1342 /* Set supported force feedback capabilities */
1343 for (j = 0; lg4ff_devices[i].ff_effects[j] >= 0; j++)
1344 set_bit(lg4ff_devices[i].ff_effects[j], dev->ffbit);
1346 error = input_ff_create_memless(dev, NULL, lg4ff_play);
1351 /* Initialize device properties */
1352 if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) {
1353 BUG_ON(mmode_idx == -1);
1354 mmode_wheel = &lg4ff_multimode_wheels[mmode_idx];
1356 lg4ff_init_wheel_data(&entry->wdata, &lg4ff_devices[i], mmode_wheel, real_product_id);
1358 /* Check if autocentering is available and
1359 * set the centering force to zero by default */
1360 if (test_bit(FF_AUTOCENTER, dev->ffbit)) {
1361 /* Formula Force EX expects different autocentering command */
1362 if ((bcdDevice >> 8) == LG4FF_FFEX_REV_MAJ &&
1363 (bcdDevice & 0xff) == LG4FF_FFEX_REV_MIN)
1364 dev->ff->set_autocenter = lg4ff_set_autocenter_ffex;
1366 dev->ff->set_autocenter = lg4ff_set_autocenter_default;
1368 dev->ff->set_autocenter(dev, 0);
1371 /* Create sysfs interface */
1372 error = device_create_file(&hid->dev, &dev_attr_combine_pedals);
1374 hid_warn(hid, "Unable to create sysfs interface for \"combine\", errno %d\n", error);
1375 error = device_create_file(&hid->dev, &dev_attr_range);
1377 hid_warn(hid, "Unable to create sysfs interface for \"range\", errno %d\n", error);
1378 if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) {
1379 error = device_create_file(&hid->dev, &dev_attr_real_id);
1381 hid_warn(hid, "Unable to create sysfs interface for \"real_id\", errno %d\n", error);
1382 error = device_create_file(&hid->dev, &dev_attr_alternate_modes);
1384 hid_warn(hid, "Unable to create sysfs interface for \"alternate_modes\", errno %d\n", error);
1386 dbg_hid("sysfs interface created\n");
1388 /* Set the maximum range to start with */
1389 entry->wdata.range = entry->wdata.max_range;
1390 if (entry->wdata.set_range)
1391 entry->wdata.set_range(hid, entry->wdata.range);
1393 #ifdef CONFIG_LEDS_CLASS
1394 /* register led subsystem - G27/G29 only */
1395 entry->wdata.led_state = 0;
1396 for (j = 0; j < 5; j++)
1397 entry->wdata.led[j] = NULL;
1399 if (lg4ff_devices[i].product_id == USB_DEVICE_ID_LOGITECH_G27_WHEEL ||
1400 lg4ff_devices[i].product_id == USB_DEVICE_ID_LOGITECH_G29_WHEEL) {
1401 struct led_classdev *led;
1405 lg4ff_set_leds(hid, 0);
1407 name_sz = strlen(dev_name(&hid->dev)) + 8;
1409 for (j = 0; j < 5; j++) {
1410 led = kzalloc(sizeof(struct led_classdev)+name_sz, GFP_KERNEL);
1412 hid_err(hid, "can't allocate memory for LED %d\n", j);
1416 name = (void *)(&led[1]);
1417 snprintf(name, name_sz, "%s::RPM%d", dev_name(&hid->dev), j+1);
1419 led->brightness = 0;
1420 led->max_brightness = 1;
1421 led->brightness_get = lg4ff_led_get_brightness;
1422 led->brightness_set = lg4ff_led_set_brightness;
1424 entry->wdata.led[j] = led;
1425 error = led_classdev_register(&hid->dev, led);
1428 hid_err(hid, "failed to register LED %d. Aborting.\n", j);
1430 /* Deregister LEDs (if any) */
1431 for (j = 0; j < 5; j++) {
1432 led = entry->wdata.led[j];
1433 entry->wdata.led[j] = NULL;
1436 led_classdev_unregister(led);
1439 goto out; /* Let the driver continue without LEDs */
1445 hid_info(hid, "Force feedback support for Logitech Gaming Wheels\n");
1449 drv_data->device_props = NULL;
1454 int lg4ff_deinit(struct hid_device *hid)
1456 struct lg4ff_device_entry *entry;
1457 struct lg_drv_data *drv_data;
1459 drv_data = hid_get_drvdata(hid);
1461 hid_err(hid, "Error while deinitializing device, no private driver data.\n");
1464 entry = drv_data->device_props;
1466 goto out; /* Nothing more to do */
1468 /* Multimode devices will have at least the "MODE_NATIVE" bit set */
1469 if (entry->wdata.alternate_modes) {
1470 device_remove_file(&hid->dev, &dev_attr_real_id);
1471 device_remove_file(&hid->dev, &dev_attr_alternate_modes);
1474 device_remove_file(&hid->dev, &dev_attr_combine_pedals);
1475 device_remove_file(&hid->dev, &dev_attr_range);
1476 #ifdef CONFIG_LEDS_CLASS
1479 struct led_classdev *led;
1481 /* Deregister LEDs (if any) */
1482 for (j = 0; j < 5; j++) {
1484 led = entry->wdata.led[j];
1485 entry->wdata.led[j] = NULL;
1488 led_classdev_unregister(led);
1493 drv_data->device_props = NULL;
1497 dbg_hid("Device successfully unregistered\n");