Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932586AbdDGKHh (ORCPT ); Fri, 7 Apr 2017 06:07:37 -0400 Received: from mail-io0-f174.google.com ([209.85.223.174]:33275 "EHLO mail-io0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752171AbdDGKH2 (ORCPT ); Fri, 7 Apr 2017 06:07:28 -0400 MIME-Version: 1.0 In-Reply-To: References: <6bf04ba1761f0692cb461558f0c8836f0d1f7ad8.1490595641.git.nandor.han@ge.com> From: Linus Walleij Date: Fri, 7 Apr 2017 12:07:26 +0200 Message-ID: Subject: Re: [PATCH 1/3] gpio - Add EXAR XRA1403 SPI GPIO expander driver To: "Han, Nandor (GE Healthcare)" Cc: Alexandre Courbot , Rob Herring , Mark Rutland , "linux-gpio@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Malinen, Semi (GE Healthcare)" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1100 Lines: 28 On Wed, Apr 5, 2017 at 3:24 PM, Han, Nandor (GE Healthcare) wrote: > [Me] >> > + /* bring the chip out of reset */ >> > + reset_gpio = gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW); >> > + if (IS_ERR(reset_gpio)) >> > + dev_warn(&spi->dev, "could not get reset-gpios\n"); >> > + else if (reset_gpio) >> > + gpiod_put(reset_gpio); >> >> I don't think you should put it, other than in the remove() >> function and in that case you need to have it in the >> state container. > > Can you please be more explicit here. > > Currently I'm trying to bring the device out from reset in case reset GPIO is provided. > I don't see how this could be done in remove() :) If you issue gpiod_put() you release the GPIO hande so something else can go in and grab the GPIO and assert the reset. This is not what you want to make possible: you want to hold this gpiod handle as long as the driver is running. devm_gpiod_get_optional() will do the trick if you don't want to put the handle under explicit control. Yours, Linus Walleij