diff options
Diffstat (limited to 'drivers/input/touchscreen/da9034-ts.c')
-rw-r--r-- | drivers/input/touchscreen/da9034-ts.c | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/drivers/input/touchscreen/da9034-ts.c b/drivers/input/touchscreen/da9034-ts.c index 8ccf7bb4028..cf6f4b31db4 100644 --- a/drivers/input/touchscreen/da9034-ts.c +++ b/drivers/input/touchscreen/da9034-ts.c @@ -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 *touch; struct input_dev *input_dev; - int ret; + int error; - touch = kzalloc(sizeof(struct da9034_touch), GFP_KERNEL); - if (touch == NULL) { + touch = devm_kzalloc(&pdev->dev, sizeof(struct da9034_touch), + GFP_KERNEL); + if (!touch) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; } @@ -315,18 +316,18 @@ static int da9034_touch_probe(struct platform_device *pdev) touch->interval_ms = pdata->interval_ms; touch->x_inverted = pdata->x_inverted; touch->y_inverted = pdata->y_inverted; - } else + } else { /* fallback into default */ touch->interval_ms = 10; + } INIT_DELAYED_WORK(&touch->tsi_work, da9034_tsi_work); touch->notifier.notifier_call = da9034_touch_notifier; - input_dev = input_allocate_device(); + input_dev = devm_input_allocate_device(&pdev->dev); if (!input_dev) { dev_err(&pdev->dev, "failed to allocate input device\n"); - ret = -ENOMEM; - goto err_free_touch; + return -ENOMEM; } input_dev->name = pdev->name; @@ -346,26 +347,9 @@ static int da9034_touch_probe(struct platform_device *pdev) touch->input_dev = input_dev; input_set_drvdata(input_dev, touch); - ret = input_register_device(input_dev); - if (ret) - goto err_free_input; - - 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); + error = input_register_device(input_dev); + if (error) + return error; return 0; } @@ -376,7 +360,6 @@ static struct platform_driver da9034_touch_driver = { .owner = THIS_MODULE, }, .probe = da9034_touch_probe, - .remove = da9034_touch_remove, }; module_platform_driver(da9034_touch_driver); |