All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: gpio_mouse - remove driver that has never been used in the kernel
@ 2026-09-19  8:36 Ethan Nelson-Moore
  2026-09-19  8:44 ` sashiko-bot
  2026-09-19 12:12 ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Ethan Nelson-Moore @ 2026-09-19  8:36 UTC (permalink / raw)
  To: Shuah Khan, Randy Dunlap, Dmitry Torokhov, Andres Salomon,
	Bjorn Helgaas, linux-gpio, linux-doc, linux-input
  Cc: Hans-Christian Egtvedt, Ethan Nelson-Moore, Linus Walleij,
	Bartosz Golaszewski, Jonathan Corbet

The gpio_mouse driver was added in 2007, but it has never been
referenced by any platform data or DTS files in the kernel, and it does
not support ACPI probing. Therefore, it has clearly never been used by
any users of unmodified mainline Linux. Remove it.

Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
---
 .../driver-api/gpio/drivers-on-gpio.rst       |   5 -
 drivers/input/mouse/Kconfig                   |  15 --
 drivers/input/mouse/Makefile                  |   1 -
 drivers/input/mouse/gpio_mouse.c              | 170 ------------------
 4 files changed, 191 deletions(-)
 delete mode 100644 drivers/input/mouse/gpio_mouse.c

diff --git a/Documentation/driver-api/gpio/drivers-on-gpio.rst b/Documentation/driver-api/gpio/drivers-on-gpio.rst
index 95572d2a94ce..e386d909bc08 100644
--- a/Documentation/driver-api/gpio/drivers-on-gpio.rst
+++ b/Documentation/driver-api/gpio/drivers-on-gpio.rst
@@ -21,11 +21,6 @@ hardware descriptions such as device tree or ACPI:
   GPIO line cannot generate interrupts, so it needs to be periodically polled
   by a timer.
 
-- gpio_mouse: drivers/input/mouse/gpio_mouse.c is used to provide a mouse with
-  up to three buttons by simply using GPIOs and no mouse port. You can cut the
-  mouse cable and connect the wires to GPIO lines or solder a mouse connector
-  to the lines for a more permanent solution of this type.
-
 - gpio-beeper: drivers/input/misc/gpio-beeper.c is used to provide a beep from
   an external speaker connected to a GPIO line. (If the beep is controlled by
   off/on, for an actual PWM waveform, see pwm-gpio below.)
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index 074130d88953..5f2466c08b9a 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -332,21 +332,6 @@ config MOUSE_VSXXXAA
 	  described in the source file). This driver also works with the
 	  digitizer (VSXXX-AB) DEC produced.
 
-config MOUSE_GPIO
-	tristate "GPIO mouse"
-	depends on GPIOLIB || COMPILE_TEST
-	help
-	  This driver simulates a mouse on GPIO lines of various CPUs (and some
-	  other chips).
-
-	  Say Y here if your device has buttons or a simple joystick connected
-	  directly to GPIO lines. Your board-specific setup logic must also
-	  provide a platform device and platform data saying which GPIOs are
-	  used.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called gpio_mouse.
-
 config MOUSE_MAPLE
 	tristate "Maple mouse (for the Dreamcast)"
 	depends on MAPLE
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index ed40f141691e..52c0a99853b0 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -11,7 +11,6 @@ obj-$(CONFIG_MOUSE_ATARI)		+= atarimouse.o
 obj-$(CONFIG_MOUSE_BCM5974)		+= bcm5974.o
 obj-$(CONFIG_MOUSE_CYAPA)		+= cyapatp.o
 obj-$(CONFIG_MOUSE_ELAN_I2C)		+= elan_i2c.o
-obj-$(CONFIG_MOUSE_GPIO)		+= gpio_mouse.o
 obj-$(CONFIG_MOUSE_MAPLE)		+= maplemouse.o
 obj-$(CONFIG_MOUSE_PS2)			+= psmouse.o
 obj-$(CONFIG_MOUSE_RISCPC)		+= rpcmouse.o
diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c
deleted file mode 100644
index 18ccbd45004a..000000000000
--- a/drivers/input/mouse/gpio_mouse.c
+++ /dev/null
@@ -1,170 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Driver for simulating a mouse on GPIO lines.
- *
- * Copyright (C) 2007 Atmel Corporation
- * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org>
- */
-
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/input.h>
-#include <linux/gpio/consumer.h>
-#include <linux/property.h>
-#include <linux/of.h>
-
-/**
- * struct gpio_mouse
- * @scan_ms: the scan interval in milliseconds.
- * @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 {
-	u32 scan_ms;
-	struct gpio_desc *up;
-	struct gpio_desc *down;
-	struct gpio_desc *left;
-	struct gpio_desc *right;
-	struct gpio_desc *bleft;
-	struct gpio_desc *bmiddle;
-	struct gpio_desc *bright;
-};
-
-/*
- * Timer function which is run every scan_ms ms when the device is opened.
- * The dev input variable is set to the input_dev pointer.
- */
-static void gpio_mouse_scan(struct input_dev *input)
-{
-	struct gpio_mouse *gpio = input_get_drvdata(input);
-	int x, y;
-
-	if (gpio->bleft)
-		input_report_key(input, BTN_LEFT,
-				 gpiod_get_value(gpio->bleft));
-	if (gpio->bmiddle)
-		input_report_key(input, BTN_MIDDLE,
-				 gpiod_get_value(gpio->bmiddle));
-	if (gpio->bright)
-		input_report_key(input, BTN_RIGHT,
-				 gpiod_get_value(gpio->bright));
-
-	x = gpiod_get_value(gpio->right) - gpiod_get_value(gpio->left);
-	y = gpiod_get_value(gpio->down) - gpiod_get_value(gpio->up);
-
-	input_report_rel(input, REL_X, x);
-	input_report_rel(input, REL_Y, y);
-	input_sync(input);
-}
-
-static int gpio_mouse_probe(struct platform_device *pdev)
-{
-	struct device *dev = &pdev->dev;
-	struct gpio_mouse *gmouse;
-	struct input_dev *input;
-	int error;
-
-	gmouse = devm_kzalloc(dev, sizeof(*gmouse), GFP_KERNEL);
-	if (!gmouse)
-		return -ENOMEM;
-
-	/* Assign some default scanning time */
-	error = device_property_read_u32(dev, "scan-interval-ms",
-					 &gmouse->scan_ms);
-	if (error || gmouse->scan_ms == 0) {
-		dev_warn(dev, "invalid scan time, set to 50 ms\n");
-		gmouse->scan_ms = 50;
-	}
-
-	gmouse->up = devm_gpiod_get(dev, "up", GPIOD_IN);
-	if (IS_ERR(gmouse->up))
-		return PTR_ERR(gmouse->up);
-	gmouse->down = devm_gpiod_get(dev, "down", GPIOD_IN);
-	if (IS_ERR(gmouse->down))
-		return PTR_ERR(gmouse->down);
-	gmouse->left = devm_gpiod_get(dev, "left", GPIOD_IN);
-	if (IS_ERR(gmouse->left))
-		return PTR_ERR(gmouse->left);
-	gmouse->right = devm_gpiod_get(dev, "right", GPIOD_IN);
-	if (IS_ERR(gmouse->right))
-		return PTR_ERR(gmouse->right);
-
-	gmouse->bleft = devm_gpiod_get_optional(dev, "button-left", GPIOD_IN);
-	if (IS_ERR(gmouse->bleft))
-		return PTR_ERR(gmouse->bleft);
-	gmouse->bmiddle = devm_gpiod_get_optional(dev, "button-middle",
-						  GPIOD_IN);
-	if (IS_ERR(gmouse->bmiddle))
-		return PTR_ERR(gmouse->bmiddle);
-	gmouse->bright = devm_gpiod_get_optional(dev, "button-right",
-						 GPIOD_IN);
-	if (IS_ERR(gmouse->bright))
-		return PTR_ERR(gmouse->bright);
-
-	input = devm_input_allocate_device(dev);
-	if (!input)
-		return -ENOMEM;
-
-	input->name = pdev->name;
-	input->id.bustype = BUS_HOST;
-
-	input_set_drvdata(input, gmouse);
-
-	input_set_capability(input, EV_REL, REL_X);
-	input_set_capability(input, EV_REL, REL_Y);
-	if (gmouse->bleft)
-		input_set_capability(input, EV_KEY, BTN_LEFT);
-	if (gmouse->bmiddle)
-		input_set_capability(input, EV_KEY, BTN_MIDDLE);
-	if (gmouse->bright)
-		input_set_capability(input, EV_KEY, BTN_RIGHT);
-
-	error = input_setup_polling(input, gpio_mouse_scan);
-	if (error)
-		return error;
-
-	input_set_poll_interval(input, gmouse->scan_ms);
-
-	error = input_register_device(input);
-	if (error) {
-		dev_err(dev, "could not register input device\n");
-		return error;
-	}
-
-	dev_dbg(dev, "%d ms scan time, buttons: %s%s%s\n",
-		gmouse->scan_ms,
-		gmouse->bleft ? "" : "left ",
-		gmouse->bmiddle ? "" : "middle ",
-		gmouse->bright ? "" : "right");
-
-	return 0;
-}
-
-static const struct of_device_id gpio_mouse_of_match[] = {
-	{ .compatible = "gpio-mouse", },
-	{ },
-};
-MODULE_DEVICE_TABLE(of, gpio_mouse_of_match);
-
-static struct platform_driver gpio_mouse_device_driver = {
-	.probe		= gpio_mouse_probe,
-	.driver		= {
-		.name	= "gpio_mouse",
-		.of_match_table = gpio_mouse_of_match,
-	}
-};
-module_platform_driver(gpio_mouse_device_driver);
-
-MODULE_AUTHOR("Hans-Christian Egtvedt <egtvedt@samfundet.no>");
-MODULE_DESCRIPTION("GPIO mouse driver");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:gpio_mouse"); /* work with hotplug and coldplug */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: gpio_mouse - remove driver that has never been used in the kernel
  2026-09-19  8:36 [PATCH] Input: gpio_mouse - remove driver that has never been used in the kernel Ethan Nelson-Moore
@ 2026-09-19  8:44 ` sashiko-bot
  2026-09-19 12:12 ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-09-19  8:44 UTC (permalink / raw)
  To: Ethan Nelson-Moore; +Cc: dmitry.torokhov, linux-input

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] input: gpio_mouse: driver removal speculatively breaks device tree ABI
- [Low] input: gpio_mouse: incomplete cleanup leaves orphaned DT binding
--

