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 {
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)
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
177176static 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)
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)
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 @@ static int navpoint_probe(struct platform_device *pdev)
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
298292static 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)
308300 kfree (navpoint );
309301
310302 pxa_ssp_free (ssp );
311-
312- if (gpio_is_valid (pdata -> gpio ))
313- gpio_free (pdata -> gpio );
314303}
315304
316305static int navpoint_suspend (struct device * dev )
0 commit comments