Commit 50525cb3 authored by Himangi Saraogi's avatar Himangi Saraogi Committed by Dmitry Torokhov

Input: jornada680_kbd - switch top using managed resources

Let's switch the driver to use managed resources, this will simplify
error handling and driver unbinding logic.
Signed-off-by: default avatarHimangi Saraogi <himangi774@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent ec62c7a8
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/device.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/input-polldev.h> #include <linux/input-polldev.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -185,14 +186,15 @@ static int jornada680kbd_probe(struct platform_device *pdev) ...@@ -185,14 +186,15 @@ static int jornada680kbd_probe(struct platform_device *pdev)
struct input_dev *input_dev; struct input_dev *input_dev;
int i, error; int i, error;
jornadakbd = kzalloc(sizeof(struct jornadakbd), GFP_KERNEL); jornadakbd = devm_kzalloc(&pdev->dev, sizeof(struct jornadakbd),
GFP_KERNEL);
if (!jornadakbd) if (!jornadakbd)
return -ENOMEM; return -ENOMEM;
poll_dev = input_allocate_polled_device(); poll_dev = devm_input_allocate_polled_device(&pdev->dev);
if (!poll_dev) { if (!poll_dev) {
error = -ENOMEM; dev_err(&pdev->dev, "failed to allocate polled input device\n");
goto failed; return -ENOMEM;
} }
platform_set_drvdata(pdev, jornadakbd); platform_set_drvdata(pdev, jornadakbd);
...@@ -224,27 +226,10 @@ static int jornada680kbd_probe(struct platform_device *pdev) ...@@ -224,27 +226,10 @@ static int jornada680kbd_probe(struct platform_device *pdev)
input_set_capability(input_dev, EV_MSC, MSC_SCAN); input_set_capability(input_dev, EV_MSC, MSC_SCAN);
error = input_register_polled_device(jornadakbd->poll_dev); error = input_register_polled_device(jornadakbd->poll_dev);
if (error) if (error) {
goto failed; dev_err(&pdev->dev, "failed to register polled input device\n");
return error;
return 0; }
failed:
printk(KERN_ERR "Jornadakbd: failed to register driver, error: %d\n",
error);
input_free_polled_device(poll_dev);
kfree(jornadakbd);
return error;
}
static int jornada680kbd_remove(struct platform_device *pdev)
{
struct jornadakbd *jornadakbd = platform_get_drvdata(pdev);
input_unregister_polled_device(jornadakbd->poll_dev);
input_free_polled_device(jornadakbd->poll_dev);
kfree(jornadakbd);
return 0; return 0;
} }
...@@ -255,7 +240,6 @@ static struct platform_driver jornada680kbd_driver = { ...@@ -255,7 +240,6 @@ static struct platform_driver jornada680kbd_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
.probe = jornada680kbd_probe, .probe = jornada680kbd_probe,
.remove = jornada680kbd_remove,
}; };
module_platform_driver(jornada680kbd_driver); module_platform_driver(jornada680kbd_driver);
......
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