diff mbox

[6/7] gpio: sch311x: Use devm_request_region

Message ID 6e0b7b1603d2d12a0ef8192248b281aad74979a7.1454342087.git.vilhelm.gray@gmail.com
State New
Headers show

Commit Message

William Breathitt Gray Feb. 1, 2016, 11:56 p.m. UTC
By the time request_region is called in the SMSC SCH311x 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>
---
 drivers/gpio/gpio-sch311x.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

kernel test robot Feb. 2, 2016, 12:11 a.m. UTC | #1
Hi William,

[auto build test WARNING on gpio/for-next]
[cannot apply to v4.5-rc2 next-20160201]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/William-Breathitt-Gray/Use-devm_request_region/20160202-080012
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next
config: i386-randconfig-x009-02010231 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   drivers/gpio/gpio-sch311x.c: In function 'sch311x_gpio_remove':
>> drivers/gpio/gpio-sch311x.c:286:28: warning: unused variable 'pdata' [-Wunused-variable]
     struct sch311x_pdev_data *pdata = dev_get_platdata(&pdev->dev);
                               ^

vim +/pdata +286 drivers/gpio/gpio-sch311x.c

12262bef Bruno Randolf    2013-12-04  270  		}
12262bef Bruno Randolf    2013-12-04  271  		dev_info(&pdev->dev,
12262bef Bruno Randolf    2013-12-04  272  			 "SMSC SCH311x GPIO block %d registered.\n", i);
12262bef Bruno Randolf    2013-12-04  273  	}
12262bef Bruno Randolf    2013-12-04  274  
12262bef Bruno Randolf    2013-12-04  275  	return 0;
12262bef Bruno Randolf    2013-12-04  276  
12262bef Bruno Randolf    2013-12-04  277  exit_err:
12262bef Bruno Randolf    2013-12-04  278  	/* release already registered chips */
12262bef Bruno Randolf    2013-12-04  279  	for (--i; i >= 0; i--)
12262bef Bruno Randolf    2013-12-04  280  		gpiochip_remove(&priv->blocks[i].chip);
12262bef Bruno Randolf    2013-12-04  281  	return err;
12262bef Bruno Randolf    2013-12-04  282  }
12262bef Bruno Randolf    2013-12-04  283  
12262bef Bruno Randolf    2013-12-04  284  static int sch311x_gpio_remove(struct platform_device *pdev)
12262bef Bruno Randolf    2013-12-04  285  {
ab128afc Nizam Haider     2015-11-23 @286  	struct sch311x_pdev_data *pdata = dev_get_platdata(&pdev->dev);
12262bef Bruno Randolf    2013-12-04  287  	struct sch311x_gpio_priv *priv = platform_get_drvdata(pdev);
9f5132ae abdoulaye berthe 2014-07-12  288  	int i;
12262bef Bruno Randolf    2013-12-04  289  
12262bef Bruno Randolf    2013-12-04  290  	for (i = 0; i < ARRAY_SIZE(priv->blocks); i++) {
9f5132ae abdoulaye berthe 2014-07-12  291  		gpiochip_remove(&priv->blocks[i].chip);
12262bef Bruno Randolf    2013-12-04  292  		dev_info(&pdev->dev,
12262bef Bruno Randolf    2013-12-04  293  			 "SMSC SCH311x GPIO block %d unregistered.\n", i);
12262bef Bruno Randolf    2013-12-04  294  	}

:::::: The code at line 286 was first introduced by commit
:::::: ab128afce4ea8a496fc42553215f6635a14f05c3 gpio: use dev_get_platdata()

:::::: TO: Nizam Haider <nizamhaider786@gmail.com>
:::::: CC: Linus Walleij <linus.walleij@linaro.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
index 1cbd77a..57ee8f2 100644
--- a/drivers/gpio/gpio-sch311x.c
+++ b/drivers/gpio/gpio-sch311x.c
@@ -12,6 +12,7 @@ 
  * (at your option) any later version.
  */
 
+#include <linux/ioport.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -228,7 +229,8 @@  static int sch311x_gpio_probe(struct platform_device *pdev)
 	int err, i;
 
 	/* we can register all GPIO data registers at once */
-	if (!request_region(pdata->runtime_reg + GP1, 6, DRV_NAME)) {
+	if (!devm_request_region(&pdev->dev, pdata->runtime_reg + GP1, 6,
+		DRV_NAME)) {
 		dev_err(&pdev->dev, "Failed to request region 0x%04x-0x%04x.\n",
 			pdata->runtime_reg + GP1, pdata->runtime_reg + GP1 + 5);
 		return -EBUSY;
@@ -273,7 +275,6 @@  static int sch311x_gpio_probe(struct platform_device *pdev)
 	return 0;
 
 exit_err:
-	release_region(pdata->runtime_reg + GP1, 6);
 	/* release already registered chips */
 	for (--i; i >= 0; i--)
 		gpiochip_remove(&priv->blocks[i].chip);
@@ -286,8 +287,6 @@  static int sch311x_gpio_remove(struct platform_device *pdev)
 	struct sch311x_gpio_priv *priv = platform_get_drvdata(pdev);
 	int i;
 
-	release_region(pdata->runtime_reg + GP1, 6);
-
 	for (i = 0; i < ARRAY_SIZE(priv->blocks); i++) {
 		gpiochip_remove(&priv->blocks[i].chip);
 		dev_info(&pdev->dev,