aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Malý <madcatxster@devoid-pointer.net>2015-04-08 16:56:50 -0400
committerJiri Kosina <jkosina@suse.cz>2015-05-07 10:27:17 -0400
commit5d9d60ad308c867b271cc03233f2c93a0f5d80ec (patch)
tree292aa90e448fc19561e2a9ca84a2d34ecbc50fc1
parentc28abd8c423b85e2d8be8ed33984a3ad966f1c83 (diff)
HID: hid-lg4ff: Constify members of lg4ff_device_entry
Constify those members of lg4ff_device_entry struct whose value is not supposed to change. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-lg4ff.c54
1 files changed, 39 insertions, 15 deletions
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index d27b2101c7a2..dcaf481ddee0 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -72,18 +72,18 @@ static void lg4ff_set_range_dfp(struct hid_device *hid, u16 range);
72static void lg4ff_set_range_g25(struct hid_device *hid, u16 range); 72static void lg4ff_set_range_g25(struct hid_device *hid, u16 range);
73 73
74struct lg4ff_wheel_data { 74struct lg4ff_wheel_data {
75 u32 product_id; 75 const u32 product_id;
76 u16 range; 76 u16 range;
77 u16 min_range; 77 const u16 min_range;
78 u16 max_range; 78 const u16 max_range;
79#ifdef CONFIG_LEDS_CLASS 79#ifdef CONFIG_LEDS_CLASS
80 u8 led_state; 80 u8 led_state;
81 struct led_classdev *led[5]; 81 struct led_classdev *led[5];
82#endif 82#endif
83 u32 alternate_modes; 83 const u32 alternate_modes;
84 const char *real_tag; 84 const char * const real_tag;
85 const char *real_name; 85 const char * const real_name;
86 u16 real_product_id; 86 const u16 real_product_id;
87 87
88 void (*set_range)(struct hid_device *hid, u16 range); 88 void (*set_range)(struct hid_device *hid, u16 range);
89}; 89};
@@ -300,6 +300,34 @@ int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field,
300 } 300 }
301} 301}
302 302
303static void lg4ff_init_wheel_data(struct lg4ff_wheel_data * const wdata, const struct lg4ff_wheel *wheel,
304 const struct lg4ff_multimode_wheel *mmode_wheel,
305 const u16 real_product_id)
306{
307 u32 alternate_modes = 0;
308 const char *real_tag = NULL;
309 const char *real_name = NULL;
310
311 if (mmode_wheel) {
312 alternate_modes = mmode_wheel->alternate_modes;
313 real_tag = mmode_wheel->real_tag;
314 real_name = mmode_wheel->real_name;
315 }
316
317 {
318 struct lg4ff_wheel_data t_wdata = { .product_id = wheel->product_id,
319 .real_product_id = real_product_id,
320 .min_range = wheel->min_range,
321 .max_range = wheel->max_range,
322 .set_range = wheel->set_range,
323 .alternate_modes = alternate_modes,
324 .real_tag = real_tag,
325 .real_name = real_name };
326
327 memcpy(wdata, &t_wdata, sizeof(t_wdata));
328 }
329}
330
303static int lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *effect) 331static int lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *effect)
304{ 332{
305 struct hid_device *hid = input_get_drvdata(dev); 333 struct hid_device *hid = input_get_drvdata(dev);
@@ -1102,6 +1130,7 @@ int lg4ff_init(struct hid_device *hid)
1102 struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 1130 struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
1103 const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor); 1131 const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor);
1104 const u16 bcdDevice = le16_to_cpu(udesc->bcdDevice); 1132 const u16 bcdDevice = le16_to_cpu(udesc->bcdDevice);
1133 const struct lg4ff_multimode_wheel *mmode_wheel = NULL;
1105 struct lg4ff_device_entry *entry; 1134 struct lg4ff_device_entry *entry;
1106 struct lg_drv_data *drv_data; 1135 struct lg_drv_data *drv_data;
1107 int error, i, j; 1136 int error, i, j;
@@ -1177,17 +1206,12 @@ int lg4ff_init(struct hid_device *hid)
1177 if (error) 1206 if (error)
1178 goto err_init; 1207 goto err_init;
1179 1208
1180 entry->wdata.product_id = lg4ff_devices[i].product_id; 1209 /* Initialize device properties */
1181 entry->wdata.real_product_id = real_product_id;
1182 entry->wdata.min_range = lg4ff_devices[i].min_range;
1183 entry->wdata.max_range = lg4ff_devices[i].max_range;
1184 entry->wdata.set_range = lg4ff_devices[i].set_range;
1185 if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) { 1210 if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) {
1186 BUG_ON(mmode_idx == -1); 1211 BUG_ON(mmode_idx == -1);
1187 entry->wdata.alternate_modes = lg4ff_multimode_wheels[mmode_idx].alternate_modes; 1212 mmode_wheel = &lg4ff_multimode_wheels[mmode_idx];
1188 entry->wdata.real_tag = lg4ff_multimode_wheels[mmode_idx].real_tag;
1189 entry->wdata.real_name = lg4ff_multimode_wheels[mmode_idx].real_name;
1190 } 1213 }
1214 lg4ff_init_wheel_data(&entry->wdata, &lg4ff_devices[i], mmode_wheel, real_product_id);
1191 1215
1192 /* Check if autocentering is available and 1216 /* Check if autocentering is available and
1193 * set the centering force to zero by default */ 1217 * set the centering force to zero by default */