mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yangtao Li <frank.li@vivo.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Yangtao Li <frank.li@vivo.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/8] Input: amikbd - convert to use devm_* api
Date: Fri, 14 Jul 2023 16:06:05 +0800	[thread overview]
Message-ID: <20230714080611.81302-2-frank.li@vivo.com> (raw)
In-Reply-To: <20230714080611.81302-1-frank.li@vivo.com>

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(-)

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",
 	},
-- 
2.39.0


  reply	other threads:[~2023-07-14  8:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-14  8:06 [PATCH 1/8] Input: lm8333 " Yangtao Li
2023-07-14  8:06 ` Yangtao Li [this message]
2023-07-24  5:33   ` [PATCH 2/8] Input: amikbd " Dmitry Torokhov
2023-07-14  8:06 ` [PATCH 3/8] Input: mcs-touchkey " Yangtao Li
2023-07-24  5:34   ` Dmitry Torokhov
2023-07-14  8:06 ` [PATCH 4/8] Input: tca6416-keypad " Yangtao Li
2023-07-24  5:38   ` Dmitry Torokhov
2023-07-14  8:06 ` [PATCH 5/8] Input: qt1070 " Yangtao Li
2023-07-24  5:35   ` Dmitry Torokhov
2023-07-14  8:06 ` [PATCH 6/8] Input: sh-keysc " Yangtao Li
2023-07-24  5:39   ` Dmitry Torokhov
2023-07-14  8:06 ` [PATCH 7/8] Input: qt2160 " Yangtao Li
2023-07-24  5:19   ` Dmitry Torokhov
2023-07-14  8:06 ` [PATCH 8/8] Input: lm8323 " Yangtao Li
2023-07-24  5:37   ` Dmitry Torokhov
2023-07-24  5:32 ` [PATCH 1/8] Input: lm8333 " Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230714080611.81302-2-frank.li@vivo.com \
    --to=frank.li@vivo.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®