hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/macintosh/ams/ams-input.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Apple Motion Sensor driver (joystick emulation)
34 *
45 * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
56 * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
117 */
128
139 #include <linux/module.h>
....@@ -29,9 +25,8 @@
2925
3026 static DEFINE_MUTEX(ams_input_mutex);
3127
32
-static void ams_idev_poll(struct input_polled_dev *dev)
28
+static void ams_idev_poll(struct input_dev *idev)
3329 {
34
- struct input_dev *idev = dev->input;
3530 s8 x, y, z;
3631
3732 mutex_lock(&ams_info.lock);
....@@ -63,14 +58,10 @@
6358 ams_info.ycalib = y;
6459 ams_info.zcalib = z;
6560
66
- ams_info.idev = input_allocate_polled_device();
67
- if (!ams_info.idev)
61
+ input = input_allocate_device();
62
+ if (!input)
6863 return -ENOMEM;
6964
70
- ams_info.idev->poll = ams_idev_poll;
71
- ams_info.idev->poll_interval = 25;
72
-
73
- input = ams_info.idev->input;
7465 input->name = "Apple Motion Sensor";
7566 input->id.bustype = ams_info.bustype;
7667 input->id.vendor = 0;
....@@ -79,28 +70,32 @@
7970 input_set_abs_params(input, ABS_X, -50, 50, 3, 0);
8071 input_set_abs_params(input, ABS_Y, -50, 50, 3, 0);
8172 input_set_abs_params(input, ABS_Z, -50, 50, 3, 0);
73
+ input_set_capability(input, EV_KEY, BTN_TOUCH);
8274
83
- set_bit(EV_ABS, input->evbit);
84
- set_bit(EV_KEY, input->evbit);
85
- set_bit(BTN_TOUCH, input->keybit);
75
+ error = input_setup_polling(input, ams_idev_poll);
76
+ if (error)
77
+ goto err_free_input;
8678
87
- error = input_register_polled_device(ams_info.idev);
88
- if (error) {
89
- input_free_polled_device(ams_info.idev);
90
- ams_info.idev = NULL;
91
- return error;
92
- }
79
+ input_set_poll_interval(input, 25);
9380
81
+ error = input_register_device(input);
82
+ if (error)
83
+ goto err_free_input;
84
+
85
+ ams_info.idev = input;
9486 joystick = true;
9587
9688 return 0;
89
+
90
+err_free_input:
91
+ input_free_device(input);
92
+ return error;
9793 }
9894
9995 static void ams_input_disable(void)
10096 {
10197 if (ams_info.idev) {
102
- input_unregister_polled_device(ams_info.idev);
103
- input_free_polled_device(ams_info.idev);
98
+ input_unregister_device(ams_info.idev);
10499 ams_info.idev = NULL;
105100 }
106101