diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/misc/uinput.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 856936247500..883f045f37df 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
@@ -311,7 +311,14 @@ static int uinput_open(struct inode *inode, struct file *file) | |||
311 | static int uinput_validate_absbits(struct input_dev *dev) | 311 | static int uinput_validate_absbits(struct input_dev *dev) |
312 | { | 312 | { |
313 | unsigned int cnt; | 313 | unsigned int cnt; |
314 | int retval = 0; | 314 | int nslot; |
315 | |||
316 | if (!test_bit(EV_ABS, dev->evbit)) | ||
317 | return 0; | ||
318 | |||
319 | /* | ||
320 | * Check if absmin/absmax/absfuzz/absflat are sane. | ||
321 | */ | ||
315 | 322 | ||
316 | for (cnt = 0; cnt < ABS_CNT; cnt++) { | 323 | for (cnt = 0; cnt < ABS_CNT; cnt++) { |
317 | int min, max; | 324 | int min, max; |
@@ -327,8 +334,7 @@ static int uinput_validate_absbits(struct input_dev *dev) | |||
327 | UINPUT_NAME, cnt, | 334 | UINPUT_NAME, cnt, |
328 | input_abs_get_min(dev, cnt), | 335 | input_abs_get_min(dev, cnt), |
329 | input_abs_get_max(dev, cnt)); | 336 | input_abs_get_max(dev, cnt)); |
330 | retval = -EINVAL; | 337 | return -EINVAL; |
331 | break; | ||
332 | } | 338 | } |
333 | 339 | ||
334 | if (input_abs_get_flat(dev, cnt) > | 340 | if (input_abs_get_flat(dev, cnt) > |
@@ -340,11 +346,18 @@ static int uinput_validate_absbits(struct input_dev *dev) | |||
340 | input_abs_get_flat(dev, cnt), | 346 | input_abs_get_flat(dev, cnt), |
341 | input_abs_get_min(dev, cnt), | 347 | input_abs_get_min(dev, cnt), |
342 | input_abs_get_max(dev, cnt)); | 348 | input_abs_get_max(dev, cnt)); |
343 | retval = -EINVAL; | 349 | return -EINVAL; |
344 | break; | ||
345 | } | 350 | } |
346 | } | 351 | } |
347 | return retval; | 352 | |
353 | if (test_bit(ABS_MT_SLOT, dev->absbit)) { | ||
354 | nslot = input_abs_get_max(dev, ABS_MT_SLOT) + 1; | ||
355 | input_mt_init_slots(dev, nslot, 0); | ||
356 | } else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) { | ||
357 | input_set_events_per_packet(dev, 60); | ||
358 | } | ||
359 | |||
360 | return 0; | ||
348 | } | 361 | } |
349 | 362 | ||
350 | static int uinput_allocate_device(struct uinput_device *udev) | 363 | static int uinput_allocate_device(struct uinput_device *udev) |
@@ -410,19 +423,9 @@ static int uinput_setup_device(struct uinput_device *udev, | |||
410 | input_abs_set_flat(dev, i, user_dev->absflat[i]); | 423 | input_abs_set_flat(dev, i, user_dev->absflat[i]); |
411 | } | 424 | } |
412 | 425 | ||
413 | /* check if absmin/absmax/absfuzz/absflat are filled as | 426 | retval = uinput_validate_absbits(dev); |
414 | * told in Documentation/input/input-programming.txt */ | 427 | if (retval < 0) |
415 | if (test_bit(EV_ABS, dev->evbit)) { | 428 | goto exit; |
416 | retval = uinput_validate_absbits(dev); | ||
417 | if (retval < 0) | ||
418 | goto exit; | ||
419 | if (test_bit(ABS_MT_SLOT, dev->absbit)) { | ||
420 | int nslot = input_abs_get_max(dev, ABS_MT_SLOT) + 1; | ||
421 | input_mt_init_slots(dev, nslot, 0); | ||
422 | } else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) { | ||
423 | input_set_events_per_packet(dev, 60); | ||
424 | } | ||
425 | } | ||
426 | 429 | ||
427 | udev->state = UIST_SETUP_COMPLETE; | 430 | udev->state = UIST_SETUP_COMPLETE; |
428 | retval = count; | 431 | retval = count; |