* [PATCH 0/7] Use devm_request_region
@ 2016-02-01 23:54 William Breathitt Gray
2016-02-01 23:54 ` [PATCH 1/7] gpio: 104-dio-48e: " William Breathitt Gray
` (7 more replies)
0 siblings, 8 replies; 11+ messages in thread
From: William Breathitt Gray @ 2016-02-01 23:54 UTC (permalink / raw)
To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel
By the time request_region is called in several GPIO drivers, 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.
William Breathitt Gray (7):
gpio: 104-dio-48e: Use devm_request_region
gpio: 104-idi-48: Use devm_request_region
gpio: 104-idio-16: Use devm_request_region
gpio: amd8111: Use devm_request_region
gpio: ich: Use devm_request_region
gpio: sch311x: Use devm_request_region
gpio: ws16c48: Use devm_request_region
drivers/gpio/gpio-104-dio-48e.c | 22 +++++++-----------
drivers/gpio/gpio-104-idi-48.c | 22 +++++++-----------
drivers/gpio/gpio-104-idio-16.c | 22 +++++++-----------
drivers/gpio/gpio-amd8111.c | 7 +++---
drivers/gpio/gpio-ich.c | 51 ++++++++---------------------------------
drivers/gpio/gpio-sch311x.c | 7 +++---
drivers/gpio/gpio-ws16c48.c | 22 +++++++-----------
7 files changed, 47 insertions(+), 106 deletions(-)
--
2.4.10
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/7] gpio: 104-dio-48e: Use devm_request_region
2016-02-01 23:54 [PATCH 0/7] Use devm_request_region William Breathitt Gray
@ 2016-02-01 23:54 ` William Breathitt Gray
2016-02-01 23:54 ` [PATCH 2/7] gpio: 104-idi-48: " William Breathitt Gray
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: William Breathitt Gray @ 2016-02-01 23:54 UTC (permalink / raw)
To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel
By the time request_region is called in the ACCES 104-DIO-48E 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-104-dio-48e.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
index 279de39..e8fcbb8 100644
--- a/drivers/gpio/gpio-104-dio-48e.c
+++ b/drivers/gpio/gpio-104-dio-48e.c
@@ -310,11 +310,10 @@ static int __init dio48e_probe(struct platform_device *pdev)
if (!dio48egpio)
return -ENOMEM;
- if (!request_region(base, extent, name)) {
- dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n",
- name, base, base + extent);
- err = -EBUSY;
- goto err_lock_io_port;
+ if (!devm_request_region(dev, base, extent, name)) {
+ dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
+ base, base + extent);
+ return -EBUSY;
}
dio48egpio->chip.label = name;
@@ -338,7 +337,7 @@ static int __init dio48e_probe(struct platform_device *pdev)
err = gpiochip_add_data(&dio48egpio->chip, dio48egpio);
if (err) {
dev_err(dev, "GPIO registering failed (%d)\n", err);
- goto err_gpio_register;
+ return err;
}
/* initialize all GPIO as output */
@@ -360,23 +359,19 @@ static int __init dio48e_probe(struct platform_device *pdev)
handle_edge_irq, IRQ_TYPE_NONE);
if (err) {
dev_err(dev, "Could not add irqchip (%d)\n", err);
- goto err_gpiochip_irqchip_add;
+ goto err_gpiochip_remove;
}
err = request_irq(irq, dio48e_irq_handler, 0, name, dio48egpio);
if (err) {
dev_err(dev, "IRQ handler registering failed (%d)\n", err);
- goto err_request_irq;
+ goto err_gpiochip_remove;
}
return 0;
-err_request_irq:
-err_gpiochip_irqchip_add:
+err_gpiochip_remove:
gpiochip_remove(&dio48egpio->chip);
-err_gpio_register:
- release_region(base, extent);
-err_lock_io_port:
return err;
}
@@ -386,7 +381,6 @@ static int dio48e_remove(struct platform_device *pdev)
free_irq(dio48egpio->irq, dio48egpio);
gpiochip_remove(&dio48egpio->chip);
- release_region(dio48egpio->base, dio48egpio->extent);
return 0;
}
--
2.4.10
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/7] gpio: 104-idi-48: Use devm_request_region
2016-02-01 23:54 [PATCH 0/7] Use devm_request_region William Breathitt Gray
2016-02-01 23:54 ` [PATCH 1/7] gpio: 104-dio-48e: " William Breathitt Gray
@ 2016-02-01 23:54 ` William Breathitt Gray
2016-02-01 23:54 ` [PATCH 3/7] gpio: 104-idio-16: " William Breathitt Gray
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: William Breathitt Gray @ 2016-02-01 23:54 UTC (permalink / raw)
To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel
By the time request_region is called in the ACCES 104-IDI-48 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-104-idi-48.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
index 285a075..70359f7 100644
--- a/drivers/gpio/gpio-104-idi-48.c
+++ b/drivers/gpio/gpio-104-idi-48.c
@@ -227,11 +227,10 @@ static int __init idi_48_probe(struct platform_device *pdev)
if (!idi48gpio)
return -ENOMEM;
- if (!request_region(base, extent, name)) {
- dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n",
- name, base, base + extent);
- err = -EBUSY;
- goto err_lock_io_port;
+ if (!devm_request_region(dev, base, extent, name)) {
+ dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
+ base, base + extent);
+ return -EBUSY;
}
idi48gpio->chip.label = name;
@@ -253,7 +252,7 @@ static int __init idi_48_probe(struct platform_device *pdev)
err = gpiochip_add_data(&idi48gpio->chip, idi48gpio);
if (err) {
dev_err(dev, "GPIO registering failed (%d)\n", err);
- goto err_gpio_register;
+ return err;
}
/* Disable IRQ by default */
@@ -264,24 +263,20 @@ static int __init idi_48_probe(struct platform_device *pdev)
handle_edge_irq, IRQ_TYPE_NONE);
if (err) {
dev_err(dev, "Could not add irqchip (%d)\n", err);
- goto err_gpiochip_irqchip_add;
+ goto err_gpiochip_remove;
}
err = request_irq(irq, idi_48_irq_handler, IRQF_SHARED, name,
idi48gpio);
if (err) {
dev_err(dev, "IRQ handler registering failed (%d)\n", err);
- goto err_request_irq;
+ goto err_gpiochip_remove;
}
return 0;
-err_request_irq:
-err_gpiochip_irqchip_add:
+err_gpiochip_remove:
gpiochip_remove(&idi48gpio->chip);
-err_gpio_register:
- release_region(base, extent);
-err_lock_io_port:
return err;
}
@@ -291,7 +286,6 @@ static int idi_48_remove(struct platform_device *pdev)
free_irq(idi48gpio->irq, idi48gpio);
gpiochip_remove(&idi48gpio->chip);
- release_region(idi48gpio->base, idi48gpio->extent);
return 0;
}
--
2.4.10
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/7] gpio: 104-idio-16: Use devm_request_region
2016-02-01 23:54 [PATCH 0/7] Use devm_request_region William Breathitt Gray
2016-02-01 23:54 ` [PATCH 1/7] gpio: 104-dio-48e: " William Breathitt Gray
2016-02-01 23:54 ` [PATCH 2/7] gpio: 104-idi-48: " William Breathitt Gray
@ 2016-02-01 23:54 ` William Breathitt Gray
2016-02-01 23:54 ` [PATCH 4/7] gpio: amd8111: " William Breathitt Gray
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: William Breathitt Gray @ 2016-02-01 23:54 UTC (permalink / raw)
To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel
By the time request_region is called in the ACCES 104-IDIO-16 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-104-idio-16.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
index 4d69b50..aecdc02 100644
--- a/drivers/gpio/gpio-104-idio-16.c
+++ b/drivers/gpio/gpio-104-idio-16.c
@@ -201,11 +201,10 @@ static int __init idio_16_probe(struct platform_device *pdev)
if (!idio16gpio)
return -ENOMEM;
- if (!request_region(base, extent, name)) {
- dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n",
- name, base, base + extent);
- err = -EBUSY;
- goto err_lock_io_port;
+ if (!devm_request_region(dev, base, extent, name)) {
+ dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
+ base, base + extent);
+ return -EBUSY;
}
idio16gpio->chip.label = name;
@@ -230,7 +229,7 @@ static int __init idio_16_probe(struct platform_device *pdev)
err = gpiochip_add_data(&idio16gpio->chip, idio16gpio);
if (err) {
dev_err(dev, "GPIO registering failed (%d)\n", err);
- goto err_gpio_register;
+ return err;
}
/* Disable IRQ by default */
@@ -241,23 +240,19 @@ static int __init idio_16_probe(struct platform_device *pdev)
handle_edge_irq, IRQ_TYPE_NONE);
if (err) {
dev_err(dev, "Could not add irqchip (%d)\n", err);
- goto err_gpiochip_irqchip_add;
+ goto err_gpiochip_remove;
}
err = request_irq(irq, idio_16_irq_handler, 0, name, idio16gpio);
if (err) {
dev_err(dev, "IRQ handler registering failed (%d)\n", err);
- goto err_request_irq;
+ goto err_gpiochip_remove;
}
return 0;
-err_request_irq:
-err_gpiochip_irqchip_add:
+err_gpiochip_remove:
gpiochip_remove(&idio16gpio->chip);
-err_gpio_register:
- release_region(base, extent);
-err_lock_io_port:
return err;
}
@@ -267,7 +262,6 @@ static int idio_16_remove(struct platform_device *pdev)
free_irq(idio16gpio->irq, idio16gpio);
gpiochip_remove(&idio16gpio->chip);
- release_region(idio16gpio->base, idio16gpio->extent);
return 0;
}
--
2.4.10
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/7] gpio: amd8111: Use devm_request_region
2016-02-01 23:54 [PATCH 0/7] Use devm_request_region William Breathitt Gray
` (2 preceding siblings ...)
2016-02-01 23:54 ` [PATCH 3/7] gpio: 104-idio-16: " William Breathitt Gray
@ 2016-02-01 23:54 ` William Breathitt Gray
2016-02-01 23:54 ` [PATCH 5/7] gpio: ich: " William Breathitt Gray
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: William Breathitt Gray @ 2016-02-01 23:54 UTC (permalink / raw)
To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel
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>
---
drivers/gpio/gpio-amd8111.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c
index c7040ff..30ad7d7 100644
--- a/drivers/gpio/gpio-amd8111.c
+++ b/drivers/gpio/gpio-amd8111.c
@@ -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);
--
2.4.10
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/7] gpio: ich: Use devm_request_region
2016-02-01 23:54 [PATCH 0/7] Use devm_request_region William Breathitt Gray
` (3 preceding siblings ...)
2016-02-01 23:54 ` [PATCH 4/7] gpio: amd8111: " William Breathitt Gray
@ 2016-02-01 23:54 ` William Breathitt Gray
2016-02-01 23:56 ` [PATCH 6/7] gpio: sch311x: " William Breathitt Gray
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: William Breathitt Gray @ 2016-02-01 23:54 UTC (permalink / raw)
To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel, Peter Tyser
By the time request_region is called in the Intel ICH series 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.
Cc: Peter Tyser <ptyser@xes-inc.com>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
drivers/gpio/gpio-ich.c | 51 +++++++++----------------------------------------
1 file changed, 9 insertions(+), 42 deletions(-)
diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
index a489338..4f6d643 100644
--- a/drivers/gpio/gpio-ich.c
+++ b/drivers/gpio/gpio-ich.c
@@ -20,6 +20,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/gpio.h>
@@ -384,8 +385,8 @@ static struct ichx_desc avoton_desc = {
.use_outlvl_cache = true,
};
-static int ichx_gpio_request_regions(struct resource *res_base,
- const char *name, u8 use_gpio)
+static int ichx_gpio_request_regions(struct device *dev,
+ struct resource *res_base, const char *name, u8 use_gpio)
{
int i;
@@ -395,34 +396,12 @@ static int ichx_gpio_request_regions(struct resource *res_base,
for (i = 0; i < ARRAY_SIZE(ichx_priv.desc->regs[0]); i++) {
if (!(use_gpio & (1 << i)))
continue;
- if (!request_region(
+ if (!devm_request_region(dev,
res_base->start + ichx_priv.desc->regs[0][i],
ichx_priv.desc->reglen[i], name))
- goto request_err;
+ return -EBUSY;
}
return 0;
-
-request_err:
- /* Clean up: release already requested regions, if any */
- for (i--; i >= 0; i--) {
- if (!(use_gpio & (1 << i)))
- continue;
- release_region(res_base->start + ichx_priv.desc->regs[0][i],
- ichx_priv.desc->reglen[i]);
- }
- return -EBUSY;
-}
-
-static void ichx_gpio_release_regions(struct resource *res_base, u8 use_gpio)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(ichx_priv.desc->regs[0]); i++) {
- if (!(use_gpio & (1 << i)))
- continue;
- release_region(res_base->start + ichx_priv.desc->regs[0][i],
- ichx_priv.desc->reglen[i]);
- }
}
static int ichx_gpio_probe(struct platform_device *pdev)
@@ -468,7 +447,7 @@ static int ichx_gpio_probe(struct platform_device *pdev)
spin_lock_init(&ichx_priv.lock);
res_base = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_GPIO);
ichx_priv.use_gpio = ich_info->use_gpio;
- err = ichx_gpio_request_regions(res_base, pdev->name,
+ err = ichx_gpio_request_regions(&pdev->dev, res_base, pdev->name,
ichx_priv.use_gpio);
if (err)
return err;
@@ -489,8 +468,8 @@ static int ichx_gpio_probe(struct platform_device *pdev)
goto init;
}
- if (!request_region(res_pm->start, resource_size(res_pm),
- pdev->name)) {
+ if (!devm_request_region(&pdev->dev, res_pm->start,
+ resource_size(res_pm), pdev->name)) {
pr_warn("ACPI BAR is busy, GPI 0 - 15 unavailable\n");
goto init;
}
@@ -502,31 +481,19 @@ init:
err = gpiochip_add_data(&ichx_priv.chip, NULL);
if (err) {
pr_err("Failed to register GPIOs\n");
- goto add_err;
+ return err;
}
pr_info("GPIO from %d to %d on %s\n", ichx_priv.chip.base,
ichx_priv.chip.base + ichx_priv.chip.ngpio - 1, DRV_NAME);
return 0;
-
-add_err:
- ichx_gpio_release_regions(ichx_priv.gpio_base, ichx_priv.use_gpio);
- if (ichx_priv.pm_base)
- release_region(ichx_priv.pm_base->start,
- resource_size(ichx_priv.pm_base));
- return err;
}
static int ichx_gpio_remove(struct platform_device *pdev)
{
gpiochip_remove(&ichx_priv.chip);
- ichx_gpio_release_regions(ichx_priv.gpio_base, ichx_priv.use_gpio);
- if (ichx_priv.pm_base)
- release_region(ichx_priv.pm_base->start,
- resource_size(ichx_priv.pm_base));
-
return 0;
}
--
2.4.10
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 6/7] gpio: sch311x: Use devm_request_region
2016-02-01 23:54 [PATCH 0/7] Use devm_request_region William Breathitt Gray
` (4 preceding siblings ...)
2016-02-01 23:54 ` [PATCH 5/7] gpio: ich: " William Breathitt Gray
@ 2016-02-01 23:56 ` William Breathitt Gray
2016-02-02 0:11 ` kbuild test robot
2016-02-01 23:57 ` [PATCH 7/7] gpio: ws16c48: " William Breathitt Gray
2016-02-03 0:26 ` [PATCH 0/7] " Alexandre Courbot
7 siblings, 1 reply; 11+ messages in thread
From: William Breathitt Gray @ 2016-02-01 23:56 UTC (permalink / raw)
To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel
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(-)
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,
--
2.4.10
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 7/7] gpio: ws16c48: Use devm_request_region
2016-02-01 23:54 [PATCH 0/7] Use devm_request_region William Breathitt Gray
` (5 preceding siblings ...)
2016-02-01 23:56 ` [PATCH 6/7] gpio: sch311x: " William Breathitt Gray
@ 2016-02-01 23:57 ` William Breathitt Gray
2016-02-03 0:26 ` [PATCH 0/7] " Alexandre Courbot
7 siblings, 0 replies; 11+ messages in thread
From: William Breathitt Gray @ 2016-02-01 23:57 UTC (permalink / raw)
To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel
By the time request_region is called in the WinSystems WS16C48 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-ws16c48.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
index 9dd9479..72b880f 100644
--- a/drivers/gpio/gpio-ws16c48.c
+++ b/drivers/gpio/gpio-ws16c48.c
@@ -314,11 +314,10 @@ static int __init ws16c48_probe(struct platform_device *pdev)
if (!ws16c48gpio)
return -ENOMEM;
- if (!request_region(base, extent, name)) {
- dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n",
- name, base, base + extent);
- err = -EBUSY;
- goto err_lock_io_port;
+ if (!devm_request_region(dev, base, extent, name)) {
+ dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
+ base, base + extent);
+ return -EBUSY;
}
ws16c48gpio->chip.label = name;
@@ -342,7 +341,7 @@ static int __init ws16c48_probe(struct platform_device *pdev)
err = gpiochip_add_data(&ws16c48gpio->chip, ws16c48gpio);
if (err) {
dev_err(dev, "GPIO registering failed (%d)\n", err);
- goto err_gpio_register;
+ return err;
}
/* Disable IRQ by default */
@@ -356,24 +355,20 @@ static int __init ws16c48_probe(struct platform_device *pdev)
handle_edge_irq, IRQ_TYPE_NONE);
if (err) {
dev_err(dev, "Could not add irqchip (%d)\n", err);
- goto err_gpiochip_irqchip_add;
+ goto err_gpiochip_remove;
}
err = request_irq(irq, ws16c48_irq_handler, IRQF_SHARED, name,
ws16c48gpio);
if (err) {
dev_err(dev, "IRQ handler registering failed (%d)\n", err);
- goto err_request_irq;
+ goto err_gpiochip_remove;
}
return 0;
-err_request_irq:
-err_gpiochip_irqchip_add:
+err_gpiochip_remove:
gpiochip_remove(&ws16c48gpio->chip);
-err_gpio_register:
- release_region(base, extent);
-err_lock_io_port:
return err;
}
@@ -383,7 +378,6 @@ static int ws16c48_remove(struct platform_device *pdev)
free_irq(ws16c48gpio->irq, ws16c48gpio);
gpiochip_remove(&ws16c48gpio->chip);
- release_region(ws16c48gpio->base, ws16c48gpio->extent);
return 0;
}
--
2.4.10
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 6/7] gpio: sch311x: Use devm_request_region
2016-02-01 23:56 ` [PATCH 6/7] gpio: sch311x: " William Breathitt Gray
@ 2016-02-02 0:11 ` kbuild test robot
0 siblings, 0 replies; 11+ messages in thread
From: kbuild test robot @ 2016-02-02 0:11 UTC (permalink / raw)
To: William Breathitt Gray
Cc: kbuild-all, linus.walleij, gnurou, linux-gpio, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2974 bytes --]
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
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 27134 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/7] Use devm_request_region
2016-02-01 23:54 [PATCH 0/7] Use devm_request_region William Breathitt Gray
` (6 preceding siblings ...)
2016-02-01 23:57 ` [PATCH 7/7] gpio: ws16c48: " William Breathitt Gray
@ 2016-02-03 0:26 ` Alexandre Courbot
2016-02-03 0:46 ` William Breathitt Gray
7 siblings, 1 reply; 11+ messages in thread
From: Alexandre Courbot @ 2016-02-03 0:26 UTC (permalink / raw)
To: William Breathitt Gray
Cc: Linus Walleij, linux-gpio, Linux Kernel Mailing List
On Tue, Feb 2, 2016 at 8:54 AM, William Breathitt Gray
<vilhelm.gray@gmail.com> wrote:
> By the time request_region is called in several GPIO drivers, 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.
>
> William Breathitt Gray (7):
> gpio: 104-dio-48e: Use devm_request_region
> gpio: 104-idi-48: Use devm_request_region
> gpio: 104-idio-16: Use devm_request_region
> gpio: amd8111: Use devm_request_region
> gpio: ich: Use devm_request_region
> gpio: sch311x: Use devm_request_region
> gpio: ws16c48: Use devm_request_region
>
> drivers/gpio/gpio-104-dio-48e.c | 22 +++++++-----------
> drivers/gpio/gpio-104-idi-48.c | 22 +++++++-----------
> drivers/gpio/gpio-104-idio-16.c | 22 +++++++-----------
> drivers/gpio/gpio-amd8111.c | 7 +++---
> drivers/gpio/gpio-ich.c | 51 ++++++++---------------------------------
> drivers/gpio/gpio-sch311x.c | 7 +++---
> drivers/gpio/gpio-ws16c48.c | 22 +++++++-----------
> 7 files changed, 47 insertions(+), 106 deletions(-)
Did a quick review and this looks all good, modulo the compile warning
on patch 6.
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/7] Use devm_request_region
2016-02-03 0:26 ` [PATCH 0/7] " Alexandre Courbot
@ 2016-02-03 0:46 ` William Breathitt Gray
0 siblings, 0 replies; 11+ messages in thread
From: William Breathitt Gray @ 2016-02-03 0:46 UTC (permalink / raw)
To: Alexandre Courbot; +Cc: Linus Walleij, linux-gpio, Linux Kernel Mailing List
On 02/02/2016 07:26 PM, Alexandre Courbot wrote:
> On Tue, Feb 2, 2016 at 8:54 AM, William Breathitt Gray
> <vilhelm.gray@gmail.com> wrote:
>> By the time request_region is called in several GPIO drivers, 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.
>>
>> William Breathitt Gray (7):
>> gpio: 104-dio-48e: Use devm_request_region
>> gpio: 104-idi-48: Use devm_request_region
>> gpio: 104-idio-16: Use devm_request_region
>> gpio: amd8111: Use devm_request_region
>> gpio: ich: Use devm_request_region
>> gpio: sch311x: Use devm_request_region
>> gpio: ws16c48: Use devm_request_region
>>
>> drivers/gpio/gpio-104-dio-48e.c | 22 +++++++-----------
>> drivers/gpio/gpio-104-idi-48.c | 22 +++++++-----------
>> drivers/gpio/gpio-104-idio-16.c | 22 +++++++-----------
>> drivers/gpio/gpio-amd8111.c | 7 +++---
>> drivers/gpio/gpio-ich.c | 51 ++++++++---------------------------------
>> drivers/gpio/gpio-sch311x.c | 7 +++---
>> drivers/gpio/gpio-ws16c48.c | 22 +++++++-----------
>> 7 files changed, 47 insertions(+), 106 deletions(-)
>
> Did a quick review and this looks all good, modulo the compile warning
> on patch 6.
>
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
The compile warning for patch 6 appears to be benign and preexisting: an
unused variable. Since the warning is unrelated to this patchset, I'll
submit a separate patch to remove the unused variable so that this
warning will no longer show up on later compiles.
William Breathitt Gray
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2016-02-03 0:46 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-01 23:54 [PATCH 0/7] Use devm_request_region William Breathitt Gray
2016-02-01 23:54 ` [PATCH 1/7] gpio: 104-dio-48e: " William Breathitt Gray
2016-02-01 23:54 ` [PATCH 2/7] gpio: 104-idi-48: " William Breathitt Gray
2016-02-01 23:54 ` [PATCH 3/7] gpio: 104-idio-16: " William Breathitt Gray
2016-02-01 23:54 ` [PATCH 4/7] gpio: amd8111: " William Breathitt Gray
2016-02-01 23:54 ` [PATCH 5/7] gpio: ich: " William Breathitt Gray
2016-02-01 23:56 ` [PATCH 6/7] gpio: sch311x: " William Breathitt Gray
2016-02-02 0:11 ` kbuild test robot
2016-02-01 23:57 ` [PATCH 7/7] gpio: ws16c48: " William Breathitt Gray
2016-02-03 0:26 ` [PATCH 0/7] " Alexandre Courbot
2016-02-03 0:46 ` William Breathitt Gray
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.