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
1010 #include <linux/platform_device.h>
1111 #include <linux/clk.h>
1212 #include <linux/delay.h>
13−#include <linux/gpio.h>
13+#include <linux/gpio/consumer.h>
1414 #include <linux/input.h>
1515 #include <linux/input/navpoint.h>
1616 #include <linux/interrupt.h>
@@ -32,7 +32,7 @@ struct navpoint { · 15 unmodified lines
3232 struct ssp_device *ssp;
3333 struct input_dev *input;
3434 struct device *dev;
35− int gpio;
35+ struct gpio_desc *gpiod;
3636 int index;
3737 u8 data[1 + HEADER_LENGTH(0xff)];
3838 };
@@ -170,16 +170,14 @@ static void navpoint_up(struct navpoint *navpoint) · 131 unmodified lines
170170 dev_err(navpoint->dev,
171171 "timeout waiting for SSSR[CSS] to clear\n");
172172
173− if (gpio_is_valid(navpoint->gpio))
174− gpio_set_value(navpoint->gpio, 1);
173+ gpiod_set_value(navpoint->gpiod, 1);
175174 }
176175
177176 static void navpoint_down(struct navpoint *navpoint)
178177 {
179178 struct ssp_device *ssp = navpoint->ssp;
180179
181− if (gpio_is_valid(navpoint->gpio))
182− gpio_set_value(navpoint->gpio, 0);
180+ gpiod_set_value(navpoint->gpiod, 0);
183181
184182 pxa_ssp_write_reg(ssp, SSCR0, 0);
185183
@@ -216,18 +214,9 @@ static int navpoint_probe(struct platform_device *pdev) · 30 unmodified lines
216214 return -EINVAL;
217215 }
218216
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−
226217 ssp = pxa_ssp_request(pdata->port, pdev->name);
227− if (!ssp) {
228− error = -ENODEV;
229− goto err_free_gpio;
230− }
218+ if (!ssp)
219+ return -ENODEV;
231220
232221 /* HaRET does not disable devices before jumping into Linux */
233222 if (pxa_ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) {
@@ -242,10 +231,18 @@ static int navpoint_probe(struct platform_device *pdev) · 8 unmodified lines
242231 goto err_free_mem;
243232 }
244233
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+
245243 navpoint->ssp = ssp;
246244 navpoint->input = input;
247245 navpoint->dev = &pdev->dev;
248− navpoint->gpio = pdata->gpio;
249246
250247 input->name = pdev->name;
251248 input->dev.parent = &pdev->dev;
@@ -288,17 +285,12 @@ err_free_mem: · 36 unmodified lines
288285 input_free_device(input);
289286 kfree(navpoint);
290287 pxa_ssp_free(ssp);
291−err_free_gpio:
292− if (gpio_is_valid(pdata->gpio))
293− gpio_free(pdata->gpio);
294288
295289 return error;
296290 }
297291
298292 static void navpoint_remove(struct platform_device *pdev)
299293 {
300− const struct navpoint_platform_data *pdata =
301− dev_get_platdata(&pdev->dev);
302294 struct navpoint *navpoint = platform_get_drvdata(pdev);
303295 struct ssp_device *ssp = navpoint->ssp;
304296
@@ -308,9 +300,6 @@ static void navpoint_remove(struct platform_device *pdev) · 3 unmodified lines
308300 kfree(navpoint);
309301
310302 pxa_ssp_free(ssp);
311−
312− if (gpio_is_valid(pdata->gpio))
313− gpio_free(pdata->gpio);
314303 }
315304
316305 static int navpoint_suspend(struct device *dev)
include/linux/input/navpoint.h+0−1
@@ -5,5 +5,4 @@ · 4 unmodified lines
55
66 struct navpoint_platform_data {
77 int port; /* PXA SSP port for pxa_ssp_request() */
8− int gpio; /* GPIO for power on/off */
98 };

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