diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-02-20 01:05:39 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-02-20 01:05:39 -0500 |
commit | 2d9f0d964be94fd51c7303288c6f9c88bf2381fe (patch) | |
tree | 2631c3e82abc145a6e9c8e2c18687833c71de012 /drivers/input/misc/twl6040-vibra.c | |
parent | 9937c026820baabd1e908a9c1e6bdc846293000a (diff) | |
parent | 005a69d632cd8694061c2dd27492fe874780b5ee (diff) |
Merge branch 'next' into for-linus
Prepare first set of updates for 3.9 merge window.
Diffstat (limited to 'drivers/input/misc/twl6040-vibra.c')
-rw-r--r-- | drivers/input/misc/twl6040-vibra.c | 100 |
1 files changed, 41 insertions, 59 deletions
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c index 71a28ee699f3..0c2dfc8e9691 100644 --- a/drivers/input/misc/twl6040-vibra.c +++ b/drivers/input/misc/twl6040-vibra.c | |||
@@ -275,7 +275,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev) | |||
275 | return -EINVAL; | 275 | return -EINVAL; |
276 | } | 276 | } |
277 | 277 | ||
278 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 278 | info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); |
279 | if (!info) { | 279 | if (!info) { |
280 | dev_err(&pdev->dev, "couldn't allocate memory\n"); | 280 | dev_err(&pdev->dev, "couldn't allocate memory\n"); |
281 | return -ENOMEM; | 281 | return -ENOMEM; |
@@ -309,53 +309,23 @@ static int twl6040_vibra_probe(struct platform_device *pdev) | |||
309 | if ((!info->vibldrv_res && !info->viblmotor_res) || | 309 | if ((!info->vibldrv_res && !info->viblmotor_res) || |
310 | (!info->vibrdrv_res && !info->vibrmotor_res)) { | 310 | (!info->vibrdrv_res && !info->vibrmotor_res)) { |
311 | dev_err(info->dev, "invalid vibra driver/motor resistance\n"); | 311 | dev_err(info->dev, "invalid vibra driver/motor resistance\n"); |
312 | ret = -EINVAL; | 312 | return -EINVAL; |
313 | goto err_kzalloc; | ||
314 | } | 313 | } |
315 | 314 | ||
316 | info->irq = platform_get_irq(pdev, 0); | 315 | info->irq = platform_get_irq(pdev, 0); |
317 | if (info->irq < 0) { | 316 | if (info->irq < 0) { |
318 | dev_err(info->dev, "invalid irq\n"); | 317 | dev_err(info->dev, "invalid irq\n"); |
319 | ret = -EINVAL; | 318 | return -EINVAL; |
320 | goto err_kzalloc; | ||
321 | } | 319 | } |
322 | 320 | ||
323 | mutex_init(&info->mutex); | 321 | mutex_init(&info->mutex); |
324 | 322 | ||
325 | info->input_dev = input_allocate_device(); | 323 | ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, |
326 | if (info->input_dev == NULL) { | 324 | twl6040_vib_irq_handler, 0, |
327 | dev_err(info->dev, "couldn't allocate input device\n"); | 325 | "twl6040_irq_vib", info); |
328 | ret = -ENOMEM; | ||
329 | goto err_kzalloc; | ||
330 | } | ||
331 | |||
332 | input_set_drvdata(info->input_dev, info); | ||
333 | |||
334 | info->input_dev->name = "twl6040:vibrator"; | ||
335 | info->input_dev->id.version = 1; | ||
336 | info->input_dev->dev.parent = pdev->dev.parent; | ||
337 | info->input_dev->close = twl6040_vibra_close; | ||
338 | __set_bit(FF_RUMBLE, info->input_dev->ffbit); | ||
339 | |||
340 | ret = input_ff_create_memless(info->input_dev, NULL, vibra_play); | ||
341 | if (ret < 0) { | ||
342 | dev_err(info->dev, "couldn't register vibrator to FF\n"); | ||
343 | goto err_ialloc; | ||
344 | } | ||
345 | |||
346 | ret = input_register_device(info->input_dev); | ||
347 | if (ret < 0) { | ||
348 | dev_err(info->dev, "couldn't register input device\n"); | ||
349 | goto err_iff; | ||
350 | } | ||
351 | |||
352 | platform_set_drvdata(pdev, info); | ||
353 | |||
354 | ret = request_threaded_irq(info->irq, NULL, twl6040_vib_irq_handler, 0, | ||
355 | "twl6040_irq_vib", info); | ||
356 | if (ret) { | 326 | if (ret) { |
357 | dev_err(info->dev, "VIB IRQ request failed: %d\n", ret); | 327 | dev_err(info->dev, "VIB IRQ request failed: %d\n", ret); |
358 | goto err_irq; | 328 | return ret; |
359 | } | 329 | } |
360 | 330 | ||
361 | info->supplies[0].supply = "vddvibl"; | 331 | info->supplies[0].supply = "vddvibl"; |
@@ -368,7 +338,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev) | |||
368 | ARRAY_SIZE(info->supplies), info->supplies); | 338 | ARRAY_SIZE(info->supplies), info->supplies); |
369 | if (ret) { | 339 | if (ret) { |
370 | dev_err(info->dev, "couldn't get regulators %d\n", ret); | 340 | dev_err(info->dev, "couldn't get regulators %d\n", ret); |
371 | goto err_regulator; | 341 | return ret; |
372 | } | 342 | } |
373 | 343 | ||
374 | if (vddvibl_uV) { | 344 | if (vddvibl_uV) { |
@@ -377,7 +347,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev) | |||
377 | if (ret) { | 347 | if (ret) { |
378 | dev_err(info->dev, "failed to set VDDVIBL volt %d\n", | 348 | dev_err(info->dev, "failed to set VDDVIBL volt %d\n", |
379 | ret); | 349 | ret); |
380 | goto err_voltage; | 350 | goto err_regulator; |
381 | } | 351 | } |
382 | } | 352 | } |
383 | 353 | ||
@@ -387,34 +357,49 @@ static int twl6040_vibra_probe(struct platform_device *pdev) | |||
387 | if (ret) { | 357 | if (ret) { |
388 | dev_err(info->dev, "failed to set VDDVIBR volt %d\n", | 358 | dev_err(info->dev, "failed to set VDDVIBR volt %d\n", |
389 | ret); | 359 | ret); |
390 | goto err_voltage; | 360 | goto err_regulator; |
391 | } | 361 | } |
392 | } | 362 | } |
393 | 363 | ||
394 | info->workqueue = alloc_workqueue("twl6040-vibra", 0, 0); | 364 | INIT_WORK(&info->play_work, vibra_play_work); |
395 | if (info->workqueue == NULL) { | 365 | |
396 | dev_err(info->dev, "couldn't create workqueue\n"); | 366 | info->input_dev = input_allocate_device(); |
367 | if (info->input_dev == NULL) { | ||
368 | dev_err(info->dev, "couldn't allocate input device\n"); | ||
397 | ret = -ENOMEM; | 369 | ret = -ENOMEM; |
398 | goto err_voltage; | 370 | goto err_regulator; |
399 | } | 371 | } |
400 | INIT_WORK(&info->play_work, vibra_play_work); | 372 | |
373 | input_set_drvdata(info->input_dev, info); | ||
374 | |||
375 | info->input_dev->name = "twl6040:vibrator"; | ||
376 | info->input_dev->id.version = 1; | ||
377 | info->input_dev->dev.parent = pdev->dev.parent; | ||
378 | info->input_dev->close = twl6040_vibra_close; | ||
379 | __set_bit(FF_RUMBLE, info->input_dev->ffbit); | ||
380 | |||
381 | ret = input_ff_create_memless(info->input_dev, NULL, vibra_play); | ||
382 | if (ret < 0) { | ||
383 | dev_err(info->dev, "couldn't register vibrator to FF\n"); | ||
384 | goto err_ialloc; | ||
385 | } | ||
386 | |||
387 | ret = input_register_device(info->input_dev); | ||
388 | if (ret < 0) { | ||
389 | dev_err(info->dev, "couldn't register input device\n"); | ||
390 | goto err_iff; | ||
391 | } | ||
392 | |||
393 | platform_set_drvdata(pdev, info); | ||
401 | 394 | ||
402 | return 0; | 395 | return 0; |
403 | 396 | ||
404 | err_voltage: | ||
405 | regulator_bulk_free(ARRAY_SIZE(info->supplies), info->supplies); | ||
406 | err_regulator: | ||
407 | free_irq(info->irq, info); | ||
408 | err_irq: | ||
409 | input_unregister_device(info->input_dev); | ||
410 | info->input_dev = NULL; | ||
411 | err_iff: | 397 | err_iff: |
412 | if (info->input_dev) | 398 | input_ff_destroy(info->input_dev); |
413 | input_ff_destroy(info->input_dev); | ||
414 | err_ialloc: | 399 | err_ialloc: |
415 | input_free_device(info->input_dev); | 400 | input_free_device(info->input_dev); |
416 | err_kzalloc: | 401 | err_regulator: |
417 | kfree(info); | 402 | regulator_bulk_free(ARRAY_SIZE(info->supplies), info->supplies); |
418 | return ret; | 403 | return ret; |
419 | } | 404 | } |
420 | 405 | ||
@@ -423,10 +408,7 @@ static int twl6040_vibra_remove(struct platform_device *pdev) | |||
423 | struct vibra_info *info = platform_get_drvdata(pdev); | 408 | struct vibra_info *info = platform_get_drvdata(pdev); |
424 | 409 | ||
425 | input_unregister_device(info->input_dev); | 410 | input_unregister_device(info->input_dev); |
426 | free_irq(info->irq, info); | ||
427 | regulator_bulk_free(ARRAY_SIZE(info->supplies), info->supplies); | 411 | regulator_bulk_free(ARRAY_SIZE(info->supplies), info->supplies); |
428 | destroy_workqueue(info->workqueue); | ||
429 | kfree(info); | ||
430 | 412 | ||
431 | return 0; | 413 | return 0; |
432 | } | 414 | } |