| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Cirrus Logic CLPS711X Keypad driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #include <linux/input.h> |
|---|
| 13 | | -#include <linux/input-polldev.h> |
|---|
| 14 | 9 | #include <linux/module.h> |
|---|
| 15 | 10 | #include <linux/of_gpio.h> |
|---|
| 16 | 11 | #include <linux/platform_device.h> |
|---|
| .. | .. |
|---|
| 34 | 29 | struct clps711x_gpio_data *gpio_data; |
|---|
| 35 | 30 | }; |
|---|
| 36 | 31 | |
|---|
| 37 | | -static void clps711x_keypad_poll(struct input_polled_dev *dev) |
|---|
| 32 | +static void clps711x_keypad_poll(struct input_dev *input) |
|---|
| 38 | 33 | { |
|---|
| 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); |
|---|
| 41 | 36 | bool sync = false; |
|---|
| 42 | 37 | int col, row; |
|---|
| 43 | 38 | |
|---|
| .. | .. |
|---|
| 65 | 60 | |
|---|
| 66 | 61 | if (state) { |
|---|
| 67 | 62 | 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); |
|---|
| 70 | 65 | } else { |
|---|
| 71 | 66 | clear_bit(col, data->last_state); |
|---|
| 72 | 67 | } |
|---|
| 73 | 68 | |
|---|
| 74 | 69 | if (keycodes[code]) |
|---|
| 75 | | - input_report_key(dev->input, |
|---|
| 70 | + input_report_key(input, |
|---|
| 76 | 71 | keycodes[code], state); |
|---|
| 77 | 72 | sync = true; |
|---|
| 78 | 73 | } |
|---|
| .. | .. |
|---|
| 84 | 79 | } |
|---|
| 85 | 80 | |
|---|
| 86 | 81 | if (sync) |
|---|
| 87 | | - input_sync(dev->input); |
|---|
| 82 | + input_sync(input); |
|---|
| 88 | 83 | } |
|---|
| 89 | 84 | |
|---|
| 90 | 85 | static int clps711x_keypad_probe(struct platform_device *pdev) |
|---|
| .. | .. |
|---|
| 92 | 87 | struct clps711x_keypad_data *priv; |
|---|
| 93 | 88 | struct device *dev = &pdev->dev; |
|---|
| 94 | 89 | struct device_node *np = dev->of_node; |
|---|
| 95 | | - struct input_polled_dev *poll_dev; |
|---|
| 90 | + struct input_dev *input; |
|---|
| 96 | 91 | u32 poll_interval; |
|---|
| 97 | 92 | int i, err; |
|---|
| 98 | 93 | |
|---|
| .. | .. |
|---|
| 129 | 124 | if (err) |
|---|
| 130 | 125 | return err; |
|---|
| 131 | 126 | |
|---|
| 132 | | - poll_dev = input_allocate_polled_device(); |
|---|
| 133 | | - if (!poll_dev) |
|---|
| 127 | + input = devm_input_allocate_device(dev); |
|---|
| 128 | + if (!input) |
|---|
| 134 | 129 | return -ENOMEM; |
|---|
| 135 | 130 | |
|---|
| 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; |
|---|
| 145 | 139 | |
|---|
| 146 | 140 | err = matrix_keypad_build_keymap(NULL, NULL, priv->row_count, |
|---|
| 147 | 141 | CLPS711X_KEYPAD_COL_COUNT, |
|---|
| 148 | | - NULL, poll_dev->input); |
|---|
| 142 | + NULL, input); |
|---|
| 149 | 143 | if (err) |
|---|
| 150 | | - goto out_err; |
|---|
| 144 | + return err; |
|---|
| 151 | 145 | |
|---|
| 152 | | - input_set_capability(poll_dev->input, EV_MSC, MSC_SCAN); |
|---|
| 146 | + input_set_capability(input, EV_MSC, MSC_SCAN); |
|---|
| 153 | 147 | 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); |
|---|
| 157 | 149 | |
|---|
| 158 | 150 | /* Set all columns to low */ |
|---|
| 159 | 151 | regmap_update_bits(priv->syscon, SYSCON_OFFSET, SYSCON1_KBDSCAN_MASK, |
|---|
| 160 | 152 | SYSCON1_KBDSCAN(1)); |
|---|
| 161 | 153 | |
|---|
| 162 | | - err = input_register_polled_device(poll_dev); |
|---|
| 154 | + |
|---|
| 155 | + err = input_setup_polling(input, clps711x_keypad_poll); |
|---|
| 163 | 156 | if (err) |
|---|
| 164 | | - goto out_err; |
|---|
| 157 | + return err; |
|---|
| 165 | 158 | |
|---|
| 166 | | - return 0; |
|---|
| 159 | + input_set_poll_interval(input, poll_interval); |
|---|
| 167 | 160 | |
|---|
| 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; |
|---|
| 179 | 164 | |
|---|
| 180 | 165 | return 0; |
|---|
| 181 | 166 | } |
|---|
| .. | .. |
|---|
| 192 | 177 | .of_match_table = clps711x_keypad_of_match, |
|---|
| 193 | 178 | }, |
|---|
| 194 | 179 | .probe = clps711x_keypad_probe, |
|---|
| 195 | | - .remove = clps711x_keypad_remove, |
|---|
| 196 | 180 | }; |
|---|
| 197 | 181 | module_platform_driver(clps711x_keypad_driver); |
|---|
| 198 | 182 | |
|---|