commit ff6ae0c9a42236905d35103b1b6b9ce3be08070e
Author: Ethan Nelson-Moore <enelsonmoore@gmail.com>

Input: gpio_mouse - remove driver that has never been used in the kernel

This commit removes the gpio_mouse driver. The driver has been present since
2007 but lacks any in-tree references from platform data, device tree files,
or ACPI probing.

> diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c
> deleted file mode 100644
> index 18ccbd45004ad..0000000000000
> --- a/drivers/input/mouse/gpio_mouse.c
> +++ /dev/null
> @@ -1,170 +0,0 @@
[ ... ]
> -static const struct of_device_id gpio_mouse_of_match[] = {
> -	{ .compatible = "gpio-mouse", },
> -	{ },
> -};
> -MODULE_DEVICE_TABLE(of, gpio_mouse_of_match);

[Severity: Medium]
Could removing this driver break the Device Tree ABI for any out-of-tree
boards that currently rely on the "gpio-mouse" compatible string?

If a system bootloader or firmware passes a DTB with the "gpio-mouse"
compatible string, the driver will no longer exist to bind to it.

[Severity: Low]
Does this patch also need to remove the devicetree binding schema for
"gpio-mouse"?

The schema file Documentation/devicetree/bindings/input/gpio-mouse.yaml
appears to be left behind, leaving it as an orphaned document now that
the driver is removed.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260919083655.586922-1-enelsonmoore@gmail.com?part=1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: gpio_mouse - remove driver that has never been used in the kernel
  2026-09-19  8:36 [PATCH] Input: gpio_mouse - remove driver that has never been used in the kernel Ethan Nelson-Moore
  2026-09-19  8:44 ` sashiko-bot
@ 2026-09-19 12:12 ` Linus Walleij
  2026-09-19 22:56   ` Ethan Nelson-Moore
  2026-09-21  8:51   ` Bartosz Golaszewski
  1 sibling, 2 replies; 5+ messages in thread
