[1/5,v2] input: mouse: Kill off platform data for GPIO mouse

Message ID 20170925163430.22397-1-linus.walleij@linaro.org
State New
Headers show
Series
  • [1/5,v2] input: mouse: Kill off platform data for GPIO mouse
Related show

Commit Message

Linus Walleij Sept. 25, 2017, 4:34 p.m.
This is not used much: git grep  gpio_mouse_platform_data shows
that absolutely nothing in the kernel defines this platform
data.

It could be argued that the driver should be deleted. But that
is a bit harsh I think since it seems generally useful. So
this patch starts a series which repurposes it to be used with
hardware nodes from device tree or ACPI.

This first patch simply localize the platform data header and
allocates a dummy platform data.

Yes: this patch leaves the driver in a pretty useless state,
but since nothing is instantiating this driver, it doesn't
make it more useless than it already is. Later patches makes
use of the driver.

Acked-by: Hans-Christian Noren Egtvedt <egtvedt@samfundet.no>

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
ChangeLog v1->v2:
- Collect Hand-Christian's ACK
---
 drivers/input/mouse/gpio_mouse.c | 59 +++++++++++++++++++++++++++++++++-----
 include/linux/gpio_mouse.h       | 61 ----------------------------------------
 2 files changed, 52 insertions(+), 68 deletions(-)
 delete mode 100644 include/linux/gpio_mouse.h

-- 
2.13.5

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Dmitry Torokhov Sept. 26, 2017, 4:54 p.m. | #1
On Mon, Sep 25, 2017 at 06:34:28PM +0200, Linus Walleij wrote:
> This adds DT bindings for simple mice attached to GPIO lines.

> As the properties are very general and pertains to all mice I

> can think of, we use very generic names for the 4-7 GPIO lines,

> "up", "down" etc.

> 

> Acked-by: Hans-Christian Noren Egtvedt <egtvedt@samfundet.no>

> Cc: devicetree@vger.kernel.org

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


Adding Rob. I am good with the patches unless there is objection to the
binding...

> ---

> ChangeLog v1->v2:

> - Collect Hand-Christian's ACK

> - Uses 5-7 lines rather than 4-7 lines

> - Add suffix "-ms" to the scan interval property

> - Fix compatible string in the example

> ---

>  .../devicetree/bindings/input/gpio-mouse.txt       | 32 ++++++++++++++++++++++

>  1 file changed, 32 insertions(+)

>  create mode 100644 Documentation/devicetree/bindings/input/gpio-mouse.txt

> 

> diff --git a/Documentation/devicetree/bindings/input/gpio-mouse.txt b/Documentation/devicetree/bindings/input/gpio-mouse.txt

> new file mode 100644

> index 000000000000..519510a11af9

> --- /dev/null

> +++ b/Documentation/devicetree/bindings/input/gpio-mouse.txt

> @@ -0,0 +1,32 @@

> +Device-Tree bindings for GPIO attached mice

> +

> +This simply uses standard GPIO handles to define a simple mouse connected

> +to 5-7 GPIO lines.

> +

> +Required properties:

> +	- compatible: must be "gpio-mouse"

> +	- scan-interval-ms: The scanning interval in milliseconds

> +	- up-gpios: GPIO line phandle to the line indicating "up"

> +	- down-gpios: GPIO line phandle to the line indicating "down"

> +	- left-gpios: GPIO line phandle to the line indicating "left"

> +	- right-gpios: GPIO line phandle to the line indicating "right"

> +

> +Optional properties:

> +	- button-left-gpios: GPIO line handle to the left mouse button

> +	- button-middle-gpios: GPIO line handle to the middle mouse button

> +	- button-right-gpios: GPIO line handle to the right mouse button

> +Example:

> +

> +#include <dt-bindings/gpio/gpio.h>

> +

