From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755436AbbHYIix (ORCPT ); Tue, 25 Aug 2015 04:38:53 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:41046 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752320AbbHYIiu (ORCPT ); Tue, 25 Aug 2015 04:38:50 -0400 Message-ID: <55DC2997.9030705@ti.com> Date: Tue, 25 Aug 2015 11:38:47 +0300 From: Grygorii Strashko User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Peng Fan , , CC: , Subject: Re: [PATCH] gpio: gpiolib: use devm_* API to simplify driver code References: <1440417930-15876-1-git-send-email-van.freenix@gmail.com> In-Reply-To: <1440417930-15876-1-git-send-email-van.freenix@gmail.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/24/2015 03:05 PM, Peng Fan wrote: > Use devm_* API to simplify driver code. > > Signed-off-by: Peng Fan > Cc: Linus Walleij > Cc: Alexandre Courbot --- > 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