regulator: wm831x-ldo: Use devm_request_threaded_irq()
authorMark Brown <broonie@linaro.org>
Sat, 31 Aug 2013 10:50:00 +0000 (11:50 +0100)
committerMark Brown <broonie@linaro.org>
Mon, 16 Sep 2013 23:27:53 +0000 (00:27 +0100)
devm guarantees that resources are freed in the oposite order to that in
which they are allocated.

Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/regulator/wm831x-ldo.c

index 1432b26ef2e97b0830a2ecf973789ee20b7991cc..5570f3e59170f7f1ba6813904b45c8fe66f893b2 100644 (file)
@@ -288,9 +288,10 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev)
        }
 
        irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV"));
-       ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq,
-                                  IRQF_TRIGGER_RISING, ldo->name,
-                                  ldo);
+       ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
+                                       wm831x_ldo_uv_irq,
+                                       IRQF_TRIGGER_RISING, ldo->name,
+                                       ldo);
        if (ret != 0) {
                dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
                        irq, ret);
@@ -311,8 +312,6 @@ static int wm831x_gp_ldo_remove(struct platform_device *pdev)
 {
        struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
 
-       free_irq(wm831x_irq(ldo->wm831x,
-                           platform_get_irq_byname(pdev, "UV")), ldo);
        regulator_unregister(ldo->regulator);
 
        return 0;
@@ -514,8 +513,9 @@ static int wm831x_aldo_probe(struct platform_device *pdev)
        }
 
        irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV"));
-       ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq,
-                                  IRQF_TRIGGER_RISING, ldo->name, ldo);
+       ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
+                                       wm831x_ldo_uv_irq,
+                                       IRQF_TRIGGER_RISING, ldo->name, ldo);
        if (ret != 0) {
                dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
                        irq, ret);
@@ -536,8 +536,6 @@ static int wm831x_aldo_remove(struct platform_device *pdev)
 {
        struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
 
-       free_irq(wm831x_irq(ldo->wm831x, platform_get_irq_byname(pdev, "UV")),
-                ldo);
        regulator_unregister(ldo->regulator);
 
        return 0;