Re: [PATCH 2/2] gpio: pca953x: use managed resources

2013-01-28 Thread Russell King - ARM Linux
On Mon, Jan 28, 2013 at 11:17:48AM +0100, Linus Walleij wrote:
> On Fri, Jan 25, 2013 at 5:59 PM, Gregory CLEMENT
>  wrote:
> 
> > From: Linus Walleij 
> >
> > Using the devm_* managed resources the pca driver can be simplified
> > and cut down on boilerplate code.
> >
> > [gcl: fixed a inccorect reference to a removed label, "goto fail_out"
> > became "return ret"]
> 
> Oh now "gcl" means both Grant C. Likely and Gregory CLement :-)

I'd say gcl means Grant C. Likely.  gc would be Gregory Clement.
Initials. :)  Using anything else results in yet more many namespace
clashes.

Maybe we should switch to a numeric namespace instead? :)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] gpio: pca953x: use managed resources

2013-01-28 Thread Linus Walleij
On Fri, Jan 25, 2013 at 5:59 PM, Gregory CLEMENT
 wrote:

> From: Linus Walleij 
>
> Using the devm_* managed resources the pca driver can be simplified
> and cut down on boilerplate code.
>
> [gcl: fixed a inccorect reference to a removed label, "goto fail_out"
> became "return ret"]

Oh now "gcl" means both Grant C. Likely and Gregory CLement :-)

> Signed-off-by: Linus Walleij 
> Signed-off-by: Gregory CLEMENT 

Patch applied, thanks!

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] gpio: pca953x: use managed resources

2013-01-28 Thread Linus Walleij
On Fri, Jan 25, 2013 at 5:59 PM, Gregory CLEMENT
gregory.clem...@free-electrons.com wrote:

 From: Linus Walleij linus.wall...@linaro.org

 Using the devm_* managed resources the pca driver can be simplified
 and cut down on boilerplate code.

 [gcl: fixed a inccorect reference to a removed label, goto fail_out
 became return ret]

Oh now gcl means both Grant C. Likely and Gregory CLement :-)

 Signed-off-by: Linus Walleij linus.wall...@linaro.org
 Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com

Patch applied, thanks!

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] gpio: pca953x: use managed resources

2013-01-28 Thread Russell King - ARM Linux
On Mon, Jan 28, 2013 at 11:17:48AM +0100, Linus Walleij wrote:
 On Fri, Jan 25, 2013 at 5:59 PM, Gregory CLEMENT
 gregory.clem...@free-electrons.com wrote:
 
  From: Linus Walleij linus.wall...@linaro.org
 
  Using the devm_* managed resources the pca driver can be simplified
  and cut down on boilerplate code.
 
  [gcl: fixed a inccorect reference to a removed label, goto fail_out
  became return ret]
 
 Oh now gcl means both Grant C. Likely and Gregory CLement :-)

I'd say gcl means Grant C. Likely.  gc would be Gregory Clement.
Initials. :)  Using anything else results in yet more many namespace
clashes.

Maybe we should switch to a numeric namespace instead? :)
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] gpio: pca953x: use managed resources

2013-01-25 Thread Gregory CLEMENT
From: Linus Walleij 

Using the devm_* managed resources the pca driver can be simplified
and cut down on boilerplate code.

[gcl: fixed a inccorect reference to a removed label, "goto fail_out"
became "return ret"]

Signed-off-by: Linus Walleij 
Signed-off-by: Gregory CLEMENT 
---
 drivers/gpio/gpio-pca953x.c |   32 
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 1dc9906..2405946 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -560,7 +560,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
}
ret = pca953x_read_regs(chip, offset, chip->irq_stat);
if (ret)
-   goto out_failed;
+   return ret;
 
/*
 * There is no way to know which GPIO line generated the
@@ -579,7 +579,8 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
if (!chip->domain)
return -ENODEV;
 
-   ret = request_threaded_irq(client->irq,
+   ret = devm_request_threaded_irq(>dev,
+   client->irq,
   NULL,
   pca953x_irq_handler,
   IRQF_TRIGGER_LOW | IRQF_ONESHOT,
@@ -596,12 +597,6 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
return 0;
 }
 
-static void pca953x_irq_teardown(struct pca953x_chip *chip)
-{
-   if (chip->irq_base != -1) {
-   free_irq(chip->client->irq, chip);
-   }
-}
 #else /* CONFIG_GPIO_PCA953X_IRQ */
 static int pca953x_irq_setup(struct pca953x_chip *chip,
 const struct i2c_device_id *id,
@@ -614,10 +609,6 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 
return 0;
 }
