diff options
| author | Himangi Saraogi <himangi774@gmail.com> | 2014-05-21 11:27:06 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-05-29 02:48:36 -0400 |
| commit | 4f8edc3c9c7e78f7c22338470d0f330f11b1ba9a (patch) | |
| tree | dad4b676f704ed55f2d7aaf370e5bc6c75bde9e6 | |
| parent | f5189d07923f0829a83d15a13691c67586ceb84f (diff) | |
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: Himangi Saraogi <himangi774@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
| -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 8ccf7bb4028a..cf6f4b31db4d 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) | |||
| 301 | struct da9034_touch_pdata *pdata = dev_get_platdata(&pdev->dev); | 301 | struct da9034_touch_pdata *pdata = dev_get_platdata(&pdev->dev); |
| 302 | struct da9034_touch *touch; | 302 | struct da9034_touch *touch; |
| 303 | struct input_dev *input_dev; | 303 | struct input_dev *input_dev; |
| 304 | int ret; | 304 | int error; |
| 305 | 305 | ||
| 306 | touch = kzalloc(sizeof(struct da9034_touch), GFP_KERNEL); | 306 | touch = devm_kzalloc(&pdev->dev, sizeof(struct da9034_touch), |
| 307 | if (touch == NULL) { | 307 | GFP_KERNEL); |
| 308 | if (!touch) { | ||
| 308 | dev_err(&pdev->dev, "failed to allocate driver data\n"); | 309 | dev_err(&pdev->dev, "failed to allocate driver data\n"); |
| 309 | return -ENOMEM; | 310 | return -ENOMEM; |
| 310 | } | 311 | } |
| @@ -315,18 +316,18 @@ static int da9034_touch_probe(struct platform_device *pdev) | |||
| 315 | touch->interval_ms = pdata->interval_ms; | 316 | touch->interval_ms = pdata->interval_ms; |
| 316 | touch->x_inverted = pdata->x_inverted; | 317 | touch->x_inverted = pdata->x_inverted; |
| 317 | touch->y_inverted = pdata->y_inverted; | 318 | touch->y_inverted = pdata->y_inverted; |
| 318 | } else | 319 | } else { |
| 319 | /* fallback into default */ | 320 | /* fallback into default */ |
| 320 | touch->interval_ms = 10; | 321 | touch->interval_ms = 10; |
| 322 | } | ||
| 321 | 323 | ||
| 322 | INIT_DELAYED_WORK(&touch->tsi_work, da9034_tsi_work); | 324 | INIT_DELAYED_WORK(&touch->tsi_work, da9034_tsi_work); |
| 323 | touch->notifier.notifier_call = da9034_touch_notifier; | 325 | touch->notifier.notifier_call = da9034_touch_notifier; |
| 324 | 326 | ||
| 325 | input_dev = input_allocate_device(); | 327 | input_dev = devm_input_allocate_device(&pdev->dev); |
| 326 | if (!input_dev) { | 328 | if (!input_dev) { |
| 327 | dev_err(&pdev->dev, "failed to allocate input device\n"); | 329 | dev_err(&pdev->dev, "failed to allocate input device\n"); |
| 328 | ret = -ENOMEM; | 330 | return -ENOMEM; |
| 329 | goto err_free_touch; | ||
| 330 | } | 331 | } |
| 331 | 332 | ||
| 332 | input_dev->name = pdev->name; | 333 | input_dev->name = pdev->name; |
| @@ -346,26 +347,9 @@ static int da9034_touch_probe(struct platform_device *pdev) | |||
| 346 | touch->input_dev = input_dev; | 347 | touch->input_dev = input_dev; |
| 347 | input_set_drvdata(input_dev, touch); | 348 | input_set_drvdata(input_dev, touch); |
| 348 | 349 | ||
| 349 | ret = input_register_device(input_dev); | 350 | error = input_register_device(input_dev); |
| 350 | if (ret) | 351 | if (error) |
| 351 | goto err_free_input; | 352 | return error; |
| 352 | |||
| 353 | platform_set_drvdata(pdev, touch); | ||
| 354 | return 0; | ||
| 355 | |||
| 356 | err_free_input: | ||
| 357 | input_free_device(input_dev); | ||
| 358 | err_free_touch: | ||
| 359 | kfree(touch); | ||
| 360 | return ret; | ||
| 361 | } | ||
| 362 | |||
| 363 | static int da9034_touch_remove(struct platform_device *pdev) | ||
| 364 | { | ||
| 365 | struct da9034_touch *touch = platform_get_drvdata(pdev); | ||
| 366 | |||
| 367 | input_unregister_device(touch->input_dev); | ||
| 368 | kfree(touch); | ||
| 369 | 353 | ||
| 370 | return 0; | 354 | return 0; |
| 371 | } | 355 | } |
| @@ -376,7 +360,6 @@ static struct platform_driver da9034_touch_driver = { | |||
| 376 | .owner = THIS_MODULE, | 360 | .owner = THIS_MODULE, |
| 377 | }, | 361 | }, |
| 378 | .probe = da9034_touch_probe, | 362 | .probe = da9034_touch_probe, |
| 379 | .remove = da9034_touch_remove, | ||
| 380 | }; | 363 | }; |
| 381 | module_platform_driver(da9034_touch_driver); | 364 | module_platform_driver(da9034_touch_driver); |
| 382 | 365 | ||
