aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2011-10-08 17:20:17 -0400
committerJiri Kosina <jkosina@suse.cz>2011-10-08 17:20:17 -0400
commit3797ef6b6bc041755318917855d63879679c6dd9 (patch)
tree99ed2c53cd3caa16a131309fc222f93b82a0bf94
parentf554ff80339b4005856e6a86454d6ea2bb962ee5 (diff)
HID: wacom: Set input bits before registration
We shouldn't change the event flags of input devices after they get registered. Otherwise, udev will not get notified of these flags and cannot setup the devices properly. This fixes the probing to set the input event flags on the input_mapped callback instead of the probe function. Reported-by: Bastien Nocera <hadess@hadess.net> Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Tested-by: Bastien Nocera <hadess@hadess.net> Signed-off-by: Bastien Nocera <hadess@hadess.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-wacom.c76
1 files changed, 41 insertions, 35 deletions
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index a597039d0755..519f56c787bb 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -304,11 +304,49 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
304 return 1; 304 return 1;
305} 305}
306 306
307static int wacom_input_mapped(struct hid_device *hdev, struct hid_input *hi,
308 struct hid_field *field, struct hid_usage *usage, unsigned long **bit,
309 int *max)
310{
311 struct input_dev *input = hi->input;
312
313 /* Basics */
314 input->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_REL);
315
316 __set_bit(REL_WHEEL, input->relbit);
317
318 __set_bit(BTN_TOOL_PEN, input->keybit);
319 __set_bit(BTN_TOUCH, input->keybit);
320 __set_bit(BTN_STYLUS, input->keybit);
321 __set_bit(BTN_STYLUS2, input->keybit);
322 __set_bit(BTN_LEFT, input->keybit);
323 __set_bit(BTN_RIGHT, input->keybit);
324 __set_bit(BTN_MIDDLE, input->keybit);
325
326 /* Pad */
327 input->evbit[0] |= BIT(EV_MSC);
328
329 __set_bit(MSC_SERIAL, input->mscbit);
330
331 __set_bit(BTN_0, input->keybit);
332 __set_bit(BTN_1, input->keybit);
333 __set_bit(BTN_TOOL_FINGER, input->keybit);
334
335 /* Distance, rubber and mouse */
336 __set_bit(BTN_TOOL_RUBBER, input->keybit);
337 __set_bit(BTN_TOOL_MOUSE, input->keybit);
338
339 input_set_abs_params(input, ABS_X, 0, 16704, 4, 0);
340 input_set_abs_params(input, ABS_Y, 0, 12064, 4, 0);
341 input_set_abs_params(input, ABS_PRESSURE, 0, 511, 0, 0);
342 input_set_abs_params(input, ABS_DISTANCE, 0, 32, 0, 0);
343
344 return 0;
345}
346
307static int wacom_probe(struct hid_device *hdev, 347static int wacom_probe(struct hid_device *hdev,
308 const struct hid_device_id *id) 348 const struct hid_device_id *id)
309{ 349{
310 struct hid_input *hidinput;
311 struct input_dev *input;
312 struct wacom_data *wdata; 350 struct wacom_data *wdata;
313 int ret; 351 int ret;
314 352
@@ -370,39 +408,6 @@ static int wacom_probe(struct hid_device *hdev,
370 goto err_ac; 408 goto err_ac;
371 } 409 }
372#endif 410#endif
373 hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
374 input = hidinput->input;
375
376 /* Basics */
377 input->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_REL);
378
379 __set_bit(REL_WHEEL, input->relbit);
380
381 __set_bit(BTN_TOOL_PEN, input->keybit);
382 __set_bit(BTN_TOUCH, input->keybit);
383 __set_bit(BTN_STYLUS, input->keybit);
384 __set_bit(BTN_STYLUS2, input->keybit);
385 __set_bit(BTN_LEFT, input->keybit);
386 __set_bit(BTN_RIGHT, input->keybit);
387 __set_bit(BTN_MIDDLE, input->keybit);
388
389 /* Pad */
390 input->evbit[0] |= BIT(EV_MSC);
391
392 __set_bit(MSC_SERIAL, input->mscbit);
393
394 __set_bit(BTN_0, input->keybit);
395 __set_bit(BTN_1, input->keybit);
396 __set_bit(BTN_TOOL_FINGER, input->keybit);
397
398 /* Distance, rubber and mouse */
399 __set_bit(BTN_TOOL_RUBBER, input->keybit);
400 __set_bit(BTN_TOOL_MOUSE, input->keybit);
401
402 input_set_abs_params(input, ABS_X, 0, 16704, 4, 0);
403 input_set_abs_params(input, ABS_Y, 0, 12064, 4, 0);
404 input_set_abs_params(input, ABS_PRESSURE, 0, 511, 0, 0);
405 input_set_abs_params(input, ABS_DISTANCE, 0, 32, 0, 0);
406 411
407 return 0; 412 return 0;
408 413
@@ -446,6 +451,7 @@ static struct hid_driver wacom_driver = {
446 .probe = wacom_probe, 451 .probe = wacom_probe,
447 .remove = wacom_remove, 452 .remove = wacom_remove,
448 .raw_event = wacom_raw_event, 453 .raw_event = wacom_raw_event,
454 .input_mapped = wacom_input_mapped,
449}; 455};
450 456
451static int __init wacom_init(void) 457static int __init wacom_init(void)