[2/8] Input: amikbd - convert to use devm_* api

Message ID 20230714080611.81302-2-frank.li@vivo.com
State New
Headers
Series [1/8] Input: lm8333 - convert to use devm_* api |

Commit Message

李扬韬 July 14, 2023, 8:06 a.m. UTC
  Use devm_* api to simplify code, this makes it unnecessary to explicitly
release resources.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/input/keyboard/amikbd.c | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
  

Comments

Dmitry Torokhov July 24, 2023, 5:33 a.m. UTC | #1
On Fri, Jul 14, 2023 at 04:06:05PM +0800, Yangtao Li wrote:
> Use devm_* api to simplify code, this makes it unnecessary to explicitly
> release resources.

Applied with minor changes, thank you.
  

Patch

diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c
index a20a4e186639..4cbac79f5a4b 100644
--- a/drivers/input/keyboard/amikbd.c
+++ b/drivers/input/keyboard/amikbd.c
@@ -193,10 +193,11 @@  static irqreturn_t amikbd_interrupt(int irq, void *data)
 
 static int __init amikbd_probe(struct platform_device *pdev)
 {
+	struct device *device = &pdev->dev;
 	struct input_dev *dev;
 	int i, err;
 
-	dev = input_allocate_device();
+	dev = devm_input_allocate_device(device);
 	if (!dev) {
 		dev_err(&pdev->dev, "Not enough memory for input device\n");
 		return -ENOMEM;
@@ -218,35 +219,21 @@  static int __init amikbd_probe(struct platform_device *pdev)
 	amikbd_init_console_keymaps();
 
 	ciaa.cra &= ~0x41;	 /* serial data in, turn off TA */
-	err = request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd",
-			  dev);
+	err = devm_request_irq(device, IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd",
+			       dev);
 	if (err)
-		goto fail2;
+		return err;
 
 	err = input_register_device(dev);
 	if (err)
-		goto fail3;
+		return err;
 
 	platform_set_drvdata(pdev, dev);
 
 	return 0;
-
- fail3:	free_irq(IRQ_AMIGA_CIAA_SP, dev);
- fail2:	input_free_device(dev);
-	return err;
-}
-
-static int __exit amikbd_remove(struct platform_device *pdev)
-{
-	struct input_dev *dev = platform_get_drvdata(pdev);
-
-	free_irq(IRQ_AMIGA_CIAA_SP, dev);
-	input_unregister_device(dev);
-	return 0;
 }
 
 static struct platform_driver amikbd_driver = {
-	.remove = __exit_p(amikbd_remove),
 	.driver   = {
 		.name	= "amiga-keyboard",
 	},