> +gpio-mouse {

> +	compatible = "gpio-mouse";

> +	scan-interval-ms = <50>;

> +	up-gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;

> +	down-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;

> +	left-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;

> +	right-gpios = <&gpio0 3 GPIO_ACTIVE_LOW>;

> +	button-left-gpios = <&gpio0 4 GPIO_ACTIVE_LOW>;

> +	button-middle-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;

> +	button-right-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;

> +};

> -- 

> 2.13.5

> 


-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Oct. 16, 2017, 8:17 a.m. | #2
On Mon, Sep 25, 2017 at 6:34 PM, Linus Walleij <linus.walleij@linaro.org> wrote:

> This is not used much: git grep  gpio_mouse_platform_data shows

> that absolutely nothing in the kernel defines this platform

> data.

>

> It could be argued that the driver should be deleted. But that

> is a bit harsh I think since it seems generally useful. So

> this patch starts a series which repurposes it to be used with

> hardware nodes from device tree or ACPI.

>

> This first patch simply localize the platform data header and

> allocates a dummy platform data.

>

> Yes: this patch leaves the driver in a pretty useless state,

> but since nothing is instantiating this driver, it doesn't

> make it more useless than it already is. Later patches makes

> use of the driver.

>

> Acked-by: Hans-Christian Noren Egtvedt <egtvedt@samfundet.no>

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

> ---

> ChangeLog v1->v2:

> - Collect Hand-Christian's ACK


Dmitry: with Rob's ACK arrvied on the DT bindings, can this series
be applied?

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov Oct. 19, 2017, 11:29 p.m. | #3
On Mon, Oct 16, 2017 at 10:17:53AM +0200, Linus Walleij wrote:
> On Mon, Sep 25, 2017 at 6:34 PM, Linus Walleij <linus.walleij@linaro.org> wrote:

> 

> > This is not used much: git grep  gpio_mouse_platform_data shows

> > that absolutely nothing in the kernel defines this platform

> > data.

> >

> > It could be argued that the driver should be deleted. But that

> > is a bit harsh I think since it seems generally useful. So

> > this patch starts a series which repurposes it to be used with

> > hardware nodes from device tree or ACPI.

> >

> > This first patch simply localize the platform data header and

> > allocates a dummy platform data.

> >

> > Yes: this patch leaves the driver in a pretty useless state,

> > but since nothing is instantiating this driver, it doesn't

> > make it more useless than it already is. Later patches makes

> > use of the driver.

> >

> > Acked-by: Hans-Christian Noren Egtvedt <egtvedt@samfundet.no>

> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

> > ---

> > ChangeLog v1->v2:

> > - Collect Hand-Christian's ACK

> 

> Dmitry: with Rob's ACK arrvied on the DT bindings, can this series

> be applied?


Queued for 4.15, thank you.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c
index ced07391304b..dcaba1e4fffb 100644
--- a/drivers/input/mouse/gpio_mouse.c
+++ b/drivers/input/mouse/gpio_mouse.c
@@ -12,8 +12,54 @@ 
 #include <linux/platform_device.h>
 #include <linux/input-polldev.h>
 #include <linux/gpio.h>
-#include <linux/gpio_mouse.h>
 
