History

Input: navpoint - convert to use GPIO descriptor

The Navpoint driver uses a GPIO line, convert this to use a GPIO descriptor. There are no in-kernel users but out of tree users can easily be added or converted using a GPIO descriptor table as with numerous other drivers.

Linus Walleij committed 2 years ago

Commit 6caa2901 parent 51835752 files · +15 −27Browse files

Unified · Split

2 files
  1. drivers/input/mouse/navpoint.c +15 −26
  2. include/linux/input/navpoint.h +0 −1
drivers/input/mouse/navpoint.c+15−26
@@ -10,7 +10,7 @@ · 9 unmodified lines
10#include <linux/platform_device.h>10#include <linux/platform_device.h>
11#include <linux/clk.h>11#include <linux/clk.h>
12#include <linux/delay.h>12#include <linux/delay.h>
13#include <linux/gpio.h>13#include <linux/gpio/consumer.h>
14#include <linux/input.h>14#include <linux/input.h>
15#include <linux/input/navpoint.h>15#include <linux/input/navpoint.h>
16#include <linux/interrupt.h>16#include <linux/interrupt.h>
@@ -32,7 +32,7 @@ struct navpoint { · 15 unmodified lines
32 struct ssp_device *ssp;32 struct ssp_device *ssp;
33 struct input_dev *input;33 struct input_dev *input;
34 struct device *dev;34 struct device *dev;
35 int gpio;35 struct gpio_desc *gpiod;
36 int index;36 int index;
37 u8 data[1 + HEADER_LENGTH(0xff)];37 u8 data[1 + HEADER_LENGTH(0xff)];
38};38};
@@ -170,16 +170,14 @@ static void navpoint_up(struct navpoint *navpoint) · 131 unmodified lines
170 dev_err(navpoint->dev,170 dev_err(navpoint->dev,
171 "timeout waiting for SSSR[CSS] to clear\n");171 "timeout waiting for SSSR[CSS] to clear\n");
172 172
173 if (gpio_is_valid(navpoint->gpio))173 gpiod_set_value(navpoint->gpiod, 1);
174 gpio_set_value(navpoint->gpio, 1);
175}174}
176 175
177static void navpoint_down(struct navpoint *navpoint)176static void navpoint_down(struct navpoint *navpoint)
178{177{
179 struct ssp_device *ssp = navpoint->ssp;178 struct ssp_device *ssp = navpoint->ssp;
180 179
181 if (gpio_is_valid(navpoint->gpio))180 gpiod_set_value(navpoint->gpiod, 0);
182 gpio_set_value(navpoint->gpio, 0);
183 181
184 pxa_ssp_write_reg(ssp, SSCR0, 0);182 pxa_ssp_write_reg(ssp, SSCR0, 0);
185 183
@@ -216,18 +214,9 @@ static int navpoint_probe(struct platform_device *pdev) · 30 unmodified lines
216 return -EINVAL;214 return -EINVAL;
217 }215 }
218 216
219 if (gpio_is_valid(pdata->gpio)) {
220 error = gpio_request_one(pdata->gpio, GPIOF_OUT_INIT_LOW,
221 "SYNAPTICS_ON");
222 if (error)
223 return error;
224 }
225
226 ssp = pxa_ssp_request(pdata->port, pdev->name);217 ssp = pxa_ssp_request(pdata->port, pdev->name);
227 if (!ssp) {218 if (!ssp)
228 error = -ENODEV;219 return -ENODEV;
229 goto err_free_gpio;
230 }
231 220
232 /* HaRET does not disable devices before jumping into Linux */221 /* HaRET does not disable devices before jumping into Linux */
233 if (pxa_ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) {222 if (pxa_ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) {
@@ -242,10 +231,18 @@ static int navpoint_probe(struct platform_device *pdev) · 8 unmodified lines
242 goto err_free_mem;231 goto err_free_mem;
243 }232 }
244 233
234 navpoint->gpiod = gpiod_get_optional(&pdev->dev,
235 NULL, GPIOD_OUT_LOW);
236 if (IS_ERR(navpoint->gpiod)) {
237 error = PTR_ERR(navpoint->gpiod);
238 dev_err(&pdev->dev, "error getting GPIO\n");
239 goto err_free_mem;
240 }
241 gpiod_set_consumer_name(navpoint->gpiod, "SYNAPTICS_ON");
242
245 navpoint->ssp = ssp;243 navpoint->ssp = ssp;
246 navpoint->input = input;244 navpoint->input = input;
247 navpoint->dev = &pdev->dev;245 navpoint->dev = &pdev->dev;
248 navpoint->gpio = pdata->gpio;
249 246
250 input->name = pdev->name;247 input->name = pdev->name;
251 input->dev.parent = &pdev->dev;248 input->dev.parent = &pdev->dev;
@@ -288,17 +285,12 @@ err_free_mem: · 36 unmodified lines
288 input_free_device(input);285 input_free_device(input);
289 kfree(navpoint);286 kfree(navpoint);
290 pxa_ssp_free(ssp);287 pxa_ssp_free(ssp);
291err_free_gpio:
292 if (gpio_is_valid(pdata->gpio))
293 gpio_free(pdata->gpio);
294 288
295 return error;289 return error;
296}290}
297 291
298static void navpoint_remove(struct platform_device *pdev)292static void navpoint_remove(struct platform_device *pdev)
299{293{
300 const struct navpoint_platform_data *pdata =
301 dev_get_platdata(&pdev->dev);
302 struct navpoint *navpoint = platform_get_drvdata(pdev);294 struct navpoint *navpoint = platform_get_drvdata(pdev);
303 struct ssp_device *ssp = navpoint->ssp;295 struct ssp_device *ssp = navpoint->ssp;
304 296
@@ -308,9 +300,6 @@ static void navpoint_remove(struct platform_device *pdev) · 3 unmodified lines
308 kfree(navpoint);300 kfree(navpoint);
309 301
310 pxa_ssp_free(ssp);302 pxa_ssp_free(ssp);
311
312 if (gpio_is_valid(pdata->gpio))
313 gpio_free(pdata->gpio);
314}303}
315 304
316static int navpoint_suspend(struct device *dev)305static int navpoint_suspend(struct device *dev)
include/linux/input/navpoint.h+0−1
@@ -5,5 +5,4 @@ · 4 unmodified lines
5 5
6struct navpoint_platform_data {6struct navpoint_platform_data {
7 int port; /* PXA SSP port for pxa_ssp_request() */7 int port; /* PXA SSP port for pxa_ssp_request() */
8 int gpio; /* GPIO for power on/off */
9};8};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t