]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
gpio: amd8111: Use devm_request_region
authorWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Wed, 3 Feb 2016 20:17:13 +0000 (15:17 -0500)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 15 Feb 2016 23:19:52 +0000 (00:19 +0100)
By the time request_region is called in the AMD 8111 GPIO driver, a
corresponding device structure has already been allocated. The
devm_request_region function should be used to help simplify the cleanup
code and reduce the possible points of failure.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-amd8111.c

index c7040fffc5b4377191f9e90a59134cabf8c5ad6d..30ad7d7c167801548b91e96af8a08b9e3d33ca10 100644 (file)
@@ -25,6 +25,7 @@
  * License version 2. This program is licensed "as is" without any
  * warranty of any kind, whether express or implied.
  */
+#include <linux/ioport.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/gpio.h>
@@ -204,7 +205,8 @@ found:
        gp.pmbase &= 0x0000FF00;
        if (gp.pmbase == 0)
                goto out;
-       if (!request_region(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE, "AMD GPIO")) {
+       if (!devm_request_region(&pdev->dev, gp.pmbase + PMBASE_OFFSET,
+               PMBASE_SIZE, "AMD GPIO")) {
                dev_err(&pdev->dev, "AMD GPIO region 0x%x already in use!\n",
                        gp.pmbase + PMBASE_OFFSET);
                err = -EBUSY;
@@ -213,7 +215,6 @@ found:
        gp.pm = ioport_map(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE);
        if (!gp.pm) {
                dev_err(&pdev->dev, "Couldn't map io port into io memory\n");
-               release_region(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE);
                err = -ENOMEM;
                goto out;
        }
@@ -228,7 +229,6 @@ found:
                printk(KERN_ERR "GPIO registering failed (%d)\n",
                       err);
                ioport_unmap(gp.pm);
-               release_region(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE);
                goto out;
        }
 out:
@@ -239,7 +239,6 @@ static void __exit amd_gpio_exit(void)
 {
        gpiochip_remove(&gp.chip);
        ioport_unmap(gp.pm);
-       release_region(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE);
 }
 
 module_init(amd_gpio_init);