Commit 4f8edc3c authored by Himangi Saraogi's avatar Himangi Saraogi Committed by Dmitry Torokhov

Input: da9034-ts - switch to using managed resources

Let's switch the driver to use managed resources, this will simplify error
handling and allows us to get rid of da9034_touch_remove().
Signed-off-by: default avatarHimangi Saraogi <himangi774@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent f5189d07
...@@ -301,10 +301,11 @@ static int da9034_touch_probe(struct platform_device *pdev) ...@@ -301,10 +301,11 @@ static int da9034_touch_probe(struct platform_device *pdev)
struct da9034_touch_pdata *pdata = dev_get_platdata(&pdev->dev); struct da9034_touch_pdata *pdata = dev_get_platdata(&pdev->dev);
struct da9034_touch *touch; struct da9034_touch *touch;
struct input_dev *input_dev; struct input_dev *input_dev;
int ret; int error;
touch = kzalloc(sizeof(struct da9034_touch), GFP_KERNEL); touch = devm_kzalloc(&pdev->dev, sizeof(struct da9034_touch),
if (touch == NULL) { GFP_KERNEL);
if (!touch) {
dev_err(&pdev->dev, "failed to allocate driver data\n"); dev_err(&pdev->dev, "failed to allocate driver data\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -315,18 +316,18 @@ static int da9034_touch_probe(struct platform_device *pdev) ...@@ -315,18 +316,18 @@ static int da9034_touch_probe(struct platform_device *pdev)
touch->interval_ms = pdata->interval_ms; touch->interval_ms = pdata->interval_ms;
touch->x_inverted = pdata->x_inverted; touch->x_inverted = pdata->x_inverted;
touch->y_inverted = pdata->y_inverted; touch->y_inverted = pdata->y_inverted;
} else } else {
/* fallback into default */ /* fallback into default */
touch->interval_ms = 10; touch->interval_ms = 10;
}
INIT_DELAYED_WORK(&touch->tsi_work, da9034_tsi_work); INIT_DELAYED_WORK(&touch->tsi_work, da9034_tsi_work);
touch->notifier.notifier_call = da9034_touch_notifier; touch->notifier.notifier_call = da9034_touch_notifier;
input_dev = input_allocate_device(); input_dev = devm_input_allocate_device(&pdev->dev);
if (!input_dev) { if (!input_dev) {
dev_err(&pdev->dev, "failed to allocate input device\n"); dev_err(&pdev->dev, "failed to allocate input device\n");
ret = -ENOMEM; return -ENOMEM;
goto err_free_touch;
} }
input_dev->name = pdev->name; input_dev->name = pdev->name;
...@@ -346,26 +347,9 @@ static int da9034_touch_probe(struct platform_device *pdev) ...@@ -346,26 +347,9 @@ static int da9034_touch_probe(struct platform_device *pdev)
touch->input_dev = input_dev; touch->input_dev = input_dev;
input_set_drvdata(input_dev, touch); input_set_drvdata(input_dev, touch);
ret = input_register_device(input_dev); error = input_register_device(input_dev);
if (ret) if (error)
goto err_free_input; return error;
platform_set_drvdata(pdev, touch);
return 0;
err_free_input:
input_free_device(input_dev);
err_free_touch:
kfree(touch);
return ret;
}
static int da9034_touch_remove(struct platform_device *pdev)
{
struct da9034_touch *touch = platform_get_drvdata(pdev);
input_unregister_device(touch->input_dev);
kfree(touch);
return 0; return 0;
} }
...@@ -376,7 +360,6 @@ static struct platform_driver da9034_touch_driver = { ...@@ -376,7 +360,6 @@ static struct platform_driver da9034_touch_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
.probe = da9034_touch_probe, .probe = da9034_touch_probe,
.remove = da9034_touch_remove,
}; };
module_platform_driver(da9034_touch_driver); module_platform_driver(da9034_touch_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