From: Linus Walleij @ 2026-09-19 12:12 UTC (permalink / raw)
  To: Ethan Nelson-Moore
  Cc: Shuah Khan, Randy Dunlap, Dmitry Torokhov, Andres Salomon,
	Bjorn Helgaas, linux-gpio, linux-doc, linux-input,
	Hans-Christian Egtvedt, Bartosz Golaszewski, Jonathan Corbet

On Sat, Sep 19, 2026 at 10:37 AM Ethan Nelson-Moore
<enelsonmoore@gmail.com> wrote:

> The gpio_mouse driver was added in 2007, but it has never been
> referenced by any platform data or DTS files in the kernel, and it does
> not support ACPI probing. Therefore, it has clearly never been used by
> any users of unmodified mainline Linux. Remove it.
>
> Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>

Why though? It is fully modernized and probably has a value
for people like "makers" who just want to connect an oldschool
mouse to their random Raspberry Pi.

I think it's better if we focus on removing code that is just
using platform devices and hacks and is hopeless
to maintain. For example the OLPC...

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: gpio_mouse - remove driver that has never been used in the kernel
  2026-09-19 12:12 ` Linus Walleij
@ 2026-09-19 22:56   ` Ethan Nelson-Moore
  2026-09-21  8:51   ` Bartosz Golaszewski
  1 sibling, 0 replies; 5+ messages in thread
From: Ethan Nelson-Moore @ 2026-09-19 22:56 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Shuah Khan, Randy Dunlap, Dmitry Torokhov, Andres Salomon,
	Bjorn Helgaas, linux-gpio, linux-doc, linux-input,
	Hans-Christian Egtvedt, Bartosz Golaszewski, Jonathan Corbet

Hi, Linus,

On Sat, Sep 19, 2026 at 5:12 AM Linus Walleij <linusw@kernel.org> wrote:
> Why though? It is fully modernized and probably has a value
> for people like "makers" who just want to connect an oldschool
> mouse to their random Raspberry Pi.

You're right. The driver is so small, too.

> I think it's better if we focus on removing code that is just
> using platform devices and hacks and is hopeless
> to maintain. For example the OLPC...

That's a good idea. I've started working on a patch to remove OLPC
support - at least 6500 lines of code and I'm not even done yet!

Ethan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: gpio_mouse - remove driver that has never been used in the kernel
  2026-09-19 12:12 ` Linus Walleij
  2026-09-19 22:56   ` Ethan Nelson-Moore
@ 2026-09-21  8:51   ` Bartosz Golaszewski
  1 sibling, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-09-21  8:51 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Shuah Khan, Randy Dunlap, Dmitry Torokhov, Andres Salomon,
	Bjorn Helgaas, linux-gpio, linux-doc, linux-input,
	Hans-Christian Egtvedt, Bartosz Golaszewski, Jonathan Corbet,
	Ethan Nelson-Moore

On Sat, 19 Sep 2026 14:12:05 +0200, Linus Walleij <linusw@kernel.org> said:
> On Sat, Sep 19, 2026 at 10:37 AM Ethan Nelson-Moore
> <enelsonmoore@gmail.com> wrote:
>
>> The gpio_mouse driver was added in 2007, but it has never been
>> referenced by any platform data or DTS files in the kernel, and it does
>> not support ACPI probing. Therefore, it has clearly never been used by
>> any users of unmodified mainline Linux. Remove it.
>>
>> Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
>
> Why though? It is fully modernized and probably has a value
> for people like "makers" who just want to connect an oldschool
> mouse to their random Raspberry Pi.
>
> I think it's better if we focus on removing code that is just
> using platform devices and hacks and is hopeless
> to maintain. For example the OLPC...
>

Agreed. I support removing drivers tied to specific architectures that were
also removed but this is very generic and may see some use.

Bart

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-21  8:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-19  8:36 [PATCH] Input: gpio_mouse - remove driver that has never been used in the kernel Ethan Nelson-Moore
2026-09-19  8:44 ` sashiko-bot
2026-09-19 12:12 ` Linus Walleij
2026-09-19 22:56   ` Ethan Nelson-Moore
2026-09-21  8:51   ` Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.