* [PATCH] hwmon: applesmc: switch to using input device polling mode
@ 2019-10-02 21:43 Dmitry Torokhov
2019-10-02 23:51 ` kbuild test robot
2019-10-03 3:39 ` Guenter Roeck
0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2019-10-02 21:43 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck
Cc: Nicolas Boichat, Nicolas Boichat, linux-hwmon, linux-kernel
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>
---
drivers/hwmon/Kconfig | 1 -
drivers/hwmon/applesmc.c | 38 ++++++++++++++++++--------------------
2 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 650dd71f9724..c5adca9cd465 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -299,7 +299,6 @@ config SENSORS_APPLESMC
depends on INPUT && X86
select NEW_LEDS
select LEDS_CLASS
- select INPUT_POLLDEV
help
This driver provides support for the Apple System Management
Controller, which provides an accelerometer (Apple Sudden Motion
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 183ff3d25129..ec93b8d673f5 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -19,7 +19,7 @@
#include <linux/delay.h>
#include <linux/platform_device.h>
-#include <linux/input-polldev.h>
+#include <linux/input.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/module.h>
@@ -140,7 +140,7 @@ static s16 rest_y;
static u8 backlight_state[2];
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
@@ -681,9 +681,8 @@ static void applesmc_calibrate(void)
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;
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)
/* Create accelerometer resources */
static int applesmc_create_accelerometer(void)
{
- struct input_dev *idev;
int ret;
if (!smcreg.has_accelerometer)
@@ -1144,37 +1142,38 @@ static int applesmc_create_accelerometer(void)
if (ret)
goto out;
- applesmc_idev = input_allocate_polled_device();
+ applesmc_idev = input_allocate_device();
if (!applesmc_idev) {
ret = -ENOMEM;
goto out_sysfs;
}
- applesmc_idev->poll = applesmc_idev_poll;
- applesmc_idev->poll_interval = APPLESMC_POLL_INTERVAL;
-
/* initial calibrate for the input device */
applesmc_calibrate();
/* initialize the input device */
- idev = applesmc_idev->input;
- idev->name = "applesmc";
- idev->id.bustype = BUS_HOST;
- idev->dev.parent = &pdev->dev;
- idev->evbit[0] = BIT_MASK(EV_ABS);
- input_set_abs_params(idev, ABS_X,
+ applesmc_idev->name = "applesmc";
+ applesmc_idev->id.bustype = BUS_HOST;
+ applesmc_idev->dev.parent = &pdev->dev;
+ input_set_abs_params(applesmc_idev, ABS_X,
-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);
- 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)
goto out_idev;
return 0;
out_idev:
- input_free_polled_device(applesmc_idev);
+ input_free_device(applesmc_idev);
out_sysfs:
applesmc_destroy_nodes(accelerometer_group);
@@ -1189,8 +1188,7 @@ static void applesmc_release_accelerometer(void)
{
if (!smcreg.has_accelerometer)
return;
- input_unregister_polled_device(applesmc_idev);
- input_free_polled_device(applesmc_idev);
+ input_unregister_device(applesmc_idev);
applesmc_destroy_nodes(accelerometer_group);
}
--
2.23.0.444.g18eeb5a265-goog
--
Dmitry
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: applesmc: switch to using input device polling mode
2019-10-02 21:43 [PATCH] hwmon: applesmc: switch to using input device polling mode Dmitry Torokhov
@ 2019-10-02 23:51 ` kbuild test robot
2019-10-03 3:39 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2019-10-02 23:51 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: kbuild-all, Jean Delvare, Guenter Roeck, Nicolas Boichat,
Nicolas Boichat, linux-hwmon, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 3399 bytes --]
Hi Dmitry,
I love your patch! Yet something to improve:
[auto build test ERROR on hwmon/hwmon-next]
[cannot apply to v5.4-rc1 next-20191002]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Dmitry-Torokhov/hwmon-applesmc-switch-to-using-input-device-polling-mode/20191003-063910
base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-7 (Debian 7.4.0-13) 7.4.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/hwmon/applesmc.c: In function 'applesmc_create_accelerometer':
>> drivers/hwmon/applesmc.c:1163:8: error: implicit declaration of function 'input_setup_polling'; did you mean 'input_set_capability'? [-Werror=implicit-function-declaration]
ret = input_setup_polling(applesmc_idev, applesmc_idev_poll);
^~~~~~~~~~~~~~~~~~~
input_set_capability
>> drivers/hwmon/applesmc.c:1167:2: error: implicit declaration of function 'input_set_poll_interval'; did you mean 'input_set_abs_params'? [-Werror=implicit-function-declaration]
input_set_poll_interval(applesmc_idev, APPLESMC_POLL_INTERVAL);
^~~~~~~~~~~~~~~~~~~~~~~
input_set_abs_params
cc1: some warnings being treated as errors
vim +1163 drivers/hwmon/applesmc.c
1132
1133 /* Create accelerometer resources */
1134 static int applesmc_create_accelerometer(void)
1135 {
1136 int ret;
1137
1138 if (!smcreg.has_accelerometer)
1139 return 0;
1140
1141 ret = applesmc_create_nodes(accelerometer_group, 1);
1142 if (ret)
1143 goto out;
1144
1145 applesmc_idev = input_allocate_device();
1146 if (!applesmc_idev) {
1147 ret = -ENOMEM;
1148 goto out_sysfs;
1149 }
1150
1151 /* initial calibrate for the input device */
1152 applesmc_calibrate();
1153
1154 /* initialize the input device */
1155 applesmc_idev->name = "applesmc";
1156 applesmc_idev->id.bustype = BUS_HOST;
1157 applesmc_idev->dev.parent = &pdev->dev;
1158 input_set_abs_params(applesmc_idev, ABS_X,
1159 -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
1160 input_set_abs_params(applesmc_idev, ABS_Y,
1161 -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
1162
> 1163 ret = input_setup_polling(applesmc_idev, applesmc_idev_poll);
1164 if (ret)
1165 goto out_idev;
1166
> 1167 input_set_poll_interval(applesmc_idev, APPLESMC_POLL_INTERVAL);
1168
1169 ret = input_register_device(applesmc_idev);
1170 if (ret)
1171 goto out_idev;
1172
1173 return 0;
1174
1175 out_idev:
1176 input_free_device(applesmc_idev);
1177
1178 out_sysfs:
1179 applesmc_destroy_nodes(accelerometer_group);
1180
1181 out:
1182 pr_warn("driver init failed (ret=%d)!\n", ret);
1183 return ret;
1184 }
1185
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 69520 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: applesmc: switch to using input device polling mode
2019-10-02 21:43 [PATCH] hwmon: applesmc: switch to using input device polling mode Dmitry Torokhov
2019-10-02 23:51 ` kbuild test robot
@ 2019-10-03 3:39 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2019-10-03 3:39 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Jean Delvare, Nicolas Boichat, Nicolas Boichat, linux-hwmon,
linux-kernel
On Wed, Oct 02, 2019 at 02:43:45PM -0700, Dmitry Torokhov wrote:
> 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>
Applied to hwmon-next.
I don't know what 0-day is complaining about; the code builds
fine for me with the supposedly failing configuration. We'll
see if we get into trouble when the patch shows up in -next.
Guenter
> ---
> drivers/hwmon/Kconfig | 1 -
> drivers/hwmon/applesmc.c | 38 ++++++++++++++++++--------------------
> 2 files changed, 18 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
> index 650dd71f9724..c5adca9cd465 100644
> --- a/drivers/hwmon/Kconfig
> +++ b/drivers/hwmon/Kconfig
> @@ -299,7 +299,6 @@ config SENSORS_APPLESMC
> depends on INPUT && X86
> select NEW_LEDS
> select LEDS_CLASS
> - select INPUT_POLLDEV
> help
> This driver provides support for the Apple System Management
> Controller, which provides an accelerometer (Apple Sudden Motion
> diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
> index 183ff3d25129..ec93b8d673f5 100644
> --- a/drivers/hwmon/applesmc.c
> +++ b/drivers/hwmon/applesmc.c
> @@ -19,7 +19,7 @@
>
> #include <linux/delay.h>
> #include <linux/platform_device.h>
> -#include <linux/input-polldev.h>
> +#include <linux/input.h>
> #include <linux/kernel.h>
> #include <linux/slab.h>
> #include <linux/module.h>
> @@ -140,7 +140,7 @@ static s16 rest_y;
> static u8 backlight_state[2];
>
> 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
> @@ -681,9 +681,8 @@ static void applesmc_calibrate(void)
> 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;
>
> 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)
> /* Create accelerometer resources */
> static int applesmc_create_accelerometer(void)
> {
> - struct input_dev *idev;
> int ret;
>
> if (!smcreg.has_accelerometer)
> @@ -1144,37 +1142,38 @@ static int applesmc_create_accelerometer(void)
> if (ret)
> goto out;
>
> - applesmc_idev = input_allocate_polled_device();
> + applesmc_idev = input_allocate_device();
> if (!applesmc_idev) {
> ret = -ENOMEM;
> goto out_sysfs;
> }
>
> - applesmc_idev->poll = applesmc_idev_poll;
> - applesmc_idev->poll_interval = APPLESMC_POLL_INTERVAL;
> -
> /* initial calibrate for the input device */
> applesmc_calibrate();
>
> /* initialize the input device */
> - idev = applesmc_idev->input;
> - idev->name = "applesmc";
> - idev->id.bustype = BUS_HOST;
> - idev->dev.parent = &pdev->dev;
> - idev->evbit[0] = BIT_MASK(EV_ABS);
> - input_set_abs_params(idev, ABS_X,
> + applesmc_idev->name = "applesmc";
> + applesmc_idev->id.bustype = BUS_HOST;
> + applesmc_idev->dev.parent = &pdev->dev;
> + input_set_abs_params(applesmc_idev, ABS_X,
> -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);
>
> - 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)
> goto out_idev;
>
> return 0;
>
> out_idev:
> - input_free_polled_device(applesmc_idev);
> + input_free_device(applesmc_idev);
>
> out_sysfs:
> applesmc_destroy_nodes(accelerometer_group);
> @@ -1189,8 +1188,7 @@ static void applesmc_release_accelerometer(void)
> {
> if (!smcreg.has_accelerometer)
> return;
> - input_unregister_polled_device(applesmc_idev);
> - input_free_polled_device(applesmc_idev);
> + input_unregister_device(applesmc_idev);
> applesmc_destroy_nodes(accelerometer_group);
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-03 3:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02 21:43 [PATCH] hwmon: applesmc: switch to using input device polling mode Dmitry Torokhov
2019-10-02 23:51 ` kbuild test robot
2019-10-03 3:39 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).