diff mbox series

Input: applespi - add missed input_unregister_device

Message ID 20200507151041.792460-1-hslester96@gmail.com
State New
Headers show
Series Input: applespi - add missed input_unregister_device | expand

Commit Message

Chuhong Yuan May 7, 2020, 3:10 p.m. UTC
This driver calls input_register_device() in probe, but misses
input_unregister_device() in probe failure and remove.
Add the missed function calls to fix it.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
 drivers/input/keyboard/applespi.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Dmitry Torokhov May 7, 2020, 4 p.m. UTC | #1
Hi Chuhong,

On Thu, May 07, 2020 at 11:10:41PM +0800, Chuhong Yuan wrote:
> This driver calls input_register_device() in probe, but misses
> input_unregister_device() in probe failure and remove.
> Add the missed function calls to fix it.

The input device in question is devm-managed and therefore does not need
explicit unregistering.

Thanks.
diff mbox series

Patch

diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c
index d38398526965..8ee9fdb562a5 100644
--- a/drivers/input/keyboard/applespi.c
+++ b/drivers/input/keyboard/applespi.c
@@ -1745,7 +1745,7 @@  static int applespi_probe(struct spi_device *spi)
 		dev_err(&applespi->spi->dev,
 			"Failed to obtain GPE for SPI slave device: %s\n",
 			acpi_format_exception(acpi_sts));
-		return -ENODEV;
+		goto err_unregister;
 	}
 	applespi->gpe = (int)gpe;
 
@@ -1756,7 +1756,7 @@  static int applespi_probe(struct spi_device *spi)
 		dev_err(&applespi->spi->dev,
 			"Failed to install GPE handler for GPE %d: %s\n",
 			applespi->gpe, acpi_format_exception(acpi_sts));
-		return -ENODEV;
+		goto err_unregister;
 	}
 
 	applespi->suspended = false;
@@ -1767,7 +1767,7 @@  static int applespi_probe(struct spi_device *spi)
 			"Failed to enable GPE handler for GPE %d: %s\n",
 			applespi->gpe, acpi_format_exception(acpi_sts));
 		acpi_remove_gpe_handler(NULL, applespi->gpe, applespi_notify);
-		return -ENODEV;
+		goto err_unregister;
 	}
 
 	/* trigger touchpad setup */
@@ -1805,6 +1805,10 @@  static int applespi_probe(struct spi_device *spi)
 			    &applespi_tp_dim_fops);
 
 	return 0;
+
+err_unregister:
+	input_unregister_device(applespi->keyboard_input_dev);
+	return -ENODEV;
 }
 
 static void applespi_drain_writes(struct applespi_data *applespi)
@@ -1847,6 +1851,7 @@  static int applespi_remove(struct spi_device *spi)
 	applespi_drain_reads(applespi);
 
 	debugfs_remove_recursive(applespi->debugfs_root);
+	input_unregister_device(applespi->keyboard_input_dev);
 
 	return 0;
 }