hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/input/keyboard/clps711x-keypad.c
....@@ -1,16 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Cirrus Logic CLPS711X Keypad driver
34 *
45 * Copyright (C) 2014 Alexander Shiyan <shc_work@mail.ru>
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.
106 */
117
128 #include <linux/input.h>
13
-#include <linux/input-polldev.h>
149 #include <linux/module.h>
1510 #include <linux/of_gpio.h>
1611 #include <linux/platform_device.h>
....@@ -34,10 +29,10 @@
3429 struct clps711x_gpio_data *gpio_data;
3530 };
3631
37
-static void clps711x_keypad_poll(struct input_polled_dev *dev)
32
+static void clps711x_keypad_poll(struct input_dev *input)
3833 {
39
- const unsigned short *keycodes = dev->input->keycode;
40
- struct clps711x_keypad_data *priv = dev->private;
34
+ const unsigned short *keycodes = input->keycode;
35
+ struct clps711x_keypad_data *priv = input_get_drvdata(input);
4136 bool sync = false;
4237 int col, row;
4338
....@@ -65,14 +60,14 @@
6560
6661 if (state) {
6762 set_bit(col, data->last_state);
68
- input_event(dev->input, EV_MSC,
69
- MSC_SCAN, code);
63
+ input_event(input,
64
+ EV_MSC, MSC_SCAN, code);
7065 } else {
7166 clear_bit(col, data->last_state);
7267 }
7368
7469 if (keycodes[code])
75
- input_report_key(dev->input,
70
+ input_report_key(input,
7671 keycodes[code], state);
7772 sync = true;
7873 }
....@@ -84,7 +79,7 @@
8479 }
8580
8681 if (sync)
87
- input_sync(dev->input);
82
+ input_sync(input);
8883 }
8984
9085 static int clps711x_keypad_probe(struct platform_device *pdev)
....@@ -92,7 +87,7 @@
9287 struct clps711x_keypad_data *priv;
9388 struct device *dev = &pdev->dev;
9489 struct device_node *np = dev->of_node;
95
- struct input_polled_dev *poll_dev;
90
+ struct input_dev *input;
9691 u32 poll_interval;
9792 int i, err;
9893
....@@ -129,53 +124,43 @@
129124 if (err)
130125 return err;
131126
132
- poll_dev = input_allocate_polled_device();
133
- if (!poll_dev)
127
+ input = devm_input_allocate_device(dev);
128
+ if (!input)
134129 return -ENOMEM;
135130
136
- poll_dev->private = priv;
137
- poll_dev->poll = clps711x_keypad_poll;
138
- poll_dev->poll_interval = poll_interval;
139
- poll_dev->input->name = pdev->name;
140
- poll_dev->input->dev.parent = dev;
141
- poll_dev->input->id.bustype = BUS_HOST;
142
- poll_dev->input->id.vendor = 0x0001;
143
- poll_dev->input->id.product = 0x0001;
144
- poll_dev->input->id.version = 0x0100;
131
+ input_set_drvdata(input, priv);
132
+
133
+ input->name = pdev->name;
134
+ input->dev.parent = dev;
135
+ input->id.bustype = BUS_HOST;
136
+ input->id.vendor = 0x0001;
137
+ input->id.product = 0x0001;
138
+ input->id.version = 0x0100;
145139
146140 err = matrix_keypad_build_keymap(NULL, NULL, priv->row_count,
147141 CLPS711X_KEYPAD_COL_COUNT,
148
- NULL, poll_dev->input);
142
+ NULL, input);
149143 if (err)
150
- goto out_err;
144
+ return err;
151145
152
- input_set_capability(poll_dev->input, EV_MSC, MSC_SCAN);
146
+ input_set_capability(input, EV_MSC, MSC_SCAN);
153147 if (of_property_read_bool(np, "autorepeat"))
154
- __set_bit(EV_REP, poll_dev->input->evbit);
155
-
156
- platform_set_drvdata(pdev, poll_dev);
148
+ __set_bit(EV_REP, input->evbit);
157149
158150 /* Set all columns to low */
159151 regmap_update_bits(priv->syscon, SYSCON_OFFSET, SYSCON1_KBDSCAN_MASK,
160152 SYSCON1_KBDSCAN(1));
161153
162
- err = input_register_polled_device(poll_dev);
154
+
155
+ err = input_setup_polling(input, clps711x_keypad_poll);
163156 if (err)
164
- goto out_err;
157
+ return err;
165158
166
- return 0;
159
+ input_set_poll_interval(input, poll_interval);
167160
168
-out_err:
169
- input_free_polled_device(poll_dev);
170
- return err;
171
-}
172
-
173
-static int clps711x_keypad_remove(struct platform_device *pdev)
174
-{
175
- struct input_polled_dev *poll_dev = platform_get_drvdata(pdev);
176
-
177
- input_unregister_polled_device(poll_dev);
178
- input_free_polled_device(poll_dev);
161
+ err = input_register_device(input);
162
+ if (err)
163
+ return err;
179164
180165 return 0;
181166 }
....@@ -192,7 +177,6 @@
192177 .of_match_table = clps711x_keypad_of_match,
193178 },
194179 .probe = clps711x_keypad_probe,
195
- .remove = clps711x_keypad_remove,
196180 };
197181 module_platform_driver(clps711x_keypad_driver);
198182