.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * SGI Volume Button interface driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2008 Thomas Bogendoerfer <tsbogend@alpha.franken.de> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
9 | | - * (at your option) any later version. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope that it will be useful, |
---|
12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | | - * GNU General Public License for more details. |
---|
15 | | - * |
---|
16 | | - * You should have received a copy of the GNU General Public License |
---|
17 | | - * along with this program; if not, write to the Free Software |
---|
18 | | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
---|
19 | 6 | */ |
---|
20 | | -#include <linux/input-polldev.h> |
---|
| 7 | +#include <linux/input.h> |
---|
21 | 8 | #include <linux/ioport.h> |
---|
22 | 9 | #include <linux/module.h> |
---|
23 | 10 | #include <linux/platform_device.h> |
---|
.. | .. |
---|
58 | 45 | }; |
---|
59 | 46 | |
---|
60 | 47 | struct buttons_dev { |
---|
61 | | - struct input_polled_dev *poll_dev; |
---|
62 | 48 | unsigned short keymap[ARRAY_SIZE(sgi_map)]; |
---|
63 | 49 | int count[ARRAY_SIZE(sgi_map)]; |
---|
64 | 50 | }; |
---|
65 | 51 | |
---|
66 | | -static void handle_buttons(struct input_polled_dev *dev) |
---|
| 52 | +static void handle_buttons(struct input_dev *input) |
---|
67 | 53 | { |
---|
68 | | - struct buttons_dev *bdev = dev->private; |
---|
69 | | - struct input_dev *input = dev->input; |
---|
| 54 | + struct buttons_dev *bdev = input_get_drvdata(input); |
---|
70 | 55 | u8 status; |
---|
71 | 56 | int i; |
---|
72 | 57 | |
---|
.. | .. |
---|
93 | 78 | static int sgi_buttons_probe(struct platform_device *pdev) |
---|
94 | 79 | { |
---|
95 | 80 | struct buttons_dev *bdev; |
---|
96 | | - struct input_polled_dev *poll_dev; |
---|
97 | 81 | struct input_dev *input; |
---|
98 | 82 | int error, i; |
---|
99 | 83 | |
---|
100 | | - bdev = kzalloc(sizeof(struct buttons_dev), GFP_KERNEL); |
---|
101 | | - poll_dev = input_allocate_polled_device(); |
---|
102 | | - if (!bdev || !poll_dev) { |
---|
103 | | - error = -ENOMEM; |
---|
104 | | - goto err_free_mem; |
---|
105 | | - } |
---|
| 84 | + bdev = devm_kzalloc(&pdev->dev, sizeof(*bdev), GFP_KERNEL); |
---|
| 85 | + if (!bdev) |
---|
| 86 | + return -ENOMEM; |
---|
| 87 | + |
---|
| 88 | + input = devm_input_allocate_device(&pdev->dev); |
---|
| 89 | + if (!input) |
---|
| 90 | + return -ENOMEM; |
---|
106 | 91 | |
---|
107 | 92 | memcpy(bdev->keymap, sgi_map, sizeof(bdev->keymap)); |
---|
108 | 93 | |
---|
109 | | - poll_dev->private = bdev; |
---|
110 | | - poll_dev->poll = handle_buttons; |
---|
111 | | - poll_dev->poll_interval = BUTTONS_POLL_INTERVAL; |
---|
| 94 | + input_set_drvdata(input, bdev); |
---|
112 | 95 | |
---|
113 | | - input = poll_dev->input; |
---|
114 | 96 | input->name = "SGI buttons"; |
---|
115 | 97 | input->phys = "sgi/input0"; |
---|
116 | 98 | input->id.bustype = BUS_HOST; |
---|
117 | | - input->dev.parent = &pdev->dev; |
---|
118 | 99 | |
---|
119 | 100 | input->keycode = bdev->keymap; |
---|
120 | 101 | input->keycodemax = ARRAY_SIZE(bdev->keymap); |
---|
.. | .. |
---|
126 | 107 | __set_bit(bdev->keymap[i], input->keybit); |
---|
127 | 108 | __clear_bit(KEY_RESERVED, input->keybit); |
---|
128 | 109 | |
---|
129 | | - bdev->poll_dev = poll_dev; |
---|
130 | | - platform_set_drvdata(pdev, bdev); |
---|
131 | | - |
---|
132 | | - error = input_register_polled_device(poll_dev); |
---|
| 110 | + error = input_setup_polling(input, handle_buttons); |
---|
133 | 111 | if (error) |
---|
134 | | - goto err_free_mem; |
---|
| 112 | + return error; |
---|
135 | 113 | |
---|
136 | | - return 0; |
---|
| 114 | + input_set_poll_interval(input, BUTTONS_POLL_INTERVAL); |
---|
137 | 115 | |
---|
138 | | - err_free_mem: |
---|
139 | | - input_free_polled_device(poll_dev); |
---|
140 | | - kfree(bdev); |
---|
141 | | - return error; |
---|
142 | | -} |
---|
143 | | - |
---|
144 | | -static int sgi_buttons_remove(struct platform_device *pdev) |
---|
145 | | -{ |
---|
146 | | - struct buttons_dev *bdev = platform_get_drvdata(pdev); |
---|
147 | | - |
---|
148 | | - input_unregister_polled_device(bdev->poll_dev); |
---|
149 | | - input_free_polled_device(bdev->poll_dev); |
---|
150 | | - kfree(bdev); |
---|
| 116 | + error = input_register_device(input); |
---|
| 117 | + if (error) |
---|
| 118 | + return error; |
---|
151 | 119 | |
---|
152 | 120 | return 0; |
---|
153 | 121 | } |
---|
154 | 122 | |
---|
155 | 123 | static struct platform_driver sgi_buttons_driver = { |
---|
156 | 124 | .probe = sgi_buttons_probe, |
---|
157 | | - .remove = sgi_buttons_remove, |
---|
158 | 125 | .driver = { |
---|
159 | 126 | .name = "sgibtns", |
---|
160 | 127 | }, |
---|