Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1212099 > unrolled thread
| Started by | Peng Fan <van.freenix@gmail.com> |
|---|---|
| First post | 2015-08-24 14:10 +0200 |
| Last post | 2015-09-05 15:40 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] gpio: gpiolib: use devm_* API to simplify driver code Peng Fan <van.freenix@gmail.com> - 2015-08-24 14:10 +0200
Re: [PATCH] gpio: gpiolib: use devm_* API to simplify driver code Grygorii Strashko <grygorii.strashko@ti.com> - 2015-08-25 10:40 +0200
Re: [PATCH] gpio: gpiolib: use devm_* API to simplify driver code Alexandre Courbot <gnurou@gmail.com> - 2015-08-31 07:20 +0200
Re: [PATCH] gpio: gpiolib: use devm_* API to simplify driver code Peng Fan <van.freenix@gmail.com> - 2015-09-05 15:40 +0200
| From | Peng Fan <van.freenix@gmail.com> |
|---|---|
| Date | 2015-08-24 14:10 +0200 |
| Subject | [PATCH] gpio: gpiolib: use devm_* API to simplify driver code |
| Message-ID | <q0YJA-7eS-15@gated-at.bofh.it> |
Use devm_* API to simplify driver code.
Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
---
drivers/gpio/gpiolib.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 6bc612b..f9470b0 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -243,7 +243,8 @@ int gpiochip_add(struct gpio_chip *chip)
int base = chip->base;
struct gpio_desc *descs;
- descs = kcalloc(chip->ngpio, sizeof(descs[0]), GFP_KERNEL);
+ descs = devm_kcalloc(chip->dev, chip->ngpio, sizeof(descs[0]),
+ GFP_KERNEL);
if (!descs)
return -ENOMEM;
@@ -254,7 +255,7 @@ int gpiochip_add(struct gpio_chip *chip)
if (base < 0) {
status = base;
spin_unlock_irqrestore(&gpio_lock, flags);
- goto err_free_descs;
+ goto err_descs;
}
chip->base = base;
}
@@ -262,7 +263,7 @@ int gpiochip_add(struct gpio_chip *chip)
status = gpiochip_add_to_list(chip);
if (status) {
spin_unlock_irqrestore(&gpio_lock, flags);
- goto err_free_descs;
+ goto err_descs;
}
for (id = 0; id < chip->ngpio; id++) {
@@ -308,9 +309,7 @@ err_remove_chip:
list_del(&chip->list);
spin_unlock_irqrestore(&gpio_lock, flags);
chip->desc = NULL;
-err_free_descs:
- kfree(descs);
-
+err_descs:
/* failures here can mean systems won't boot... */
pr_err("%s: GPIOs %d..%d (%s) failed to register\n", __func__,
chip->base, chip->base + chip->ngpio - 1,
--
1.8.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Grygorii Strashko <grygorii.strashko@ti.com> |
|---|---|
| Date | 2015-08-25 10:40 +0200 |
| Message-ID | <q1hVV-1br-11@gated-at.bofh.it> |
| In reply to | #1212099 |
On 08/24/2015 03:05 PM, Peng Fan wrote: > Use devm_* API to simplify driver code. > > Signed-off-by: Peng Fan <van.freenix@gmail.com> > Cc: Linus Walleij <linus.walleij@linaro.org> > Cc: Alexandre Courbot <gnurou@gmail.com> --- > drivers/gpio/gpiolib.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index 6bc612b..f9470b0 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -243,7 +243,8 @@ int gpiochip_add(struct gpio_chip *chip) > int base = chip->base; > struct gpio_desc *descs; > > - descs = kcalloc(chip->ngpio, sizeof(descs[0]), GFP_KERNEL); > + descs = devm_kcalloc(chip->dev, chip->ngpio, sizeof(descs[0]), > + GFP_KERNEL); ^ above will not work for every one as NOT all GPIO drivers implemented using dev/drv model, so chip->dev could be not set (at least it was true when I've checked it last time). -- regards, -grygorii -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Alexandre Courbot <gnurou@gmail.com> |
|---|---|
| Date | 2015-08-31 07:20 +0200 |
| Message-ID | <q3pFD-6ti-1@gated-at.bofh.it> |
| In reply to | #1212832 |
On Tue, Aug 25, 2015 at 5:38 PM, Grygorii Strashko <grygorii.strashko@ti.com> wrote: > On 08/24/2015 03:05 PM, Peng Fan wrote: >> >> Use devm_* API to simplify driver code. >> >> Signed-off-by: Peng Fan <van.freenix@gmail.com> >> Cc: Linus Walleij <linus.walleij@linaro.org> >> Cc: Alexandre Courbot <gnurou@gmail.com> > > --- >> >> drivers/gpio/gpiolib.c | 11 +++++------ >> 1 file changed, 5 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c >> index 6bc612b..f9470b0 100644 >> --- a/drivers/gpio/gpiolib.c >> +++ b/drivers/gpio/gpiolib.c >> @@ -243,7 +243,8 @@ int gpiochip_add(struct gpio_chip *chip) >> int base = chip->base; >> struct gpio_desc *descs; >> >> - descs = kcalloc(chip->ngpio, sizeof(descs[0]), GFP_KERNEL); >> + descs = devm_kcalloc(chip->dev, chip->ngpio, sizeof(descs[0]), >> + GFP_KERNEL); > > > ^ above will not work for every one as NOT all GPIO drivers > implemented using dev/drv model, so chip->dev could be not set > (at least it was true when I've checked it last time). AFAICT that is still true as of today. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Peng Fan <van.freenix@gmail.com> |
|---|---|
| Date | 2015-09-05 15:40 +0200 |
| Message-ID | <q5lRi-1T7-31@gated-at.bofh.it> |
| In reply to | #1212832 |
On Tue, Aug 25, 2015 at 11:38:47AM +0300, Grygorii Strashko wrote: > On 08/24/2015 03:05 PM, Peng Fan wrote: > >Use devm_* API to simplify driver code. > > > >Signed-off-by: Peng Fan <van.freenix@gmail.com> > >Cc: Linus Walleij <linus.walleij@linaro.org> > >Cc: Alexandre Courbot <gnurou@gmail.com> > --- > > drivers/gpio/gpiolib.c | 11 +++++------ > > 1 file changed, 5 insertions(+), 6 deletions(-) > > > >diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > >index 6bc612b..f9470b0 100644 > >--- a/drivers/gpio/gpiolib.c > >+++ b/drivers/gpio/gpiolib.c > >@@ -243,7 +243,8 @@ int gpiochip_add(struct gpio_chip *chip) > > int base = chip->base; > > struct gpio_desc *descs; > > > >- descs = kcalloc(chip->ngpio, sizeof(descs[0]), GFP_KERNEL); > >+ descs = devm_kcalloc(chip->dev, chip->ngpio, sizeof(descs[0]), > >+ GFP_KERNEL); > > ^ above will not work for every one as NOT all GPIO drivers > implemented using dev/drv model, so chip->dev could be not set > (at least it was true when I've checked it last time). > Thanks for correcting me! Regards, Peng. > > > > -- > regards, > -grygorii -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web