Input: amikbd - convert to use devm_* api
authorYangtao Li <frank.li@vivo.com>
Thu, 20 Jul 2023 22:38:03 +0000 (15:38 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 20 Jul 2023 23:52:48 +0000 (16:52 -0700)
Use devm_* api to simplify code, this makes it unnecessary to explicitly
release resources.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Link: https://lore.kernel.org/r/20230714080611.81302-2-frank.li@vivo.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/keyboard/amikbd.c

index a20a4e1..e305c44 100644 (file)
@@ -196,7 +196,7 @@ static int __init amikbd_probe(struct platform_device *pdev)
        struct input_dev *dev;
        int i, err;
 
-       dev = input_allocate_device();
+       dev = devm_input_allocate_device(&pdev->dev);
        if (!dev) {
                dev_err(&pdev->dev, "Not enough memory for input device\n");
                return -ENOMEM;
@@ -208,7 +208,6 @@ static int __init amikbd_probe(struct platform_device *pdev)
        dev->id.vendor = 0x0001;
        dev->id.product = 0x0001;
        dev->id.version = 0x0100;
-       dev->dev.parent = &pdev->dev;
 
        dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
 
@@ -218,35 +217,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(&pdev->dev, 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",
        },