lkml.org 
[lkml]   [2015]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] gpio: gpiolib: use devm_* API to simplify driver code
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


\
 
 \ /
  Last update: 2015-08-25 11:01    [W:0.107 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site