Commit 07d9089d authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Darren Hart

platform/x86: intel_mid_powerbtn: Convert to use devm_*()

Convert driver to use managed resources.
This eliminates error path boilerplate and makes code neat.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent 4ec567b8
...@@ -66,7 +66,7 @@ static int mfld_pb_probe(struct platform_device *pdev) ...@@ -66,7 +66,7 @@ static int mfld_pb_probe(struct platform_device *pdev)
if (irq < 0) if (irq < 0)
return -EINVAL; return -EINVAL;
input = input_allocate_device(); input = devm_input_allocate_device(&pdev->dev);
if (!input) if (!input)
return -ENOMEM; return -ENOMEM;
...@@ -77,22 +77,19 @@ static int mfld_pb_probe(struct platform_device *pdev) ...@@ -77,22 +77,19 @@ static int mfld_pb_probe(struct platform_device *pdev)
input_set_capability(input, EV_KEY, KEY_POWER); input_set_capability(input, EV_KEY, KEY_POWER);
error = request_threaded_irq(irq, NULL, mfld_pb_isr, IRQF_ONESHOT, error = devm_request_threaded_irq(&pdev->dev, irq, NULL, mfld_pb_isr,
DRIVER_NAME, input); IRQF_ONESHOT, DRIVER_NAME, input);
if (error) { if (error) {
dev_err(&pdev->dev, "Unable to request irq %d for mfld power" dev_err(&pdev->dev, "Unable to request irq %d for mfld power"
"button\n", irq); "button\n", irq);
goto err_free_input; return error;
} }
device_init_wakeup(&pdev->dev, true);
dev_pm_set_wake_irq(&pdev->dev, irq);
error = input_register_device(input); error = input_register_device(input);
if (error) { if (error) {
dev_err(&pdev->dev, "Unable to register input dev, error " dev_err(&pdev->dev, "Unable to register input dev, error "
"%d\n", error); "%d\n", error);
goto err_free_irq; return error;
} }
platform_set_drvdata(pdev, input); platform_set_drvdata(pdev, input);
...@@ -111,27 +108,19 @@ static int mfld_pb_probe(struct platform_device *pdev) ...@@ -111,27 +108,19 @@ static int mfld_pb_probe(struct platform_device *pdev)
if (error) { if (error) {
dev_err(&pdev->dev, "Unable to clear power button interrupt, " dev_err(&pdev->dev, "Unable to clear power button interrupt, "
"error: %d\n", error); "error: %d\n", error);
goto err_free_irq; return error;
} }
return 0; device_init_wakeup(&pdev->dev, true);
dev_pm_set_wake_irq(&pdev->dev, irq);
err_free_irq: return 0;
free_irq(irq, input);
err_free_input:
input_free_device(input);
return error;
} }
static int mfld_pb_remove(struct platform_device *pdev) static int mfld_pb_remove(struct platform_device *pdev)
{ {
struct input_dev *input = platform_get_drvdata(pdev);
int irq = platform_get_irq(pdev, 0);
dev_pm_clear_wake_irq(&pdev->dev); dev_pm_clear_wake_irq(&pdev->dev);
device_init_wakeup(&pdev->dev, false); device_init_wakeup(&pdev->dev, false);
free_irq(irq, input);
input_unregister_device(input);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment