aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-09-13 02:12:08 -0400
committerJiri Kosina <jkosina@suse.cz>2012-09-17 07:09:02 -0400
commit832fbeaef446a7024c5e0f19b7122100a7b1003d (patch)
tree352a2d3b0247a9cddb30688626c5c4cc96382384 /drivers/hid
parent372d297b8c8968d7a05e4a63911bea8ec335e031 (diff)
HID: lenovo-tpkbd: Remove unnecessary casts of void pointers
container_of() never returns NULL, thus also remove the NULL checking for it. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-lenovo-tpkbd.c147
1 files changed, 33 insertions, 114 deletions
diff --git a/drivers/hid/hid-lenovo-tpkbd.c b/drivers/hid/hid-lenovo-tpkbd.c
index 77d2df04c97b..32bfcc4808b7 100644
--- a/drivers/hid/hid-lenovo-tpkbd.c
+++ b/drivers/hid/hid-lenovo-tpkbd.c
@@ -56,9 +56,8 @@ static int tpkbd_input_mapping(struct hid_device *hdev,
56static int tpkbd_features_set(struct hid_device *hdev) 56static int tpkbd_features_set(struct hid_device *hdev)
57{ 57{
58 struct hid_report *report; 58 struct hid_report *report;
59 struct tpkbd_data_pointer *data_pointer; 59 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
60 60
61 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
62 report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[4]; 61 report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[4];
63 62
64 report->field[0]->value[0] = data_pointer->press_to_select ? 0x01 : 0x02; 63 report->field[0]->value[0] = data_pointer->press_to_select ? 0x01 : 0x02;
@@ -77,14 +76,8 @@ static ssize_t pointer_press_to_select_show(struct device *dev,
77 struct device_attribute *attr, 76 struct device_attribute *attr,
78 char *buf) 77 char *buf)
79{ 78{
80 struct hid_device *hdev; 79 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
81 struct tpkbd_data_pointer *data_pointer; 80 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
82
83 hdev = container_of(dev, struct hid_device, dev);
84 if (hdev == NULL)
85 return -ENODEV;
86
87 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
88 81
89 return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_to_select); 82 return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_to_select);
90} 83}
@@ -94,16 +87,10 @@ static ssize_t pointer_press_to_select_store(struct device *dev,
94 const char *buf, 87 const char *buf,
95 size_t count) 88 size_t count)
96{ 89{
97 struct hid_device *hdev; 90 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
98 struct tpkbd_data_pointer *data_pointer; 91 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
99 int value; 92 int value;
100 93
101 hdev = container_of(dev, struct hid_device, dev);
102 if (hdev == NULL)
103 return -ENODEV;
104
105 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
106
107 if (kstrtoint(buf, 10, &value)) 94 if (kstrtoint(buf, 10, &value))
108 return -EINVAL; 95 return -EINVAL;
109 if (value < 0 || value > 1) 96 if (value < 0 || value > 1)
@@ -119,14 +106,8 @@ static ssize_t pointer_dragging_show(struct device *dev,
119 struct device_attribute *attr, 106 struct device_attribute *attr,
120 char *buf) 107 char *buf)
121{ 108{
122 struct hid_device *hdev; 109 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
123 struct tpkbd_data_pointer *data_pointer; 110 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
124
125 hdev = container_of(dev, struct hid_device, dev);
126 if (hdev == NULL)
127 return -ENODEV;
128
129 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
130 111
131 return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->dragging); 112 return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->dragging);
132} 113}
@@ -136,16 +117,10 @@ static ssize_t pointer_dragging_store(struct device *dev,
136 const char *buf, 117 const char *buf,
137 size_t count) 118 size_t count)
138{ 119{
139 struct hid_device *hdev; 120 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
140 struct tpkbd_data_pointer *data_pointer; 121 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
141 int value; 122 int value;
142 123
143 hdev = container_of(dev, struct hid_device, dev);
144 if (hdev == NULL)
145 return -ENODEV;
146
147 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
148
149 if (kstrtoint(buf, 10, &value)) 124 if (kstrtoint(buf, 10, &value))
150 return -EINVAL; 125 return -EINVAL;
151 if (value < 0 || value > 1) 126 if (value < 0 || value > 1)
@@ -161,14 +136,8 @@ static ssize_t pointer_release_to_select_show(struct device *dev,
161 struct device_attribute *attr, 136 struct device_attribute *attr,
162 char *buf) 137 char *buf)
163{ 138{
164 struct hid_device *hdev; 139 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
165 struct tpkbd_data_pointer *data_pointer; 140 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
166
167 hdev = container_of(dev, struct hid_device, dev);
168 if (hdev == NULL)
169 return -ENODEV;
170
171 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
172 141
173 return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->release_to_select); 142 return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->release_to_select);
174} 143}
@@ -178,16 +147,10 @@ static ssize_t pointer_release_to_select_store(struct device *dev,
178 const char *buf, 147 const char *buf,
179 size_t count) 148 size_t count)
180{ 149{
181 struct hid_device *hdev; 150 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
182 struct tpkbd_data_pointer *data_pointer; 151 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
183 int value; 152 int value;
184 153
185 hdev = container_of(dev, struct hid_device, dev);
186 if (hdev == NULL)
187 return -ENODEV;
188
189 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
190
191 if (kstrtoint(buf, 10, &value)) 154 if (kstrtoint(buf, 10, &value))
192 return -EINVAL; 155 return -EINVAL;
193 if (value < 0 || value > 1) 156 if (value < 0 || value > 1)
@@ -203,14 +166,8 @@ static ssize_t pointer_select_right_show(struct device *dev,
203 struct device_attribute *attr, 166 struct device_attribute *attr,
204 char *buf) 167 char *buf)
205{ 168{
206 struct hid_device *hdev; 169 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
207 struct tpkbd_data_pointer *data_pointer; 170 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
208
209 hdev = container_of(dev, struct hid_device, dev);
210 if (hdev == NULL)
211 return -ENODEV;
212
213 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
214 171
215 return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->select_right); 172 return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->select_right);
216} 173}
@@ -220,16 +177,10 @@ static ssize_t pointer_select_right_store(struct device *dev,
220 const char *buf, 177 const char *buf,
221 size_t count) 178 size_t count)
222{ 179{
223 struct hid_device *hdev; 180 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
224 struct tpkbd_data_pointer *data_pointer; 181 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
225 int value; 182 int value;
226 183
227 hdev = container_of(dev, struct hid_device, dev);
228 if (hdev == NULL)
229 return -ENODEV;
230
231 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
232
233 if (kstrtoint(buf, 10, &value)) 184 if (kstrtoint(buf, 10, &value))
234 return -EINVAL; 185 return -EINVAL;
235 if (value < 0 || value > 1) 186 if (value < 0 || value > 1)
@@ -245,14 +196,8 @@ static ssize_t pointer_sensitivity_show(struct device *dev,
245 struct device_attribute *attr, 196 struct device_attribute *attr,
246 char *buf) 197 char *buf)
247{ 198{
248 struct hid_device *hdev; 199 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
249 struct tpkbd_data_pointer *data_pointer; 200 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
250
251 hdev = container_of(dev, struct hid_device, dev);
252 if (hdev == NULL)
253 return -ENODEV;
254
255 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
256 201
257 return snprintf(buf, PAGE_SIZE, "%u\n", 202 return snprintf(buf, PAGE_SIZE, "%u\n",
258 data_pointer->sensitivity); 203 data_pointer->sensitivity);
@@ -263,16 +208,10 @@ static ssize_t pointer_sensitivity_store(struct device *dev,
263 const char *buf, 208 const char *buf,
264 size_t count) 209 size_t count)
265{ 210{
266 struct hid_device *hdev; 211 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
267 struct tpkbd_data_pointer *data_pointer; 212 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
268 int value; 213 int value;
269 214
270 hdev = container_of(dev, struct hid_device, dev);
271 if (hdev == NULL)
272 return -ENODEV;
273
274 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
275
276 if (kstrtoint(buf, 10, &value) || value < 1 || value > 255) 215 if (kstrtoint(buf, 10, &value) || value < 1 || value > 255)
277 return -EINVAL; 216 return -EINVAL;
278 217
@@ -286,14 +225,10 @@ static ssize_t pointer_press_speed_show(struct device *dev,
286 struct device_attribute *attr, 225 struct device_attribute *attr,
287 char *buf) 226 char *buf)
288{ 227{
289 struct hid_device *hdev; 228 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
290 struct tpkbd_data_pointer *data_pointer; 229 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
291 230
292 hdev = container_of(dev, struct hid_device, dev); 231 data_pointer = hid_get_drvdata(hdev);
293 if (hdev == NULL)
294 return -ENODEV;
295
296 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
297 232
298 return snprintf(buf, PAGE_SIZE, "%u\n", 233 return snprintf(buf, PAGE_SIZE, "%u\n",
299 data_pointer->press_speed); 234 data_pointer->press_speed);
@@ -304,16 +239,10 @@ static ssize_t pointer_press_speed_store(struct device *dev,
304 const char *buf, 239 const char *buf,
305 size_t count) 240 size_t count)
306{ 241{
307 struct hid_device *hdev; 242 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
308 struct tpkbd_data_pointer *data_pointer; 243 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
309 int value; 244 int value;
310 245
311 hdev = container_of(dev, struct hid_device, dev);
312 if (hdev == NULL)
313 return -ENODEV;
314
315 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
316
317 if (kstrtoint(buf, 10, &value) || value < 1 || value > 255) 246 if (kstrtoint(buf, 10, &value) || value < 1 || value > 255)
318 return -EINVAL; 247 return -EINVAL;
319 248
@@ -370,15 +299,11 @@ static const struct attribute_group tpkbd_attr_group_pointer = {
370static enum led_brightness tpkbd_led_brightness_get( 299static enum led_brightness tpkbd_led_brightness_get(
371 struct led_classdev *led_cdev) 300 struct led_classdev *led_cdev)
372{ 301{
373 struct device *dev; 302 struct device *dev = led_cdev->dev->parent;
374 struct hid_device *hdev; 303 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
375 struct tpkbd_data_pointer *data_pointer; 304 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
376 int led_nr = 0; 305 int led_nr = 0;
377 306
378 dev = led_cdev->dev->parent;
379 hdev = container_of(dev, struct hid_device, dev);
380 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
381
382 if (led_cdev == &data_pointer->led_micmute) 307 if (led_cdev == &data_pointer->led_micmute)
383 led_nr = 1; 308 led_nr = 1;
384 309
@@ -390,16 +315,12 @@ static enum led_brightness tpkbd_led_brightness_get(
390static void tpkbd_led_brightness_set(struct led_classdev *led_cdev, 315static void tpkbd_led_brightness_set(struct led_classdev *led_cdev,
391 enum led_brightness value) 316 enum led_brightness value)
392{ 317{
393 struct device *dev; 318 struct device *dev = led_cdev->dev->parent;
394 struct hid_device *hdev; 319 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
320 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
395 struct hid_report *report; 321 struct hid_report *report;
396 struct tpkbd_data_pointer *data_pointer;
397 int led_nr = 0; 322 int led_nr = 0;
398 323
399 dev = led_cdev->dev->parent;
400 hdev = container_of(dev, struct hid_device, dev);
401 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
402
403 if (led_cdev == &data_pointer->led_micmute) 324 if (led_cdev == &data_pointer->led_micmute)
404 led_nr = 1; 325 led_nr = 1;
405 326
@@ -508,13 +429,11 @@ err_free:
508 429
509static void tpkbd_remove_tp(struct hid_device *hdev) 430static void tpkbd_remove_tp(struct hid_device *hdev)
510{ 431{
511 struct tpkbd_data_pointer *data_pointer; 432 struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
512 433
513 sysfs_remove_group(&hdev->dev.kobj, 434 sysfs_remove_group(&hdev->dev.kobj,
514 &tpkbd_attr_group_pointer); 435 &tpkbd_attr_group_pointer);
515 436
516 data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
517
518 led_classdev_unregister(&data_pointer->led_micmute); 437 led_classdev_unregister(&data_pointer->led_micmute);
519 led_classdev_unregister(&data_pointer->led_mute); 438 led_classdev_unregister(&data_pointer->led_mute);
520 439