Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: amd8111: Use devm_request_region

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>

authored by

William Breathitt Gray and committed by
Linus Walleij
35568c40 cb32389c

+3 -4
+3 -4
drivers/gpio/gpio-amd8111.c
··· 25 25 * License version 2. This program is licensed "as is" without any 26 26 * warranty of any kind, whether express or implied. 27 27 */ 28 + #include <linux/ioport.h> 28 29 #include <linux/module.h> 29 30 #include <linux/kernel.h> 30 31 #include <linux/gpio.h> ··· 205 204 gp.pmbase &= 0x0000FF00; 206 205 if (gp.pmbase == 0) 207 206 goto out; 208 - if (!request_region(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE, "AMD GPIO")) { 207 + if (!devm_request_region(&pdev->dev, gp.pmbase + PMBASE_OFFSET, 208 + PMBASE_SIZE, "AMD GPIO")) { 209 209 dev_err(&pdev->dev, "AMD GPIO region 0x%x already in use!\n", 210 210 gp.pmbase + PMBASE_OFFSET); 211 211 err = -EBUSY; ··· 215 213 gp.pm = ioport_map(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE); 216 214 if (!gp.pm) { 217 215 dev_err(&pdev->dev, "Couldn't map io port into io memory\n"); 218 - release_region(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE); 219 216 err = -ENOMEM; 220 217 goto out; 221 218 } ··· 229 228 printk(KERN_ERR "GPIO registering failed (%d)\n", 230 229 err); 231 230 ioport_unmap(gp.pm); 232 - release_region(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE); 233 231 goto out; 234 232 } 235 233 out: ··· 239 239 { 240 240 gpiochip_remove(&gp.chip); 241 241 ioport_unmap(gp.pm); 242 - release_region(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE); 243 242 } 244 243 245 244 module_init(amd_gpio_init);