Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lis3lv02d: switch to using input device polling mode

Now that instances of input_dev support polling mode natively,
we no longer need to create input_polled_dev instance.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Link: https://lore.kernel.org/r/20191002215658.GA134561@dtor-ws
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dmitry Torokhov and committed by
Greg Kroah-Hartman
bb4d6e0e fa6f90f3

+46 -39
-1
drivers/misc/Kconfig
··· 8 8 config SENSORS_LIS3LV02D 9 9 tristate 10 10 depends on INPUT 11 - select INPUT_POLLDEV 12 11 13 12 config AD525X_DPOT 14 13 tristate "Analog Devices Digital Potentiometers"
+44 -36
drivers/misc/lis3lv02d/lis3lv02d.c
··· 16 16 #include <linux/types.h> 17 17 #include <linux/platform_device.h> 18 18 #include <linux/interrupt.h> 19 - #include <linux/input-polldev.h> 19 + #include <linux/input.h> 20 20 #include <linux/delay.h> 21 21 #include <linux/wait.h> 22 22 #include <linux/poll.h> ··· 434 434 EXPORT_SYMBOL_GPL(lis3lv02d_poweron); 435 435 436 436 437 - static void lis3lv02d_joystick_poll(struct input_polled_dev *pidev) 437 + static void lis3lv02d_joystick_poll(struct input_dev *input) 438 438 { 439 - struct lis3lv02d *lis3 = pidev->private; 439 + struct lis3lv02d *lis3 = input_get_drvdata(input); 440 440 int x, y, z; 441 441 442 442 mutex_lock(&lis3->mutex); 443 443 lis3lv02d_get_xyz(lis3, &x, &y, &z); 444 - input_report_abs(pidev->input, ABS_X, x); 445 - input_report_abs(pidev->input, ABS_Y, y); 446 - input_report_abs(pidev->input, ABS_Z, z); 447 - input_sync(pidev->input); 444 + input_report_abs(input, ABS_X, x); 445 + input_report_abs(input, ABS_Y, y); 446 + input_report_abs(input, ABS_Z, z); 447 + input_sync(input); 448 448 mutex_unlock(&lis3->mutex); 449 449 } 450 450 451 - static void lis3lv02d_joystick_open(struct input_polled_dev *pidev) 451 + static int lis3lv02d_joystick_open(struct input_dev *input) 452 452 { 453 - struct lis3lv02d *lis3 = pidev->private; 453 + struct lis3lv02d *lis3 = input_get_drvdata(input); 454 454 455 455 if (lis3->pm_dev) 456 456 pm_runtime_get_sync(lis3->pm_dev); ··· 461 461 * Update coordinates for the case where poll interval is 0 and 462 462 * the chip in running purely under interrupt control 463 463 */ 464 - lis3lv02d_joystick_poll(pidev); 464 + lis3lv02d_joystick_poll(input); 465 + 466 + return 0; 465 467 } 466 468 467 - static void lis3lv02d_joystick_close(struct input_polled_dev *pidev) 469 + static void lis3lv02d_joystick_close(struct input_dev *input) 468 470 { 469 - struct lis3lv02d *lis3 = pidev->private; 471 + struct lis3lv02d *lis3 = input_get_drvdata(input); 470 472 471 473 atomic_set(&lis3->wake_thread, 0); 472 474 if (lis3->pm_dev) ··· 499 497 500 498 static void lis302dl_interrupt_handle_click(struct lis3lv02d *lis3) 501 499 { 502 - struct input_dev *dev = lis3->idev->input; 500 + struct input_dev *dev = lis3->idev; 503 501 u8 click_src; 504 502 505 503 mutex_lock(&lis3->mutex); ··· 679 677 if (lis3->idev) 680 678 return -EINVAL; 681 679 682 - lis3->idev = input_allocate_polled_device(); 683 - if (!lis3->idev) 680 + input_dev = input_allocate_device(); 681 + if (!input_dev) 684 682 return -ENOMEM; 685 - 686 - lis3->idev->poll = lis3lv02d_joystick_poll; 687 - lis3->idev->open = lis3lv02d_joystick_open; 688 - lis3->idev->close = lis3lv02d_joystick_close; 689 - lis3->idev->poll_interval = MDPS_POLL_INTERVAL; 690 - lis3->idev->poll_interval_min = MDPS_POLL_MIN; 691 - lis3->idev->poll_interval_max = MDPS_POLL_MAX; 692 - lis3->idev->private = lis3; 693 - input_dev = lis3->idev->input; 694 683 695 684 input_dev->name = "ST LIS3LV02DL Accelerometer"; 696 685 input_dev->phys = DRIVER_NAME "/input0"; ··· 689 696 input_dev->id.vendor = 0; 690 697 input_dev->dev.parent = &lis3->pdev->dev; 691 698 692 - set_bit(EV_ABS, input_dev->evbit); 699 + input_dev->open = lis3lv02d_joystick_open; 700 + input_dev->close = lis3lv02d_joystick_close; 701 + 693 702 max_val = (lis3->mdps_max_val * lis3->scale) / LIS3_ACCURACY; 694 703 if (lis3->whoami == WAI_12B) { 695 704 fuzz = LIS3_DEFAULT_FUZZ_12B; ··· 707 712 input_set_abs_params(input_dev, ABS_Y, -max_val, max_val, fuzz, flat); 708 713 input_set_abs_params(input_dev, ABS_Z, -max_val, max_val, fuzz, flat); 709 714 715 + input_set_drvdata(input_dev, lis3); 716 + lis3->idev = input_dev; 717 + 718 + err = input_setup_polling(input_dev, lis3lv02d_joystick_poll); 719 + if (err) 720 + goto err_free_input; 721 + 722 + input_set_poll_interval(input_dev, MDPS_POLL_INTERVAL); 723 + input_set_min_poll_interval(input_dev, MDPS_POLL_MIN); 724 + input_set_max_poll_interval(input_dev, MDPS_POLL_MAX); 725 + 710 726 lis3->mapped_btns[0] = lis3lv02d_get_axis(abs(lis3->ac.x), btns); 711 727 lis3->mapped_btns[1] = lis3lv02d_get_axis(abs(lis3->ac.y), btns); 712 728 lis3->mapped_btns[2] = lis3lv02d_get_axis(abs(lis3->ac.z), btns); 713 729 714 - err = input_register_polled_device(lis3->idev); 715 - if (err) { 716 - input_free_polled_device(lis3->idev); 717 - lis3->idev = NULL; 718 - } 730 + err = input_register_device(lis3->idev); 731 + if (err) 732 + goto err_free_input; 719 733 734 + return 0; 735 + 736 + err_free_input: 737 + input_free_device(input_dev); 738 + lis3->idev = NULL; 720 739 return err; 740 + 721 741 } 722 742 EXPORT_SYMBOL_GPL(lis3lv02d_joystick_enable); 723 743 ··· 748 738 749 739 if (lis3->irq) 750 740 misc_deregister(&lis3->miscdev); 751 - input_unregister_polled_device(lis3->idev); 752 - input_free_polled_device(lis3->idev); 741 + input_unregister_device(lis3->idev); 753 742 lis3->idev = NULL; 754 743 } 755 744 EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable); ··· 904 895 (p->click_thresh_y << 4)); 905 896 906 897 if (lis3->idev) { 907 - struct input_dev *input_dev = lis3->idev->input; 908 - input_set_capability(input_dev, EV_KEY, BTN_X); 909 - input_set_capability(input_dev, EV_KEY, BTN_Y); 910 - input_set_capability(input_dev, EV_KEY, BTN_Z); 898 + input_set_capability(lis3->idev, EV_KEY, BTN_X); 899 + input_set_capability(lis3->idev, EV_KEY, BTN_Y); 900 + input_set_capability(lis3->idev, EV_KEY, BTN_Z); 911 901 } 912 902 } 913 903
+2 -2
drivers/misc/lis3lv02d/lis3lv02d.h
··· 6 6 * Copyright (C) 2008-2009 Eric Piel 7 7 */ 8 8 #include <linux/platform_device.h> 9 - #include <linux/input-polldev.h> 9 + #include <linux/input.h> 10 10 #include <linux/regulator/consumer.h> 11 11 #include <linux/miscdevice.h> 12 12 ··· 281 281 * (1/1000th of earth gravity) 282 282 */ 283 283 284 - struct input_polled_dev *idev; /* input device */ 284 + struct input_dev *idev; /* input device */ 285 285 struct platform_device *pdev; /* platform device */ 286 286 struct regulator_bulk_data regulators[2]; 287 287 atomic_t count; /* interrupt count after last read */