aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2013-01-11 12:05:42 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2013-01-21 20:31:03 -0500
commitc3ead16e7094076607d7c7c47aee280209d829f7 (patch)
tree3cdc85c273801e3079e742d63dd29c54da70d541
parentd7e34d12ba877fa77080257d2621c29769333c40 (diff)
Input: twl4030-vibra - switch to using managed resources
This simplifies error handling and eliminates the need for implementing remove() method. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/misc/twl4030-vibra.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/drivers/input/misc/twl4030-vibra.c b/drivers/input/misc/twl4030-vibra.c
index 78eb6b30580a..e2e2a261e02a 100644
--- a/drivers/input/misc/twl4030-vibra.c
+++ b/drivers/input/misc/twl4030-vibra.c
@@ -219,7 +219,7 @@ static int twl4030_vibra_probe(struct platform_device *pdev)
219 return -EINVAL; 219 return -EINVAL;
220 } 220 }
221 221
222 info = kzalloc(sizeof(*info), GFP_KERNEL); 222 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
223 if (!info) 223 if (!info)
224 return -ENOMEM; 224 return -ENOMEM;
225 225
@@ -227,11 +227,10 @@ static int twl4030_vibra_probe(struct platform_device *pdev)
227 info->coexist = twl4030_vibra_check_coexist(pdata, twl4030_core_node); 227 info->coexist = twl4030_vibra_check_coexist(pdata, twl4030_core_node);
228 INIT_WORK(&info->play_work, vibra_play_work); 228 INIT_WORK(&info->play_work, vibra_play_work);
229 229
230 info->input_dev = input_allocate_device(); 230 info->input_dev = devm_input_allocate_device(&pdev->dev);
231 if (info->input_dev == NULL) { 231 if (info->input_dev == NULL) {
232 dev_err(&pdev->dev, "couldn't allocate input device\n"); 232 dev_err(&pdev->dev, "couldn't allocate input device\n");
233 ret = -ENOMEM; 233 return -ENOMEM;
234 goto err_kzalloc;
235 } 234 }
236 235
237 input_set_drvdata(info->input_dev, info); 236 input_set_drvdata(info->input_dev, info);
@@ -246,7 +245,7 @@ static int twl4030_vibra_probe(struct platform_device *pdev)
246 ret = input_ff_create_memless(info->input_dev, NULL, vibra_play); 245 ret = input_ff_create_memless(info->input_dev, NULL, vibra_play);
247 if (ret < 0) { 246 if (ret < 0) {
248 dev_dbg(&pdev->dev, "couldn't register vibrator to FF\n"); 247 dev_dbg(&pdev->dev, "couldn't register vibrator to FF\n");
249 goto err_ialloc; 248 return ret;
250 } 249 }
251 250
252 ret = input_register_device(info->input_dev); 251 ret = input_register_device(info->input_dev);
@@ -262,28 +261,11 @@ static int twl4030_vibra_probe(struct platform_device *pdev)
262 261
263err_iff: 262err_iff:
264 input_ff_destroy(info->input_dev); 263 input_ff_destroy(info->input_dev);
265err_ialloc:
266 input_free_device(info->input_dev);
267err_kzalloc:
268 kfree(info);
269 return ret; 264 return ret;
270} 265}
271 266
272static int twl4030_vibra_remove(struct platform_device *pdev)
273{
274 struct vibra_info *info = platform_get_drvdata(pdev);
275
276 /* this also free ff-memless and calls close if needed */
277 input_unregister_device(info->input_dev);
278 kfree(info);
279 platform_set_drvdata(pdev, NULL);
280
281 return 0;
282}
283
284static struct platform_driver twl4030_vibra_driver = { 267static struct platform_driver twl4030_vibra_driver = {
285 .probe = twl4030_vibra_probe, 268 .probe = twl4030_vibra_probe,
286 .remove = twl4030_vibra_remove,
287 .driver = { 269 .driver = {
288 .name = "twl4030-vibra", 270 .name = "twl4030-vibra",
289 .owner = THIS_MODULE, 271 .owner = THIS_MODULE,