From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 357BEC43612 for ; Mon, 31 Dec 2018 20:40:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED71021783 for ; Mon, 31 Dec 2018 20:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546288853; bh=bXn5PAxPmJETDf7IGQcCLV2q8CDe7Qpa3PLg0V7bzS8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=wsUPR+GlrCQWXqnIeakyvCcaLIPsdrzohRvJQNPbePkNDrrN4qRKVRHevWMINCe4K P8qtr4WNuZR1wfyXojpyLkpsxlF+cj9Jjd3hEtOcoag3YWIXE8dN0k3J3BmdjDe29K TrujOnNszlpe/LHpOW+z80GGTALdGl54XXMvMGFE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727987AbeLaUkw (ORCPT ); Mon, 31 Dec 2018 15:40:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:52394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727624AbeLaUkv (ORCPT ); Mon, 31 Dec 2018 15:40:51 -0500 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9CFF921019; Mon, 31 Dec 2018 20:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546288850; bh=bXn5PAxPmJETDf7IGQcCLV2q8CDe7Qpa3PLg0V7bzS8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aTYR1Zxi26Rp+SN7/3G2m+gYVKwErVNsjVHpWFL5sTx5WxMR6Mon/ZJGs/ZtmozxZ mw6+Iu9qEh6oz93zYpsX3T2eqRkrdyJMyrUWMNQHMrfhqCTSsAVRmMbQreg4gr9N4d 4l7OSzdzo9BflPdNxunHwPtSpk+kPjN/aKjPTUFc= Date: Mon, 31 Dec 2018 14:40:48 -0600 From: Bjorn Helgaas To: Kangjie Lu Cc: Lorenzo Pieralisi , Jingoo Han , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski , linux-samsung-soc@vger.kernel.org, Kukjin Kim , pakki001@umn.edu, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] pci: dwc: add a check for resetting gpio Message-ID: <20181231204048.GG159477@google.com> References: <20181226022236.71682-1-kjlu@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181226022236.71682-1-kjlu@umn.edu> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kangjie, Thanks for the patch. On Tue, Dec 25, 2018 at 08:22:36PM -0600, Kangjie Lu wrote: > devm_gpio_request_one() could fail. The fix checks its status and issues > an error if it fails. > > Signed-off-by: Kangjie Lu > --- > drivers/pci/controller/dwc/pci-exynos.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-exynos.c b/drivers/pci/controller/dwc/pci-exynos.c > index cee5f2f590e2..e3a045e215d2 100644 > --- a/drivers/pci/controller/dwc/pci-exynos.c > +++ b/drivers/pci/controller/dwc/pci-exynos.c > @@ -226,9 +226,12 @@ static void exynos_pcie_assert_reset(struct exynos_pcie *ep) > struct dw_pcie *pci = ep->pci; > struct device *dev = pci->dev; > > - if (ep->reset_gpio >= 0) > - devm_gpio_request_one(dev, ep->reset_gpio, > - GPIOF_OUT_INIT_HIGH, "RESET"); > + if (ep->reset_gpio >= 0) { > + if (devm_gpio_request_one(dev, ep->reset_gpio, > + GPIOF_OUT_INIT_HIGH, "RESET")) > + dev_err(dev, "Failed requesting reset gpio %d\n", > + ep->reset_gpio); > + } Even before your patch, this code doesn't make sense to me. devm_gpio_request_one() is a setup function and should be called in the probe path. The "assert_reset" path should do something like gpio_set_value(). See other callers, e.g., imx6_pcie_probe() histb_pcie_probe() mvebu_pcie_parse_port() I'm skeptical that exynos_pcie_assert_reset() ever worked as intended, so let's straighten that out before worrying about checking the return code from devm_gpio_request_one(). The result should be two patches: (1) fix the devm_gpio_request_one() usage, and (2) check the devm_gpio_request_one() return value. > } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21A8DC43387 for ; Mon, 31 Dec 2018 20:40:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E195621783 for ; Mon, 31 Dec 2018 20:40:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="G03D+S+I"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="aTYR1Zxi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E195621783 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V3vZPpEOZyTY931WA/8uH7pbkeWaqQ+oOtlOV5Madew=; b=G03D+S+IqBIiTV vGGYptXa9dsVzDNzo9UC1V1crBOtm5L1YtNbKQ3BWGhthaPjavZ+ymdk49BBTrLSFVu5AvfEZWgD/ gbz/1IUXW/qAhjhm/tp8/PzXUMcRNXFjfC26xes1kskS8EfRufre0aM3xTji7LrLdVU4kAuJJHrIi RJ8s0WLatqp0qBZ7SBCgaGwBEx2Bc/LnAA+Z4WrIgefnhW7MOt3FjtKw9921rVrxcaQeWM8oMs6EN JZCiReF6jA1XZC2lD/F+GNB/dgYwL5DvsBzsK/Q/6mdodu5Nri5Ty9jK9Du4Jt7aPeNSeBMoCSPCf lqnwDwDU/1sR9S025btw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ge4Mo-0006oM-M6; Mon, 31 Dec 2018 20:40:54 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ge4Ml-0006o1-Ss for linux-arm-kernel@lists.infradead.org; Mon, 31 Dec 2018 20:40:53 +0000 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9CFF921019; Mon, 31 Dec 2018 20:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546288850; bh=bXn5PAxPmJETDf7IGQcCLV2q8CDe7Qpa3PLg0V7bzS8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aTYR1Zxi26Rp+SN7/3G2m+gYVKwErVNsjVHpWFL5sTx5WxMR6Mon/ZJGs/ZtmozxZ mw6+Iu9qEh6oz93zYpsX3T2eqRkrdyJMyrUWMNQHMrfhqCTSsAVRmMbQreg4gr9N4d 4l7OSzdzo9BflPdNxunHwPtSpk+kPjN/aKjPTUFc= Date: Mon, 31 Dec 2018 14:40:48 -0600 From: Bjorn Helgaas To: Kangjie Lu Subject: Re: [PATCH] pci: dwc: add a check for resetting gpio Message-ID: <20181231204048.GG159477@google.com> References: <20181226022236.71682-1-kjlu@umn.edu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20181226022236.71682-1-kjlu@umn.edu> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181231_124051_955504_DD28B3B8 X-CRM114-Status: GOOD ( 16.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc@vger.kernel.org, Jingoo Han , pakki001@umn.edu, linux-kernel@vger.kernel.org, Krzysztof Kozlowski , Lorenzo Pieralisi , Kukjin Kim , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Kangjie, Thanks for the patch. On Tue, Dec 25, 2018 at 08:22:36PM -0600, Kangjie Lu wrote: > devm_gpio_request_one() could fail. The fix checks its status and issues > an error if it fails. > > Signed-off-by: Kangjie Lu > --- > drivers/pci/controller/dwc/pci-exynos.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-exynos.c b/drivers/pci/controller/dwc/pci-exynos.c > index cee5f2f590e2..e3a045e215d2 100644 > --- a/drivers/pci/controller/dwc/pci-exynos.c > +++ b/drivers/pci/controller/dwc/pci-exynos.c > @@ -226,9 +226,12 @@ static void exynos_pcie_assert_reset(struct exynos_pcie *ep) > struct dw_pcie *pci = ep->pci; > struct device *dev = pci->dev; > > - if (ep->reset_gpio >= 0) > - devm_gpio_request_one(dev, ep->reset_gpio, > - GPIOF_OUT_INIT_HIGH, "RESET"); > + if (ep->reset_gpio >= 0) { > + if (devm_gpio_request_one(dev, ep->reset_gpio, > + GPIOF_OUT_INIT_HIGH, "RESET")) > + dev_err(dev, "Failed requesting reset gpio %d\n", > + ep->reset_gpio); > + } Even before your patch, this code doesn't make sense to me. devm_gpio_request_one() is a setup function and should be called in the probe path. The "assert_reset" path should do something like gpio_set_value(). See other callers, e.g., imx6_pcie_probe() histb_pcie_probe() mvebu_pcie_parse_port() I'm skeptical that exynos_pcie_assert_reset() ever worked as intended, so let's straighten that out before worrying about checking the return code from devm_gpio_request_one(). The result should be two patches: (1) fix the devm_gpio_request_one() usage, and (2) check the devm_gpio_request_one() return value. > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel