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.
Unified · Split
| @@ -10,7 +10,7 @@ · 9 unmodified lines | ||
| 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,7 +32,7 @@ struct navpoint { · 15 unmodified lines | ||
| 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,16 +170,14 @@ static void navpoint_up(struct navpoint *navpoint) · 131 unmodified lines | ||
| 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 | |
| @@ -216,18 +214,9 @@ static int navpoint_probe(struct platform_device *pdev) · 30 unmodified lines | ||
| 216 | 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 | 217 | 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; | |
| 231 | 220 | |
| 232 | 221 | /* HaRET does not disable devices before jumping into Linux */ |
| 233 | 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 | 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 | 243 | navpoint->ssp = ssp; |
| 246 | 244 | navpoint->input = input; |
| 247 | 245 | navpoint->dev = &pdev->dev; |
| 248 | − navpoint->gpio = pdata->gpio; | |
| 249 | 246 | |
| 250 | 247 | input->name = pdev->name; |
| 251 | 248 | input->dev.parent = &pdev->dev; |
| @@ -288,17 +285,12 @@ err_free_mem: · 36 unmodified lines | ||
| 288 | 285 | input_free_device(input); |
| 289 | 286 | kfree(navpoint); |
| 290 | 287 | pxa_ssp_free(ssp); |
| 291 | −err_free_gpio: | |
| 292 | − if (gpio_is_valid(pdata->gpio)) | |
| 293 | − gpio_free(pdata->gpio); | |
| 294 | 288 | |
| 295 | 289 | return error; |
| 296 | 290 | } |
| 297 | 291 | |
| 298 | 292 | static void navpoint_remove(struct platform_device *pdev) |
| 299 | 293 | { |
| 300 | − const struct navpoint_platform_data *pdata = | |
| 301 | − dev_get_platdata(&pdev->dev); | |
| 302 | 294 | struct navpoint *navpoint = platform_get_drvdata(pdev); |
| 303 | 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 | 300 | kfree(navpoint); |
| 309 | 301 | |
| 310 | 302 | pxa_ssp_free(ssp); |
| 311 | − | |
| 312 | − if (gpio_is_valid(pdata->gpio)) | |
| 313 | − gpio_free(pdata->gpio); | |
| 314 | 303 | } |
| 315 | 304 | |
| 316 | 305 | static int navpoint_suspend(struct device *dev) |
| @@ -5,5 +5,4 @@ · 4 unmodified lines | ||
| 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 | }; |