* [PATCH] input: move gpio mouse to managed api
@ 2017-05-20 13:13 Bram Vlerick
2017-05-21 7:30 ` Bram Vlerick
0 siblings, 1 reply; 5+ messages in thread
From: Bram Vlerick @ 2017-05-20 13:13 UTC (permalink / raw)
To: dmitry.torokhov, michael.opdenacker; +Cc: linux-input, linux-kernel
Signed-off-by: Bram Vlerick <vlerickb@gmail.com>
---
drivers/input/mouse/gpio_mouse.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c
index ced07391304b..2fc8ddaf0175 100644
--- a/drivers/input/mouse/gpio_mouse.c
+++ b/drivers/input/mouse/gpio_mouse.c
@@ -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];
--
2.12.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] input: move gpio mouse to managed api
2017-05-20 13:13 [PATCH] input: move gpio mouse to managed api Bram Vlerick
@ 2017-05-21 7:30 ` Bram Vlerick
0 siblings, 0 replies; 5+ messages in thread
From: Bram Vlerick @ 2017-05-21 7:30 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: linux-input, linux-kernel
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
On Sat, 2017-05-20 at 15:13 +0200, Bram Vlerick wrote:
> Signed-off-by: Bram Vlerick <vlerickb@gmail.com>
> ---
> drivers/input/mouse/gpio_mouse.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/mouse/gpio_mouse.c
> b/drivers/input/mouse/gpio_mouse.c
> index ced07391304b..2fc8ddaf0175 100644
> --- a/drivers/input/mouse/gpio_mouse.c
> +++ b/drivers/input/mouse/gpio_mouse.c
> @@ -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];
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] input: move gpio mouse to managed api
2017-05-19 15:35 Bram Vlerick
2017-05-19 15:43 ` Michael Opdenacker
@ 2017-05-19 20:28 ` Dmitry Torokhov
1 sibling, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2017-05-19 20:28 UTC (permalink / raw)
To: Bram Vlerick; +Cc: michael.opdenacker, linux-input, linux-kernel
Hi Bram,
On Fri, May 19, 2017 at 05:35:02PM +0200, Bram Vlerick wrote:
> Signed-off-by: Bram Vlerick <vlerickb@gmail.com>
> ---
> drivers/input/mouse/gpio_mouse.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c
> index ced07391304b..7d56fd5173bc 100644
> --- a/drivers/input/mouse/gpio_mouse.c
> +++ b/drivers/input/mouse/gpio_mouse.c
> @@ -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];
> @@ -154,9 +151,6 @@ static int gpio_mouse_remove(struct platform_device *pdev)
> struct gpio_mouse_platform_data *pdata = input->private;
> int pin, i;
>
> - input_unregister_polled_device(input);
> - input_free_polled_device(input);
> -
This is wrong, as you now letting input device be active while gpios
are free.
Frankly, I wonder if we could not retire this driver by making gpio-keys
be more flexible... I think we discussed options to allow mode where
gpio-keys-polled "sums" the gpios for the same axis and report the
value.
> for (i = 0; i < GPIO_MOUSE_PIN_MAX; i++) {
> pin = pdata->pins[i];
> if (pin >= 0)
> --
> 2.12.2
>
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] input: move gpio mouse to managed api
2017-05-19 15:35 Bram Vlerick
@ 2017-05-19 15:43 ` Michael Opdenacker
2017-05-19 20:28 ` Dmitry Torokhov
1 sibling, 0 replies; 5+ messages in thread
From: Michael Opdenacker @ 2017-05-19 15:43 UTC (permalink / raw)
To: Bram Vlerick; +Cc: dmitry.torokhov, linux-input, linux-kernel
On 19/05/2017 17:35, Bram Vlerick wrote:
> Signed-off-by: Bram Vlerick <vlerickb@gmail.com>
> ---
> drivers/input/mouse/gpio_mouse.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c
> index ced07391304b..7d56fd5173bc 100644
> --- a/drivers/input/mouse/gpio_mouse.c
> +++ b/drivers/input/mouse/gpio_mouse.c
> @@ -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];
> @@ -154,9 +151,6 @@ static int gpio_mouse_remove(struct platform_device *pdev)
> struct gpio_mouse_platform_data *pdata = input->private;
> 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];
> if (pin >= 0)
Reviewed-by: Michael Opdenacker <michael.opdenacker@free-electrons.com>
--
Michael Opdenacker, CEO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] input: move gpio mouse to managed api
@ 2017-05-19 15:35 Bram Vlerick
2017-05-19 15:43 ` Michael Opdenacker
2017-05-19 20:28 ` Dmitry Torokhov
0 siblings, 2 replies; 5+ messages in thread
From: Bram Vlerick @ 2017-05-19 15:35 UTC (permalink / raw)
To: dmitry.torokhov, michael.opdenacker; +Cc: linux-input, linux-kernel
Signed-off-by: Bram Vlerick <vlerickb@gmail.com>
---
drivers/input/mouse/gpio_mouse.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c
index ced07391304b..7d56fd5173bc 100644
--- a/drivers/input/mouse/gpio_mouse.c
+++ b/drivers/input/mouse/gpio_mouse.c
@@ -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];
@@ -154,9 +151,6 @@ static int gpio_mouse_remove(struct platform_device *pdev)
struct gpio_mouse_platform_data *pdata = input->private;
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];
if (pin >= 0)
--
2.12.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-05-21 7:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-20 13:13 [PATCH] input: move gpio mouse to managed api Bram Vlerick
2017-05-21 7:30 ` Bram Vlerick
-- strict thread matches above, loose matches on Subject: below --
2017-05-19 15:35 Bram Vlerick
2017-05-19 15:43 ` Michael Opdenacker
2017-05-19 20:28 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).