Skip to contentSkip to conversation

input: move gpio mouse to managed api

PATCH In review Bram Vlerick 1 participant 2 messages May 20, 2017 – May 21, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input: move gpio mouse to managed api

---
 drivers/input/mouse/gpio_mouse.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/input/mouse/gpio_mouse.c +2 -6
index ced07391304b..2fc8ddaf0175 100644
@@ -93,7 +93,7 @@ static int gpio_mouse_probe(struct platform_device *pdev)
 		}
 	}
 
-	input_poll = input_allocate_polled_device();
+	input_poll = devm_input_allocate_polled_device(&pdev->dev);
 	if (!input_poll) {
 		dev_err(&pdev->dev, "not enough memory for input device\n");
 		error = -ENOMEM;
@@ -124,7 +124,7 @@ static int gpio_mouse_probe(struct platform_device *pdev)
 	error = input_register_polled_device(input_poll);
 	if (error) {
 		dev_err(&pdev->dev, "could not register input device\n");
-		goto out_free_polldev;
+		goto out_free_gpios;
 	}
 
 	dev_dbg(&pdev->dev, "%d ms scan time, buttons: %s%s%s\n",
@@ -135,9 +135,6 @@ static int gpio_mouse_probe(struct platform_device *pdev)
 
 	return 0;
 
- out_free_polldev:
-	input_free_polled_device(input_poll);
-
  out_free_gpios:
 	while (--i >= 0) {
 		pin = pdata->pins[i];
@@ -155,7 +152,6 @@ static int gpio_mouse_remove(struct platform_device *pdev)
 	int pin, i;
 
 	input_unregister_polled_device(input);
-	input_free_polled_device(input);
 
 	for (i = 0; i < GPIO_MOUSE_PIN_MAX; i++) {
 		pin = pdata->pins[i];
Signature · 1 line
2.12.2
#1 lore raw

Hi Dmitry,

I've updated the patch with your comments, unregistering first before freeing the gpios.

In regards of your comment for the gpio-keys-polled update, I've just started with kernel dev and thought moving old drivers to the new managed api was a good start.
So I don't really know how to start that. However I'm willing to look at it if you could give some pointers where to start/how to tacle this.

Regards
Bram

Quoted 52 lines · Bram Vlerick
---
 drivers/input/mouse/gpio_mouse.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/input/mouse/gpio_mouse.c +1 -1
index ced07391304b..2fc8ddaf0175 100644
@@ -93,7 +93,7 @@ static int gpio_mouse_probe(struct platform_device
 *pdev)
 		}
 	}
 
-	input_poll = input_allocate_polled_device();
+	input_poll = devm_input_allocate_polled_device(&pdev->dev);
 	if (!input_poll) {
 		dev_err(&pdev->dev, "not enough memory for input

device\n");

drivers/input/mouse/gpio_mouse.c +1 -1
 		error = -ENOMEM;
@@ -124,7 +124,7 @@ static int gpio_mouse_probe(struct
 platform_device *pdev)
 	error = input_register_polled_device(input_poll);
 	if (error) {
 		dev_err(&pdev->dev, "could not register input
 device\n");
-		goto out_free_polldev;
+		goto out_free_gpios;
 	}
drivers/input/mouse/gpio_mouse.c +0 -3
 	dev_dbg(&pdev->dev, "%d ms scan time, buttons: %s%s%s\n",
@@ -135,9 +135,6 @@ static int gpio_mouse_probe(struct
 platform_device *pdev)
 
 	return 0;
 
- out_free_polldev:
-	input_free_polled_device(input_poll);
-
  out_free_gpios:
 	while (--i >= 0) {
drivers/input/mouse/gpio_mouse.c +0 -1
 		pin = pdata->pins[i];
@@ -155,7 +152,6 @@ static int gpio_mouse_remove(struct
 platform_device *pdev)
 	int pin, i;
 
 	input_unregister_polled_device(input);
-	input_free_polled_device(input);
 
 	for (i = 0; i < GPIO_MOUSE_PIN_MAX; i++) {

pin = pdata->pins[i];