-
-static void pca953x_irq_teardown(struct pca953x_chip *chip)
-{
-}
 #endif
 
 /*
@@ -736,7 +727,8 @@ static int pca953x_probe(struct i2c_client *client,
int ret;
u32 invert = 0;
 
-   chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
+   chip = devm_kzalloc(>dev,
+   sizeof(struct pca953x_chip), GFP_KERNEL);
if (chip == NULL)
return -ENOMEM;
 
@@ -771,15 +763,15 @@ static int pca953x_probe(struct i2c_client *client,
else
ret = device_pca957x_init(chip, invert);
if (ret)
-   goto out_failed;
+   return ret;
 
ret = pca953x_irq_setup(chip, id, irq_base);
if (ret)
-   goto out_failed;
+   return ret;
 
ret = gpiochip_add(>gpio_chip);
if (ret)
-   goto out_failed_irq;
+   return ret;
 
if (pdata && pdata->setup) {
ret = pdata->setup(client, chip->gpio_chip.base,
@@ -790,12 +782,6 @@ static int pca953x_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, chip);
return 0;
-
-out_failed_irq:
-   pca953x_irq_teardown(chip);
-out_failed:
-   kfree(chip);
-   return ret;
 }
 
 static int pca953x_remove(struct i2c_client *client)
@@ -821,8 +807,6 @@ static int pca953x_remove(struct i2c_client *client)
return ret;
}
 
-   pca953x_irq_teardown(chip);
-   kfree(chip);
return 0;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] gpio: pca953x: use managed resources

2013-01-25 Thread Linus Walleij
Using the devm_* managed resources the pca driver can be simplified
and cut down on boilerplate code.

Signed-off-by: Linus Walleij 
---
 drivers/gpio/gpio-pca953x.c | 30 +++---
 1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 51e7f15..2b04a8f 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -573,7 +573,8 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 #endif
}
 
-   ret = request_threaded_irq(client->irq,
+   ret = devm_request_threaded_irq(>dev,
+   client->irq,
NULL,
pca953x_irq_handler,
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
@@ -590,12 +591,6 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
return 0;
 }
 
-static void pca953x_irq_teardown(struct pca953x_chip *chip)
-{
-   if (chip->irq_base != -1) {
-   free_irq(chip->client->irq, chip);
-   }
-}
 #else /* CONFIG_GPIO_PCA953X_IRQ */
 static int pca953x_irq_setup(struct pca953x_chip *chip,
 const struct i2c_device_id *id,
@@ -608,10 +603,6 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 
return 0;
 }
-
-static void pca953x_irq_teardown(struct pca953x_chip *chip)
-{
-}
 #endif
 
 /*
@@ -730,7 +721,8 @@ static int pca953x_probe(struct i2c_client *client,
int ret;
u32 invert = 0;
 
-   chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
+   chip = devm_kzalloc(>dev,
+   sizeof(struct pca953x_chip), GFP_KERNEL);
if (chip == NULL)
return -ENOMEM;
 
@@ -765,15 +757,15 @@ static int pca953x_probe(struct i2c_client *client,
else
ret = device_pca957x_init(chip, invert);
if (ret)
-   goto out_failed;
+   return ret;
 
ret = pca953x_irq_setup(chip, id, irq_base);
if (ret)
-   goto out_failed;
+   return ret;
 
ret = gpiochip_add(>gpio_chip);
if (ret)
-   goto out_failed_irq;
+   return ret;
 
if (pdata && pdata->setup) {
ret = pdata->setup(client, chip->gpio_chip.base,
@@ -784,12 +776,6 @@ static int pca953x_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, chip);
return 0;
-
-out_failed_irq:
-   pca953x_irq_teardown(chip);
-out_failed:
-   kfree(chip);
-   return ret;
 }
 
 static int pca953x_remove(struct i2c_client *client)
@@ -815,8 +801,6 @@ static int pca953x_remove(struct i2c_client *client)
return ret;
}
 
-   pca953x_irq_teardown(chip);
-   kfree(chip);
return 0;
 }
 
-- 
1.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] gpio: pca953x: use managed resources

2013-01-25 Thread Linus Walleij
Using the devm_* managed resources the pca driver can be simplified
and cut down on boilerplate code.

Signed-off-by: Linus Walleij linus.wall...@linaro.org
---
 drivers/gpio/gpio-pca953x.c | 30 +++---
 1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 51e7f15..2b04a8f 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -573,7 +573,8 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 #endif
}
 
-   ret = request_threaded_irq(client-irq,
+   ret = devm_request_threaded_irq(client-dev,
+   client-irq,
NULL,
pca953x_irq_handler,
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
@@ -590,12 +591,6 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
return 0;
 }
 
-static void pca953x_irq_teardown(struct pca953x_chip *chip)
-{
-   if (chip-irq_base != -1) {
-   free_irq(chip-client-irq, chip);
-   }
-}
 #else /* CONFIG_GPIO_PCA953X_IRQ */
 static int pca953x_irq_setup(struct pca953x_chip *chip,
 const struct i2c_device_id *id,
@@ -608,10 +603,6 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 
return 0;
 }
