Input: arizona-haptic - convert to use managed input devices
Using managed input device (via devm_input_allocate_device) simplifies error handling and driver removal paths and also silences CID# 712569. Reviewed-by: Joshua Clayton <stillcompiling@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
@@ -170,8 +170,8 @@ static int arizona_haptics_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
INIT_WORK(&haptics->work, arizona_haptics_work);
|
INIT_WORK(&haptics->work, arizona_haptics_work);
|
||||||
|
|
||||||
haptics->input_dev = input_allocate_device();
|
haptics->input_dev = devm_input_allocate_device(&pdev->dev);
|
||||||
if (haptics->input_dev == NULL) {
|
if (!haptics->input_dev) {
|
||||||
dev_err(arizona->dev, "Failed to allocate input device\n");
|
dev_err(arizona->dev, "Failed to allocate input device\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
@@ -188,41 +188,23 @@ static int arizona_haptics_probe(struct platform_device *pdev)
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(arizona->dev, "input_ff_create_memless() failed: %d\n",
|
dev_err(arizona->dev, "input_ff_create_memless() failed: %d\n",
|
||||||
ret);
|
ret);
|
||||||
goto err_ialloc;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = input_register_device(haptics->input_dev);
|
ret = input_register_device(haptics->input_dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(arizona->dev, "couldn't register input device: %d\n",
|
dev_err(arizona->dev, "couldn't register input device: %d\n",
|
||||||
ret);
|
ret);
|
||||||
goto err_iff;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, haptics);
|
platform_set_drvdata(pdev, haptics);
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
err_iff:
|
|
||||||
if (haptics->input_dev)
|
|
||||||
input_ff_destroy(haptics->input_dev);
|
|
||||||
err_ialloc:
|
|
||||||
input_free_device(haptics->input_dev);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int arizona_haptics_remove(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
struct arizona_haptics *haptics = platform_get_drvdata(pdev);
|
|
||||||
|
|
||||||
input_unregister_device(haptics->input_dev);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct platform_driver arizona_haptics_driver = {
|
static struct platform_driver arizona_haptics_driver = {
|
||||||
.probe = arizona_haptics_probe,
|
.probe = arizona_haptics_probe,
|
||||||
.remove = arizona_haptics_remove,
|
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "arizona-haptics",
|
.name = "arizona-haptics",
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user