Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751988AbdDHHjM (ORCPT ); Sat, 8 Apr 2017 03:39:12 -0400 Received: from mx0b-00176a03.pphosted.com ([67.231.157.48]:38175 "EHLO mx0a-00176a03.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751154AbdDHHjD (ORCPT ); Sat, 8 Apr 2017 03:39:03 -0400 From: "Han, Nandor (GE Healthcare)" To: Linus Walleij 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)" Thread-Topic: Re: [PATCH 1/3] gpio - Add EXAR XRA1403 SPI GPIO expander driver Thread-Index: AQHSpsKisO+GNwMHKEiVTGcNOcZLiaGrFNgAgAuzFXCAAvgRAIABZ1fA Date: Sat, 8 Apr 2017 07:38:50 +0000 Message-ID: References: <6bf04ba1761f0692cb461558f0c8836f0d1f7ad8.1490595641.git.nandor.han@ge.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=ge.com; x-originating-ip: [205.173.90.58] x-microsoft-exchange-diagnostics: 1;HE1P101MB0188;7:LSi7eV5ksr+Wv/ErNNMAL4SmTWWgYz8QOZQbMjZyMdDdLvACSKOESh9GpDbKctU2JJdzW6VpEoQ4AUY3IH0jk7pQZWx+8M9PWwVzQeA7ZDu5+nmxSe6EWoE9VdADEtqH6nY9lV+V2r90DbXmEQqC1kE6J47dE1VcJqHbTKuW4IulTeVzUA1zlT1JMm3CBNBBfrfXImPs77NvBYWNzC/pcZgTdWC2qbKN1gtyRTVhOf3fKz7LAw324Mk8wPqjnX+w9GrqSsOzWWVhKe3Ou4J7wjgdudq9HxkFsX1f50MDe8hXe5S2zutHEQoSe4RXQyDrLqMIMI89JTCGbPsoFN9j8A== x-ld-processed: 15ccb6d1-d335-4996-b6f9-7b6925f08121,ExtAddr x-ms-office365-filtering-correlation-id: 388c1f47-d5e0-415e-97de-08d47e524cc5 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(201703131423075)(201703031133081)(201702281549075);SRVR:HE1P101MB0188; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(9452136761055)(106981052589767); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(6041248)(20161123562025)(20161123560025)(20161123564025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(6072148);SRVR:HE1P101MB0188;BCL:0;PCL:0;RULEID:;SRVR:HE1P101MB0188; x-forefront-prvs: 0271483E06 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39400400002)(39410400002)(39450400003)(39840400002)(39850400002)(377454003)(24454002)(13464003)(5660300001)(305945005)(2906002)(53936002)(54906002)(55016002)(6246003)(9686003)(7736002)(4326008)(53546009)(25786009)(189998001)(110136004)(122556002)(33656002)(38730400002)(39060400002)(6436002)(8676002)(81166006)(8936002)(7696004)(3280700002)(66066001)(3660700001)(93886004)(6916009)(76176999)(86362001)(54356999)(50986999)(229853002)(6506006)(2950100002)(74316002)(2900100001)(3846002)(102836003)(6116002)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1P101MB0188;H:HE1P101MB0188.NAMP101.PROD.OUTLOOK.COM;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2017 07:38:50.2143 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 15ccb6d1-d335-4996-b6f9-7b6925f08121 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P101MB0188 X-OriginatorOrg: ge.com Subject: [PATCH 1/3] gpio - Add EXAR XRA1403 SPI GPIO expander driver X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-04-08_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704080070 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v387dJbU005166 Content-Length: 2242 Lines: 53 > -----Original Message----- > From: Linus Walleij [mailto:linus.walleij@linaro.org] > Sent: 07 April 2017 13:07 > 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) > Subject: EXT: Re: [PATCH 1/3] gpio - Add EXAR XRA1403 SPI GPIO expander driver > > 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. > That was my first intention to release the reset line in case somebody else wants to control it. I did it like that because usually reset line controls multiple devices and probably some upper layer wants to control that. After your comment I did some analysing and I will follow your advice and change the reset line handling. Once the GPIO is provided to the driver the driver will own it and bring out the device from reset. In case not provided the reset line is somebody else responsibility. This way we are able to cover multiple use-cases. Thanks Linus, Nandy > Yours, > Linus Walleij