+#define GPIO_MOUSE_POLARITY_ACT_HIGH	0x00
+#define GPIO_MOUSE_POLARITY_ACT_LOW	0x01
+
+#define GPIO_MOUSE_PIN_UP	0
+#define GPIO_MOUSE_PIN_DOWN	1
+#define GPIO_MOUSE_PIN_LEFT	2
+#define GPIO_MOUSE_PIN_RIGHT	3
+#define GPIO_MOUSE_PIN_BLEFT	4
+#define GPIO_MOUSE_PIN_BMIDDLE	5
+#define GPIO_MOUSE_PIN_BRIGHT	6
+#define GPIO_MOUSE_PIN_MAX	7
+
+/**
+ * struct gpio_mouse_platform_data
+ * @scan_ms: integer in ms specifying the scan periode.
+ * @polarity: Pin polarity, active high or low.
+ * @up: GPIO line for up value.
+ * @down: GPIO line for down value.
+ * @left: GPIO line for left value.
+ * @right: GPIO line for right value.
+ * @bleft: GPIO line for left button.
+ * @bmiddle: GPIO line for middle button.
+ * @bright: GPIO line for right button.
+ * @pins: GPIO line numbers used for the mouse.
+ *
+ * This struct must be added to the platform_device in the board code.
+ * It is used by the gpio_mouse driver to setup GPIO lines and to
+ * calculate mouse movement.
+ */
+struct gpio_mouse_platform_data {
+	int scan_ms;
+	int polarity;
+
+	union {
+		struct {
+			int up;
+			int down;
+			int left;
+			int right;
+
+			int bleft;
+			int bmiddle;
+			int bright;
+		};
+		int pins[GPIO_MOUSE_PIN_MAX];
+	};
+};
 
 /*
  * Timer function which is run every scan_ms ms when the device is opened.
@@ -47,17 +93,16 @@  static void gpio_mouse_scan(struct input_polled_dev *dev)
 
 static int gpio_mouse_probe(struct platform_device *pdev)
 {
-	struct gpio_mouse_platform_data *pdata = dev_get_platdata(&pdev->dev);
+	struct device *dev = &pdev->dev;
+	struct gpio_mouse_platform_data *pdata;
 	struct input_polled_dev *input_poll;
 	struct input_dev *input;
 	int pin, i;
 	int error;
 
-	if (!pdata) {
-		dev_err(&pdev->dev, "no platform data\n");
-		error = -ENXIO;
-		goto out;
-	}
+	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
 	if (pdata->scan_ms < 0) {
 		dev_err(&pdev->dev, "invalid scan time\n");
diff --git a/include/linux/gpio_mouse.h b/include/linux/gpio_mouse.h
deleted file mode 100644
index 44ed7aa14d85..000000000000
--- a/include/linux/gpio_mouse.h
+++ /dev/null
@@ -1,61 +0,0 @@ 
-/*
- * Driver for simulating a mouse on GPIO lines.
- *
- * Copyright (C) 2007 Atmel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef _GPIO_MOUSE_H
-#define _GPIO_MOUSE_H
-
-#define GPIO_MOUSE_POLARITY_ACT_HIGH	0x00
-#define GPIO_MOUSE_POLARITY_ACT_LOW	0x01
-
-#define GPIO_MOUSE_PIN_UP	0
-#define GPIO_MOUSE_PIN_DOWN	1
-#define GPIO_MOUSE_PIN_LEFT	2
-#define GPIO_MOUSE_PIN_RIGHT	3
-#define GPIO_MOUSE_PIN_BLEFT	4
-#define GPIO_MOUSE_PIN_BMIDDLE	5
-#define GPIO_MOUSE_PIN_BRIGHT	6
-#define GPIO_MOUSE_PIN_MAX	7
-
-/**
- * struct gpio_mouse_platform_data
- * @scan_ms: integer in ms specifying the scan periode.
- * @polarity: Pin polarity, active high or low.
- * @up: GPIO line for up value.
- * @down: GPIO line for down value.
- * @left: GPIO line for left value.
- * @right: GPIO line for right value.
- * @bleft: GPIO line for left button.
- * @bmiddle: GPIO line for middle button.
- * @bright: GPIO line for right button.
- *
- * This struct must be added to the platform_device in the board code.
- * It is used by the gpio_mouse driver to setup GPIO lines and to
- * calculate mouse movement.
- */
-struct gpio_mouse_platform_data {
-	int scan_ms;
-	int polarity;
-
-	union {
-		struct {
-			int up;
-			int down;
-			int left;
-			int right;
-
-			int bleft;
-			int bmiddle;
-			int bright;
-		};
-		int pins[GPIO_MOUSE_PIN_MAX];
-	};
-};
-
-#endif /* _GPIO_MOUSE_H */