-
-static void pca953x_irq_teardown(struct pca953x_chip *chip)
-{
-}
 #endif
 
 /*
@@ -730,7 +721,8 @@ static int pca953x_probe(struct i2c_client *client,
int ret;
u32 invert = 0;
 
-   chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
+   chip = devm_kzalloc(client-dev,
+   sizeof(struct pca953x_chip), GFP_KERNEL);
if (chip == NULL)
return -ENOMEM;
 
@@ -765,15 +757,15 @@ static int pca953x_probe(struct i2c_client *client,
else
ret = device_pca957x_init(chip, invert);
if (ret)
-   goto out_failed;
+   return ret;
 
ret = pca953x_irq_setup(chip, id, irq_base);
if (ret)
-   goto out_failed;
+   return ret;
 
ret = gpiochip_add(chip-gpio_chip);
if (ret)
-   goto out_failed_irq;
+   return ret;
 
if (pdata  pdata-setup) {
ret = pdata-setup(client, chip-gpio_chip.base,
@@ -784,12 +776,6 @@ static int pca953x_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, chip);
return 0;
-
-out_failed_irq:
-   pca953x_irq_teardown(chip);
-out_failed:
-   kfree(chip);
-   return ret;
 }
 
 static int pca953x_remove(struct i2c_client *client)
@@ -815,8 +801,6 @@ static int pca953x_remove(struct i2c_client *client)
return ret;
}
 
-   pca953x_irq_teardown(chip);
-   kfree(chip);
return 0;
 }
 
-- 
1.8.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] gpio: pca953x: use managed resources

2013-01-25 Thread Gregory CLEMENT
From: Linus Walleij linus.wall...@linaro.org

Using the devm_* managed resources the pca driver can be simplified
and cut down on boilerplate code.

[gcl: fixed a inccorect reference to a removed label, goto fail_out
became return ret]

Signed-off-by: Linus Walleij linus.wall...@linaro.org
Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
---
 drivers/gpio/gpio-pca953x.c |   32 
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 1dc9906..2405946 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -560,7 +560,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
}
ret = pca953x_read_regs(chip, offset, chip-irq_stat);
if (ret)
-   goto out_failed;
+   return ret;
 
/*
 * There is no way to know which GPIO line generated the
@@ -579,7 +579,8 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
if (!chip-domain)
return -ENODEV;
 
-   ret = request_threaded_irq(client-irq,
+   ret = devm_request_threaded_irq(client-dev,
+   client-irq,
   NULL,
   pca953x_irq_handler,
   IRQF_TRIGGER_LOW | IRQF_ONESHOT,
@@ -596,12 +597,6 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
return 0;
 }
 
-static void pca953x_irq_teardown(struct pca953x_chip *chip)
-{
-   if (chip-irq_base != -1) {
-   free_irq(chip-client-irq, chip);
-   }
-}
 #else /* CONFIG_GPIO_PCA953X_IRQ */
 static int pca953x_irq_setup(struct pca953x_chip *chip,
 const struct i2c_device_id *id,
@@ -614,10 +609,6 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 
return 0;
 }
-
-static void pca953x_irq_teardown(struct pca953x_chip *chip)
-{
-}
 #endif
 
 /*
@@ -736,7 +727,8 @@ static int pca953x_probe(struct i2c_client *client,
int ret;
u32 invert = 0;
 
-   chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
+   chip = devm_kzalloc(client-dev,
+   sizeof(struct pca953x_chip), GFP_KERNEL);
if (chip == NULL)
return -ENOMEM;
 
@@ -771,15 +763,15 @@ static int pca953x_probe(struct i2c_client *client,
else
ret = device_pca957x_init(chip, invert);
if (ret)
-   goto out_failed;
+   return ret;
 
ret = pca953x_irq_setup(chip, id, irq_base);
if (ret)
-   goto out_failed;
+   return ret;
 
ret = gpiochip_add(chip-gpio_chip);
if (ret)
-   goto out_failed_irq;
+   return ret;
 
if (pdata  pdata-setup) {
ret = pdata-setup(client, chip-gpio_chip.base,
@@ -790,12 +782,6 @@ static int pca953x_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, chip);
return 0;
-
-out_failed_irq:
-   pca953x_irq_teardown(chip);
-out_failed:
-   kfree(chip);
-   return ret;
 }
 
 static int pca953x_remove(struct i2c_client *client)
@@ -821,8 +807,6 @@ static int pca953x_remove(struct i2c_client *client)
return ret;
}
 
-   pca953x_irq_teardown(chip);
-   kfree(chip);
return 0;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/