diff options
| author | Himangi Saraogi <himangi774@gmail.com> | 2014-05-29 03:19:45 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-05-29 03:26:35 -0400 |
| commit | 5ac66de5744b832530645ad82935d7357dba7afc (patch) | |
| tree | b7ef5909604fa65e0f5ec6a8b25e6eff800c927c | |
| parent | cde51e73cbfa00a85b17bb5dfc0a465d9233660e (diff) | |
Input: 88pm860x-ts - 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>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
| -rw-r--r-- | drivers/input/touchscreen/88pm860x-ts.c | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c index 544e20c551f8..0d4a9fad4a78 100644 --- a/drivers/input/touchscreen/88pm860x-ts.c +++ b/drivers/input/touchscreen/88pm860x-ts.c | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include <linux/input.h> | 16 | #include <linux/input.h> |
| 17 | #include <linux/mfd/88pm860x.h> | 17 | #include <linux/mfd/88pm860x.h> |
| 18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
| 19 | #include <linux/device.h> | ||
| 19 | 20 | ||
| 20 | #define MEAS_LEN (8) | 21 | #define MEAS_LEN (8) |
| 21 | #define ACCURATE_BIT (12) | 22 | #define ACCURATE_BIT (12) |
| @@ -234,16 +235,17 @@ static int pm860x_touch_probe(struct platform_device *pdev) | |||
| 234 | if (ret) | 235 | if (ret) |
| 235 | return ret; | 236 | return ret; |
| 236 | 237 | ||
| 237 | touch = kzalloc(sizeof(struct pm860x_touch), GFP_KERNEL); | 238 | touch = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_touch), |
| 238 | if (touch == NULL) | 239 | GFP_KERNEL); |
| 240 | if (!touch) | ||
| 239 | return -ENOMEM; | 241 | return -ENOMEM; |
| 242 | |||
| 240 | platform_set_drvdata(pdev, touch); | 243 | platform_set_drvdata(pdev, touch); |
| 241 | 244 | ||
| 242 | touch->idev = input_allocate_device(); | 245 | touch->idev = devm_input_allocate_device(&pdev->dev); |
| 243 | if (touch->idev == NULL) { | 246 | if (!touch->idev) { |
| 244 | dev_err(&pdev->dev, "Failed to allocate input device!\n"); | 247 | dev_err(&pdev->dev, "Failed to allocate input device!\n"); |
| 245 | ret = -ENOMEM; | 248 | return -ENOMEM; |
| 246 | goto out; | ||
| 247 | } | 249 | } |
| 248 | 250 | ||
| 249 | touch->idev->name = "88pm860x-touch"; | 251 | touch->idev->name = "88pm860x-touch"; |
| @@ -258,10 +260,11 @@ static int pm860x_touch_probe(struct platform_device *pdev) | |||
| 258 | touch->res_x = res_x; | 260 | touch->res_x = res_x; |
| 259 | input_set_drvdata(touch->idev, touch); | 261 | input_set_drvdata(touch->idev, touch); |
| 260 | 262 | ||
| 261 | ret = request_threaded_irq(touch->irq, NULL, pm860x_touch_handler, | 263 | ret = devm_request_threaded_irq(&pdev->dev, touch->irq, NULL, |
| 262 | IRQF_ONESHOT, "touch", touch); | 264 | pm860x_touch_handler, IRQF_ONESHOT, |
| 265 | "touch", touch); | ||
| 263 | if (ret < 0) | 266 | if (ret < 0) |
| 264 | goto out_irq; | 267 | return ret; |
| 265 | 268 | ||
| 266 | __set_bit(EV_ABS, touch->idev->evbit); | 269 | __set_bit(EV_ABS, touch->idev->evbit); |
| 267 | __set_bit(ABS_X, touch->idev->absbit); | 270 | __set_bit(ABS_X, touch->idev->absbit); |
| @@ -279,28 +282,11 @@ static int pm860x_touch_probe(struct platform_device *pdev) | |||
| 279 | ret = input_register_device(touch->idev); | 282 | ret = input_register_device(touch->idev); |
| 280 | if (ret < 0) { | 283 | if (ret < 0) { |
| 281 | dev_err(chip->dev, "Failed to register touch!\n"); | 284 | dev_err(chip->dev, "Failed to register touch!\n"); |
| 282 | goto out_rg; | 285 | return ret; |
| 283 | } | 286 | } |
| 284 | 287 | ||
| 285 | platform_set_drvdata(pdev, touch); | 288 | platform_set_drvdata(pdev, touch); |
| 286 | return 0; | 289 | return 0; |
| 287 | out_rg: | ||
| 288 | free_irq(touch->irq, touch); | ||
| 289 | out_irq: | ||
| 290 | input_free_device(touch->idev); | ||
| 291 | out: | ||
| 292 | kfree(touch); | ||
| 293 | return ret; | ||
| 294 | } | ||
| 295 | |||
| 296 | static int pm860x_touch_remove(struct platform_device *pdev) | ||
| 297 | { | ||
| 298 | struct pm860x_touch *touch = platform_get_drvdata(pdev); | ||
| 299 | |||
| 300 | input_unregister_device(touch->idev); | ||
| 301 | free_irq(touch->irq, touch); | ||
| 302 | kfree(touch); | ||
| 303 | return 0; | ||
| 304 | } | 290 | } |
| 305 | 291 | ||
| 306 | static struct platform_driver pm860x_touch_driver = { | 292 | static struct platform_driver pm860x_touch_driver = { |
| @@ -309,7 +295,6 @@ static struct platform_driver pm860x_touch_driver = { | |||
| 309 | .owner = THIS_MODULE, | 295 | .owner = THIS_MODULE, |
| 310 | }, | 296 | }, |
| 311 | .probe = pm860x_touch_probe, | 297 | .probe = pm860x_touch_probe, |
| 312 | .remove = pm860x_touch_remove, | ||
| 313 | }; | 298 | }; |
| 314 | module_platform_driver(pm860x_touch_driver); | 299 | module_platform_driver(pm860x_touch_driver); |
| 315 | 300 | ||
