hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/platform/x86/hdaps.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * hdaps.c - driver for IBM's Hard Drive Active Protection System
34 *
....@@ -11,26 +12,13 @@
1112 * This driver is based on the document by Mark A. Smith available at
1213 * http://www.almaden.ibm.com/cs/people/marksmith/tpaps.html and a lot of trial
1314 * and error.
14
- *
15
- * This program is free software; you can redistribute it and/or modify it
16
- * under the terms of the GNU General Public License v2 as published by the
17
- * Free Software Foundation.
18
- *
19
- * This program is distributed in the hope that it will be useful, but WITHOUT
20
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
22
- * more details.
23
- *
24
- * You should have received a copy of the GNU General Public License along with
25
- * this program; if not, write to the Free Software Foundation, Inc.,
26
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
2715 */
2816
2917 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3018
3119 #include <linux/delay.h>
3220 #include <linux/platform_device.h>
33
-#include <linux/input-polldev.h>
21
+#include <linux/input.h>
3422 #include <linux/kernel.h>
3523 #include <linux/mutex.h>
3624 #include <linux/module.h>
....@@ -71,7 +59,7 @@
7159 #define HDAPS_BOTH_AXES (HDAPS_X_AXIS | HDAPS_Y_AXIS)
7260
7361 static struct platform_device *pdev;
74
-static struct input_polled_dev *hdaps_idev;
62
+static struct input_dev *hdaps_idev;
7563 static unsigned int hdaps_invert;
7664 static u8 km_activity;
7765 static int rest_x;
....@@ -330,9 +318,8 @@
330318 __hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &rest_x, &rest_y);
331319 }
332320
333
-static void hdaps_mousedev_poll(struct input_polled_dev *dev)
321
+static void hdaps_mousedev_poll(struct input_dev *input_dev)
334322 {
335
- struct input_dev *input_dev = dev->input;
336323 int x, y;
337324
338325 mutex_lock(&hdaps_mtx);
....@@ -378,7 +365,7 @@
378365 static ssize_t hdaps_temp1_show(struct device *dev,
379366 struct device_attribute *attr, char *buf)
380367 {
381
- u8 uninitialized_var(temp);
368
+ u8 temp;
382369 int ret;
383370
384371 ret = hdaps_readb_one(HDAPS_PORT_TEMP1, &temp);
....@@ -391,7 +378,7 @@
391378 static ssize_t hdaps_temp2_show(struct device *dev,
392379 struct device_attribute *attr, char *buf)
393380 {
394
- u8 uninitialized_var(temp);
381
+ u8 temp;
395382 int ret;
396383
397384 ret = hdaps_readb_one(HDAPS_PORT_TEMP2, &temp);
....@@ -543,7 +530,6 @@
543530
544531 static int __init hdaps_init(void)
545532 {
546
- struct input_dev *idev;
547533 int ret;
548534
549535 if (!dmi_check_system(hdaps_whitelist)) {
....@@ -571,31 +557,32 @@
571557 if (ret)
572558 goto out_device;
573559
574
- hdaps_idev = input_allocate_polled_device();
560
+ hdaps_idev = input_allocate_device();
575561 if (!hdaps_idev) {
576562 ret = -ENOMEM;
577563 goto out_group;
578564 }
579565
580
- hdaps_idev->poll = hdaps_mousedev_poll;
581
- hdaps_idev->poll_interval = HDAPS_POLL_INTERVAL;
582
-
583566 /* initial calibrate for the input device */
584567 hdaps_calibrate();
585568
586569 /* initialize the input class */
587
- idev = hdaps_idev->input;
588
- idev->name = "hdaps";
589
- idev->phys = "isa1600/input0";
590
- idev->id.bustype = BUS_ISA;
591
- idev->dev.parent = &pdev->dev;
592
- idev->evbit[0] = BIT_MASK(EV_ABS);
593
- input_set_abs_params(idev, ABS_X,
570
+ hdaps_idev->name = "hdaps";
571
+ hdaps_idev->phys = "isa1600/input0";
572
+ hdaps_idev->id.bustype = BUS_ISA;
573
+ hdaps_idev->dev.parent = &pdev->dev;
574
+ input_set_abs_params(hdaps_idev, ABS_X,
594575 -256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);
595
- input_set_abs_params(idev, ABS_Y,
576
+ input_set_abs_params(hdaps_idev, ABS_Y,
596577 -256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);
597578
598
- ret = input_register_polled_device(hdaps_idev);
579
+ ret = input_setup_polling(hdaps_idev, hdaps_mousedev_poll);
580
+ if (ret)
581
+ goto out_idev;
582
+
583
+ input_set_poll_interval(hdaps_idev, HDAPS_POLL_INTERVAL);
584
+
585
+ ret = input_register_device(hdaps_idev);
599586 if (ret)
600587 goto out_idev;
601588
....@@ -603,7 +590,7 @@
603590 return 0;
604591
605592 out_idev:
606
- input_free_polled_device(hdaps_idev);
593
+ input_free_device(hdaps_idev);
607594 out_group:
608595 sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
609596 out_device:
....@@ -619,8 +606,7 @@
619606
620607 static void __exit hdaps_exit(void)
621608 {
622
- input_unregister_polled_device(hdaps_idev);
623
- input_free_polled_device(hdaps_idev);
609
+ input_unregister_device(hdaps_idev);
624610 sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
625611 platform_device_unregister(pdev);
626612 platform_driver_unregister(&hdaps_driver);