Commit caddca33 authored by Yangtao Li's avatar Yangtao Li Committed by Dmitry Torokhov

Input: amikbd - convert to use devm_* api

Use devm_* api to simplify code, this makes it unnecessary to explicitly
release resources.
Signed-off-by: default avatarYangtao Li <frank.li@vivo.com>
Link: https://lore.kernel.org/r/20230714080611.81302-2-frank.li@vivo.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 2b6aa9e7
...@@ -196,7 +196,7 @@ static int __init amikbd_probe(struct platform_device *pdev) ...@@ -196,7 +196,7 @@ static int __init amikbd_probe(struct platform_device *pdev)
struct input_dev *dev; struct input_dev *dev;
int i, err; int i, err;
dev = input_allocate_device(); dev = devm_input_allocate_device(&pdev->dev);
if (!dev) { if (!dev) {
dev_err(&pdev->dev, "Not enough memory for input device\n"); dev_err(&pdev->dev, "Not enough memory for input device\n");
return -ENOMEM; return -ENOMEM;
...@@ -208,7 +208,6 @@ static int __init amikbd_probe(struct platform_device *pdev) ...@@ -208,7 +208,6 @@ static int __init amikbd_probe(struct platform_device *pdev)
dev->id.vendor = 0x0001; dev->id.vendor = 0x0001;
dev->id.product = 0x0001; dev->id.product = 0x0001;
dev->id.version = 0x0100; dev->id.version = 0x0100;
dev->dev.parent = &pdev->dev;
dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
...@@ -218,35 +217,21 @@ static int __init amikbd_probe(struct platform_device *pdev) ...@@ -218,35 +217,21 @@ static int __init amikbd_probe(struct platform_device *pdev)
amikbd_init_console_keymaps(); amikbd_init_console_keymaps();
ciaa.cra &= ~0x41; /* serial data in, turn off TA */ ciaa.cra &= ~0x41; /* serial data in, turn off TA */
err = request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", err = devm_request_irq(&pdev->dev, IRQ_AMIGA_CIAA_SP, amikbd_interrupt,
dev); 0, "amikbd", dev);
if (err) if (err)
goto fail2; return err;
err = input_register_device(dev); err = input_register_device(dev);
if (err) if (err)
goto fail3; return err;
platform_set_drvdata(pdev, dev); platform_set_drvdata(pdev, dev);
return 0; 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 = { static struct platform_driver amikbd_driver = {
.remove = __exit_p(amikbd_remove),
.driver = { .driver = {
.name = "amiga-keyboard", .name = "amiga-keyboard",
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment