mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
Input: adp5520-keys - 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: Himangi Saraogi <himangi774@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
4f8edc3c9c
commit
ec62c7a8f8
@ -12,6 +12,7 @@
|
|||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <linux/mfd/adp5520.h>
|
#include <linux/mfd/adp5520.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/device.h>
|
||||||
|
|
||||||
struct adp5520_keys {
|
struct adp5520_keys {
|
||||||
struct input_dev *input;
|
struct input_dev *input;
|
||||||
@ -81,7 +82,7 @@ static int adp5520_keys_probe(struct platform_device *pdev)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdata == NULL) {
|
if (!pdata) {
|
||||||
dev_err(&pdev->dev, "missing platform data\n");
|
dev_err(&pdev->dev, "missing platform data\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@ -89,17 +90,15 @@ static int adp5520_keys_probe(struct platform_device *pdev)
|
|||||||
if (!(pdata->rows_en_mask && pdata->cols_en_mask))
|
if (!(pdata->rows_en_mask && pdata->cols_en_mask))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
|
||||||
if (dev == NULL) {
|
if (!dev) {
|
||||||
dev_err(&pdev->dev, "failed to alloc memory\n");
|
dev_err(&pdev->dev, "failed to alloc memory\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
input = input_allocate_device();
|
input = devm_input_allocate_device(&pdev->dev);
|
||||||
if (!input) {
|
if (!input)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->master = pdev->dev.parent;
|
dev->master = pdev->dev.parent;
|
||||||
dev->input = input;
|
dev->input = input;
|
||||||
@ -135,7 +134,7 @@ static int adp5520_keys_probe(struct platform_device *pdev)
|
|||||||
ret = input_register_device(input);
|
ret = input_register_device(input);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "unable to register input device\n");
|
dev_err(&pdev->dev, "unable to register input device\n");
|
||||||
goto err;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
en_mask = pdata->rows_en_mask | pdata->cols_en_mask;
|
en_mask = pdata->rows_en_mask | pdata->cols_en_mask;
|
||||||
@ -157,8 +156,7 @@ static int adp5520_keys_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "failed to write\n");
|
dev_err(&pdev->dev, "failed to write\n");
|
||||||
ret = -EIO;
|
return -EIO;
|
||||||
goto err1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->notifier.notifier_call = adp5520_keys_notifier;
|
dev->notifier.notifier_call = adp5520_keys_notifier;
|
||||||
@ -166,19 +164,11 @@ static int adp5520_keys_probe(struct platform_device *pdev)
|
|||||||
ADP5520_KP_IEN | ADP5520_KR_IEN);
|
ADP5520_KP_IEN | ADP5520_KR_IEN);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "failed to register notifier\n");
|
dev_err(&pdev->dev, "failed to register notifier\n");
|
||||||
goto err1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, dev);
|
platform_set_drvdata(pdev, dev);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err1:
|
|
||||||
input_unregister_device(input);
|
|
||||||
input = NULL;
|
|
||||||
err:
|
|
||||||
input_free_device(input);
|
|
||||||
kfree(dev);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int adp5520_keys_remove(struct platform_device *pdev)
|
static int adp5520_keys_remove(struct platform_device *pdev)
|
||||||
@ -188,8 +178,6 @@ static int adp5520_keys_remove(struct platform_device *pdev)
|
|||||||
adp5520_unregister_notifier(dev->master, &dev->notifier,
|
adp5520_unregister_notifier(dev->master, &dev->notifier,
|
||||||
ADP5520_KP_IEN | ADP5520_KR_IEN);
|
ADP5520_KP_IEN | ADP5520_KR_IEN);
|
||||||
|
|
||||||
input_unregister_device(dev->input);
|
|
||||||
kfree(dev);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user