Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20231129-descriptors-input-v1-1-9433162914a3@linaro.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Linus Walleij and committed by
Dmitry Torokhov
6caa2906 51835758

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