Commit 58d5aa5c authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Guenter Roeck

hwmon: (applesmc) 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: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Link: https://lore.kernel.org/r/20191002214345.GA108728@dtor-wsSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 7b10e170
...@@ -309,7 +309,6 @@ config SENSORS_APPLESMC ...@@ -309,7 +309,6 @@ config SENSORS_APPLESMC
depends on INPUT && X86 depends on INPUT && X86
select NEW_LEDS select NEW_LEDS
select LEDS_CLASS select LEDS_CLASS
select INPUT_POLLDEV
help help
This driver provides support for the Apple System Management This driver provides support for the Apple System Management
Controller, which provides an accelerometer (Apple Sudden Motion Controller, which provides an accelerometer (Apple Sudden Motion
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/input-polldev.h> #include <linux/input.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -140,7 +140,7 @@ static s16 rest_y; ...@@ -140,7 +140,7 @@ static s16 rest_y;
static u8 backlight_state[2]; static u8 backlight_state[2];
static struct device *hwmon_dev; static struct device *hwmon_dev;
static struct input_polled_dev *applesmc_idev; static struct input_dev *applesmc_idev;
/* /*
* Last index written to key_at_index sysfs file, and value to use for all other * Last index written to key_at_index sysfs file, and value to use for all other
...@@ -681,9 +681,8 @@ static void applesmc_calibrate(void) ...@@ -681,9 +681,8 @@ static void applesmc_calibrate(void)
rest_x = -rest_x; rest_x = -rest_x;
} }
static void applesmc_idev_poll(struct input_polled_dev *dev) static void applesmc_idev_poll(struct input_dev *idev)
{ {
struct input_dev *idev = dev->input;
s16 x, y; s16 x, y;
if (applesmc_read_s16(MOTION_SENSOR_X_KEY, &x)) if (applesmc_read_s16(MOTION_SENSOR_X_KEY, &x))
...@@ -1134,7 +1133,6 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num) ...@@ -1134,7 +1133,6 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
/* Create accelerometer resources */ /* Create accelerometer resources */
static int applesmc_create_accelerometer(void) static int applesmc_create_accelerometer(void)
{ {
struct input_dev *idev;
int ret; int ret;
if (!smcreg.has_accelerometer) if (!smcreg.has_accelerometer)
...@@ -1144,37 +1142,38 @@ static int applesmc_create_accelerometer(void) ...@@ -1144,37 +1142,38 @@ static int applesmc_create_accelerometer(void)
if (ret) if (ret)
goto out; goto out;
applesmc_idev = input_allocate_polled_device(); applesmc_idev = input_allocate_device();
if (!applesmc_idev) { if (!applesmc_idev) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_sysfs; goto out_sysfs;
} }
applesmc_idev->poll = applesmc_idev_poll;
applesmc_idev->poll_interval = APPLESMC_POLL_INTERVAL;
/* initial calibrate for the input device */ /* initial calibrate for the input device */
applesmc_calibrate(); applesmc_calibrate();
/* initialize the input device */ /* initialize the input device */
idev = applesmc_idev->input; applesmc_idev->name = "applesmc";
idev->name = "applesmc"; applesmc_idev->id.bustype = BUS_HOST;
idev->id.bustype = BUS_HOST; applesmc_idev->dev.parent = &pdev->dev;
idev->dev.parent = &pdev->dev; input_set_abs_params(applesmc_idev, ABS_X,
idev->evbit[0] = BIT_MASK(EV_ABS);
input_set_abs_params(idev, ABS_X,
-256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT); -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
input_set_abs_params(idev, ABS_Y, input_set_abs_params(applesmc_idev, ABS_Y,
-256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT); -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
ret = input_register_polled_device(applesmc_idev); ret = input_setup_polling(applesmc_idev, applesmc_idev_poll);
if (ret)
goto out_idev;
input_set_poll_interval(applesmc_idev, APPLESMC_POLL_INTERVAL);
ret = input_register_device(applesmc_idev);
if (ret) if (ret)
goto out_idev; goto out_idev;
return 0; return 0;
out_idev: out_idev:
input_free_polled_device(applesmc_idev); input_free_device(applesmc_idev);
out_sysfs: out_sysfs:
applesmc_destroy_nodes(accelerometer_group); applesmc_destroy_nodes(accelerometer_group);
...@@ -1189,8 +1188,7 @@ static void applesmc_release_accelerometer(void) ...@@ -1189,8 +1188,7 @@ static void applesmc_release_accelerometer(void)
{ {
if (!smcreg.has_accelerometer) if (!smcreg.has_accelerometer)
return; return;
input_unregister_polled_device(applesmc_idev); input_unregister_device(applesmc_idev);
input_free_polled_device(applesmc_idev);
applesmc_destroy_nodes(accelerometer_group); applesmc_destroy_nodes(accelerometer_group);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment