Received: by 10.192.165.148 with SMTP id m20csp426821imm; Wed, 2 May 2018 02:45:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqePDqMA8UfKIEJPkkjwoR61gAAQC6a4rdqLgpOxU334rhDt7VFrRetnzzB8JIt0Vr4gK8r X-Received: by 2002:a63:5f4c:: with SMTP id t73-v6mr15671320pgb.226.1525254354790; Wed, 02 May 2018 02:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525254354; cv=none; d=google.com; s=arc-20160816; b=g+05KlZOKg/Zo6ecM9fAABvIItlvds7yl8InclTpxhxHhphWb12vvh39U5lgryiSIy 9xU70sKTKWgMeRnt5Ngxy7psP+ZYgQP2VOJmjP2TfvQ9p9axbUpU1zCprBkUIJCYTwrE 0tfDgHOpQHXu1Wv5cVr35MlF1rApUqBML9aihfmCFJkeC4FXfWO1oZo5iC99wT3zBs8d jpXlXvyNJ5ouW5dt4q8EuwOxMW3qDlzJUnFzT/m7W+a0S7DEO3JB9zjEl5OQjubFI1Mv 7vAB2UimntmhRXHq/EgU6KrItFTnJH/rRUVoNqgCRFfkA5sOXXSu35HNIZrHMk8BpOms 3Otw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature:arc-authentication-results; bh=rOm/VWwt7kozkguu0l3iVGqlcF3z8sjTzsKfTLFdUMo=; b=g+wsUNJECcnuFkbr1cmpfheFzzMu+U5TVF8NB5SxmQP676ouuQK13FNFxWvaPTKt17 2we9am5hFxFfVKIGEbfPTXR1yrHSHs3h6UBlnev4AHJjXtYbch8oXHJ3bUeFKAwJiA2a Xo/45yKChsdB48KNm9c/4OCA0gA1OYarjmuYUO75N8zgNp4AnPeRVWGHuyhL5NGbg6lM uvd0V47dA86MvWQqZLukCX1oTIPsS0J4pUxFd7zlNKTAyJ2lWaVi3De5OiujS5LsjBqF YL32W71QS+SK4TfonKio1cdZY55+wefyJhM71Kwdb8rb3R1COdL2zZuq00ASNkG/GsMI Tnjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dzcgtAJ4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s204-v6si2005269pgs.164.2018.05.02.02.45.39; Wed, 02 May 2018 02:45:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dzcgtAJ4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751271AbeEBJpZ (ORCPT + 99 others); Wed, 2 May 2018 05:45:25 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:44497 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750883AbeEBJpU (ORCPT ); Wed, 2 May 2018 05:45:20 -0400 Received: by mail-pf0-f195.google.com with SMTP id q22so11317762pff.11 for ; Wed, 02 May 2018 02:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=rOm/VWwt7kozkguu0l3iVGqlcF3z8sjTzsKfTLFdUMo=; b=dzcgtAJ4iCh20PeTWMN6oP5Cohq4W1NMo244evzELsTMncjUVvX+CGgsngX7O4uNFb TQschsoQxJE2liuI2FxkeS/2GoNJ+I4cjjAauaX2OVZRvR5NWiaVcwz2o54LyBJ5OY0w uSqQSjhrcSh/G4WiU7cZZCRSisefhcDtXFKsqgcn3rC0EZrHMKGjqDoAobYGaUvMaRMS QHaG9NxHTYdbQqQHaFC1msansPRWhmmrw1QTxMJOeOpJigmhXmyssuW03RQyek08Kesl OzXHKm5fS9QYYUY7mSxHTMgsHZR18fo8Jdd4Ut2K6RttFUGS8YWhzvMYlcwmzGwl44bm Hrow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=rOm/VWwt7kozkguu0l3iVGqlcF3z8sjTzsKfTLFdUMo=; b=kCNrVl7TSX2FpDRVmWItAqCXKjsdMhyWMW6YqjxkKxDxfGqpzGsyXKQxCtGc+CDIUq P5P5UwqXZICWoGV6TzAe0tZ2lJsLqHY1i/K9gLRyiDQOkr13NwMwDUPlS2oB5TECyJ9G d+oKqpESCJvou+cXwIlHyqQkYf0nRG0S2g7knjGBXM8/xqjHCsLQsivO7o/r1QaEM0FH E9pOXuFayVkfoEhoo31egNY1kwUAvljxevXV9SOWLsyPaMhwinxZ6r2rMPV27Nrtq4AZ +adSW0Y+Bl27a9AIHAPMrUlB/lfy1Jy6BpAmncMEqEAOE+um8Un+pN4mxnPxe/c7TkR+ zUMA== X-Gm-Message-State: ALQs6tBuggrZbKSEat/hjbtnGKG4nnreapr8JWUt87AVdPcVFIkfv+XK YYlklV7OdnmFmgspqqWquhQ= X-Received: by 2002:a17:902:780d:: with SMTP id p13-v6mr19514799pll.281.1525254320293; Wed, 02 May 2018 02:45:20 -0700 (PDT) Received: from [10.17.129.40] ([149.23.17.254]) by smtp.gmail.com with ESMTPSA id t11-v6sm19348167pgn.94.2018.05.02.02.45.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 May 2018 02:45:19 -0700 (PDT) Subject: Re: [PATCH v2] staging: greybus: Use gpio_is_valid() To: Johan Hovold References: <5c8c96b1971bc09a2a2bfa62c343973ab986aec8.1524889296.git.arvind.yadav.cs@gmail.com> <20180502084308.GF2285@localhost> Cc: hvaibhav.linux@gmail.com, elder@kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, greybus-dev@lists.linaro.org, devel@driverdev.osuosl.org From: Arvind Yadav Message-ID: <2aa263ef-1bbc-69fc-c007-303e59517081@gmail.com> Date: Wed, 2 May 2018 15:15:05 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20180502084308.GF2285@localhost> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 02 May 2018 02:13 PM, Johan Hovold wrote: > On Sat, Apr 28, 2018 at 10:05:39AM +0530, Arvind Yadav wrote: >> Replace the manual validity checks for the GPIO with the >> gpio_is_valid(). >> >> Signed-off-by: Arvind Yadav >> --- >> chnage in v2 : >> Returning invalid gpio as error instead of -ENODEV. >> >> drivers/staging/greybus/arche-platform.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c >> index 83254a7..c3a7da5 100644 >> --- a/drivers/staging/greybus/arche-platform.c >> +++ b/drivers/staging/greybus/arche-platform.c >> @@ -448,7 +448,7 @@ static int arche_platform_probe(struct platform_device *pdev) >> arche_pdata->svc_reset_gpio = of_get_named_gpio(np, >> "svc,reset-gpio", >> 0); >> - if (arche_pdata->svc_reset_gpio < 0) { >> + if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) { >> dev_err(dev, "failed to get reset-gpio\n"); >> return arche_pdata->svc_reset_gpio; > I'm sorry, but I don't this change is desirable. of_get_named_gpio() > returns a valid gpio number or a negative errno, so there's no need to > use the legacy gpio_is_valid() helper here. > > If you grep for of_get_named_gpio() you'll find that some drivers indeed > use that helper this way, but they are in a clear minority. > > And ultimately, we want to move to using gpio descriptors anyway. We need to check gpio validity. If we are using of_get_named_gpio() or not. of_get_name_gpio() will read a device node and fetch the value. But it'll not check that gpio is valid or not valid. > >> } >> @@ -468,7 +468,7 @@ static int arche_platform_probe(struct platform_device *pdev) >> arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np, >> "svc,sysboot-gpio", >> 0); >> - if (arche_pdata->svc_sysboot_gpio < 0) { >> + if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) { >> dev_err(dev, "failed to get sysboot gpio\n"); >> return arche_pdata->svc_sysboot_gpio; >> } >> @@ -487,7 +487,7 @@ static int arche_platform_probe(struct platform_device *pdev) >> arche_pdata->svc_refclk_req = of_get_named_gpio(np, >> "svc,refclk-req-gpio", >> 0); >> - if (arche_pdata->svc_refclk_req < 0) { >> + if (!gpio_is_valid(arche_pdata->svc_refclk_req)) { >> dev_err(dev, "failed to get svc clock-req gpio\n"); >> return arche_pdata->svc_refclk_req; >> } > But if this were to be changed, you'd need to update also the fourth > call to of_get_named_gpio() in this function. Sorry, I missed it. Thanks for point out. I will add check for this. ~arvind > > Thanks, > Johan