| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Apple Motion Sensor driver (joystick emulation) |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2005 Stelian Pop (stelian@popies.net) |
|---|
| 5 | 6 | * 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. |
|---|
| 11 | 7 | */ |
|---|
| 12 | 8 | |
|---|
| 13 | 9 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 29 | 25 | |
|---|
| 30 | 26 | static DEFINE_MUTEX(ams_input_mutex); |
|---|
| 31 | 27 | |
|---|
| 32 | | -static void ams_idev_poll(struct input_polled_dev *dev) |
|---|
| 28 | +static void ams_idev_poll(struct input_dev *idev) |
|---|
| 33 | 29 | { |
|---|
| 34 | | - struct input_dev *idev = dev->input; |
|---|
| 35 | 30 | s8 x, y, z; |
|---|
| 36 | 31 | |
|---|
| 37 | 32 | mutex_lock(&ams_info.lock); |
|---|
| .. | .. |
|---|
| 63 | 58 | ams_info.ycalib = y; |
|---|
| 64 | 59 | ams_info.zcalib = z; |
|---|
| 65 | 60 | |
|---|
| 66 | | - ams_info.idev = input_allocate_polled_device(); |
|---|
| 67 | | - if (!ams_info.idev) |
|---|
| 61 | + input = input_allocate_device(); |
|---|
| 62 | + if (!input) |
|---|
| 68 | 63 | return -ENOMEM; |
|---|
| 69 | 64 | |
|---|
| 70 | | - ams_info.idev->poll = ams_idev_poll; |
|---|
| 71 | | - ams_info.idev->poll_interval = 25; |
|---|
| 72 | | - |
|---|
| 73 | | - input = ams_info.idev->input; |
|---|
| 74 | 65 | input->name = "Apple Motion Sensor"; |
|---|
| 75 | 66 | input->id.bustype = ams_info.bustype; |
|---|
| 76 | 67 | input->id.vendor = 0; |
|---|
| .. | .. |
|---|
| 79 | 70 | input_set_abs_params(input, ABS_X, -50, 50, 3, 0); |
|---|
| 80 | 71 | input_set_abs_params(input, ABS_Y, -50, 50, 3, 0); |
|---|
| 81 | 72 | input_set_abs_params(input, ABS_Z, -50, 50, 3, 0); |
|---|
| 73 | + input_set_capability(input, EV_KEY, BTN_TOUCH); |
|---|
| 82 | 74 | |
|---|
| 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; |
|---|
| 86 | 78 | |
|---|
| 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); |
|---|
| 93 | 80 | |
|---|
| 81 | + error = input_register_device(input); |
|---|
| 82 | + if (error) |
|---|
| 83 | + goto err_free_input; |
|---|
| 84 | + |
|---|
| 85 | + ams_info.idev = input; |
|---|
| 94 | 86 | joystick = true; |
|---|
| 95 | 87 | |
|---|
| 96 | 88 | return 0; |
|---|
| 89 | + |
|---|
| 90 | +err_free_input: |
|---|
| 91 | + input_free_device(input); |
|---|
| 92 | + return error; |
|---|
| 97 | 93 | } |
|---|
| 98 | 94 | |
|---|
| 99 | 95 | static void ams_input_disable(void) |
|---|
| 100 | 96 | { |
|---|
| 101 | 97 | 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); |
|---|
| 104 | 99 | ams_info.idev = NULL; |
|---|
| 105 | 100 | } |
|---|
| 106 | 101 | |
|---|