Commit cde51e73 authored by Himangi Saraogi's avatar Himangi Saraogi Committed by Dmitry Torokhov

Input: 88pm860x_onkey - switch to 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>
Acked-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 157d45fb
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/mfd/88pm860x.h> #include <linux/mfd/88pm860x.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/device.h>
#define PM8607_WAKEUP 0x0b #define PM8607_WAKEUP 0x0b
...@@ -68,7 +69,8 @@ static int pm860x_onkey_probe(struct platform_device *pdev) ...@@ -68,7 +69,8 @@ static int pm860x_onkey_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
info = kzalloc(sizeof(struct pm860x_onkey_info), GFP_KERNEL); info = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_onkey_info),
GFP_KERNEL);
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;
info->chip = chip; info->chip = chip;
...@@ -76,11 +78,10 @@ static int pm860x_onkey_probe(struct platform_device *pdev) ...@@ -76,11 +78,10 @@ static int pm860x_onkey_probe(struct platform_device *pdev)
info->dev = &pdev->dev; info->dev = &pdev->dev;
info->irq = irq; info->irq = irq;
info->idev = input_allocate_device(); info->idev = devm_input_allocate_device(&pdev->dev);
if (!info->idev) { if (!info->idev) {
dev_err(chip->dev, "Failed to allocate input dev\n"); dev_err(chip->dev, "Failed to allocate input dev\n");
ret = -ENOMEM; return -ENOMEM;
goto out;
} }
info->idev->name = "88pm860x_on"; info->idev->name = "88pm860x_on";
...@@ -93,42 +94,22 @@ static int pm860x_onkey_probe(struct platform_device *pdev) ...@@ -93,42 +94,22 @@ static int pm860x_onkey_probe(struct platform_device *pdev)
ret = input_register_device(info->idev); ret = input_register_device(info->idev);
if (ret) { if (ret) {
dev_err(chip->dev, "Can't register input device: %d\n", ret); dev_err(chip->dev, "Can't register input device: %d\n", ret);
goto out_reg; return ret;
} }
ret = request_threaded_irq(info->irq, NULL, pm860x_onkey_handler, ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
IRQF_ONESHOT, "onkey", info); pm860x_onkey_handler, IRQF_ONESHOT,
"onkey", info);
if (ret < 0) { if (ret < 0) {
dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
info->irq, ret); info->irq, ret);
goto out_irq; return ret;
} }
platform_set_drvdata(pdev, info); platform_set_drvdata(pdev, info);
device_init_wakeup(&pdev->dev, 1); device_init_wakeup(&pdev->dev, 1);
return 0; return 0;
out_irq:
input_unregister_device(info->idev);
kfree(info);
return ret;
out_reg:
input_free_device(info->idev);
out:
kfree(info);
return ret;
}
static int pm860x_onkey_remove(struct platform_device *pdev)
{
struct pm860x_onkey_info *info = platform_get_drvdata(pdev);
free_irq(info->irq, info);
input_unregister_device(info->idev);
kfree(info);
return 0;
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
...@@ -161,7 +142,6 @@ static struct platform_driver pm860x_onkey_driver = { ...@@ -161,7 +142,6 @@ static struct platform_driver pm860x_onkey_driver = {
.pm = &pm860x_onkey_pm_ops, .pm = &pm860x_onkey_pm_ops,
}, },
.probe = pm860x_onkey_probe, .probe = pm860x_onkey_probe,
.remove = pm860x_onkey_remove,
}; };
module_platform_driver(pm860x_onkey_driver); module_platform_driver(pm860x_onkey_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