macintosh/ams-input: switch to using input device polling mode
PATCH 1/1 macintosh/ams-input: 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 <[email protected]>
--- drivers/macintosh/Kconfig | 1 - drivers/macintosh/ams/ams-input.c | 37 +++++++++++++++---------------- drivers/macintosh/ams/ams.h | 4 ++-- 3 files changed, 20 insertions(+), 22 deletions(-)
drivers/macintosh/Kconfig +0 -1
@@ -247,7 +247,6 @@ config PMAC_RACKMETER config SENSORS_AMS tristate "Apple Motion Sensor driver" depends on PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) - select INPUT_POLLDEV help Support for the motion sensor included in PowerBooks. Includes implementations for PMU and I2C.
drivers/macintosh/ams/ams-input.c +18 -19
@@ -25,9 +25,8 @@ MODULE_PARM_DESC(invert, "Invert input data on X and Y axis");static DEFINE_MUTEX (ams_input_mutex); -static void ams_idev_poll (struct input_polled_dev *dev) +static void ams_idev_poll (struct input_dev *idev) { -struct input_dev *idev = dev->input;s8 x, y, z;mutex_lock (&ams_info.lock);
@@ -59,14 +58,10 @@ static int ams_input_enable(void) ams_info.ycalib = y; ams_info.zcalib = z; - ams_info.idev =input_allocate_polled_device (); -if (!ams_info.idev) + input =input_allocate_device (); +if (!input)return -ENOMEM ; - ams_info.idev->poll = ams_idev_poll; - ams_info.idev->poll_interval =25 ; - - input = ams_info.idev->input; input->name ="Apple Motion Sensor" ; input->id.bustype = ams_info.bustype; input->id.vendor =0 ;
@@ -75,28 +70,32 @@ static int ams_input_enable(void)input_set_abs_params (input,ABS_X ,-50 ,50 ,3 ,0 );input_set_abs_params (input,ABS_Y ,-50 ,50 ,3 ,0 );input_set_abs_params (input,ABS_Z ,-50 ,50 ,3 ,0 ); +input_set_capability (input,EV_KEY ,BTN_TOUCH ); -set_bit (EV_ABS , input->evbit); -set_bit (EV_KEY , input->evbit); -set_bit (BTN_TOUCH , input->keybit); + error =input_setup_polling (input, ams_idev_poll); +if (error) + goto err_free_input; - error =input_register_polled_device (ams_info.idev); -if (error) { -input_free_polled_device (ams_info.idev); - ams_info.idev =NULL ; -return error; - } +input_set_poll_interval (input,25 ); + error =input_register_device (input); +if (error) + goto err_free_input; + + ams_info.idev = input; joystick = true;return 0 ; + +err_free_input: +input_free_device (input); +return error; }static void ams_input_disable (void ) {if (ams_info.idev) { -input_unregister_polled_device (ams_info.idev); -input_free_polled_device (ams_info.idev); +input_unregister_device (ams_info.idev); ams_info.idev =NULL ; }
drivers/macintosh/ams/ams.h +2 -2
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ #include <linux/i2c.h> -#include <linux/input-polldev.h> +#include <linux/input.h> #include <linux/kthread.h> #include <linux/mutex.h> #include <linux/spinlock.h>
@@ -51,7 +51,7 @@ struct ams {#endif /* Joystick emulation */ -struct input_polled_dev *idev; +struct input_dev *idev;__u16 bustype;/* calibrated null values */
Signature · 5 lines
2.23.0.444.g18eeb5a265-goog -- Dmitry
Quoted 2 lines · Dmitry Torokhov
Now that instances of
input_devsupport polling mode natively, we no longer need to createinput_polled_devinstance.
Michael, could you please take this? Or I could push through my tree...
Thanks!
Quoted 123 lines
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/macintosh/Kconfig | 1 - drivers/macintosh/ams/ams-input.c | 37 +++++++++++++++---------------- drivers/macintosh/ams/ams.h | 4 ++-- 3 files changed, 20 insertions(+), 22 deletions(-)drivers/macintosh/Kconfig +0
-1@@ -247,7 +247,6 @@ config PMAC_RACKMETER config SENSORS_AMS tristate "Apple Motion Sensor driver" depends on PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) - select INPUT_POLLDEV help Support for the motion sensor included in PowerBooks. Includes implementations for PMU and I2C.drivers/macintosh/ams/ams-input.c +18
-19@@ -25,9 +25,8 @@ MODULE_PARM_DESC(invert, "Invert input data on X and Y axis");static DEFINE_MUTEX (ams_input_mutex); -static void ams_idev_poll (struct input_polled_dev *dev) +static void ams_idev_poll (struct input_dev *idev) { -struct input_dev *idev = dev->input;s8 x, y, z;mutex_lock (&ams_info.lock);@@ -59,14 +58,10 @@ static int ams_input_enable(void) ams_info.ycalib = y; ams_info.zcalib = z; - ams_info.idev =input_allocate_polled_device (); -if (!ams_info.idev) + input =input_allocate_device (); +if (!input)return -ENOMEM ; - ams_info.idev->poll = ams_idev_poll; - ams_info.idev->poll_interval =25 ; - - input = ams_info.idev->input; input->name ="Apple Motion Sensor" ; input->id.bustype = ams_info.bustype; input->id.vendor =0 ;@@ -75,28 +70,32 @@ static int ams_input_enable(void)input_set_abs_params (input,ABS_X ,-50 ,50 ,3 ,0 );input_set_abs_params (input,ABS_Y ,-50 ,50 ,3 ,0 );input_set_abs_params (input,ABS_Z ,-50 ,50 ,3 ,0 ); +input_set_capability (input,EV_KEY ,BTN_TOUCH ); -set_bit (EV_ABS , input->evbit); -set_bit (EV_KEY , input->evbit); -set_bit (BTN_TOUCH , input->keybit); + error =input_setup_polling (input, ams_idev_poll); +if (error) + goto err_free_input; - error =input_register_polled_device (ams_info.idev); -if (error) { -input_free_polled_device (ams_info.idev); - ams_info.idev =NULL ; -return error; - } +input_set_poll_interval (input,25 ); + error =input_register_device (input); +if (error) + goto err_free_input; + + ams_info.idev = input; joystick = true;return 0 ; + +err_free_input: +input_free_device (input); +return error; }static void ams_input_disable (void ) {if (ams_info.idev) { -input_unregister_polled_device (ams_info.idev); -input_free_polled_device (ams_info.idev); +input_unregister_device (ams_info.idev); ams_info.idev =NULL ; }drivers/macintosh/ams/ams.h +2
-2@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ #include <linux/i2c.h> -#include <linux/input-polldev.h> +#include <linux/input.h> #include <linux/kthread.h> #include <linux/mutex.h> #include <linux/spinlock.h> @@ -51,7 +51,7 @@ struct ams {#endif /* Joystick emulation */ -struct input_polled_dev *idev; +struct input_dev *idev;__u16 bustype;/* calibrated null values */ Signature · 5 lines
2.23.0.444.g18eeb5a265-goog -- Dmitry
Signature · 1 line
Dmitry
Michael Ellerman
AppliedQuoted 2 lines · Dmitry Torokhov
Now that instances of
input_devsupport polling mode natively, we no longer need to createinput_polled_devinstance.
Applied to powerpc/next.
[1/1] macintosh/ams-input: switch to using input device polling mode
https://git.kernel.org/powerpc/c/0c444d98efad89e2a189d1a5a188e0385edac647
cheers