Received: by 10.213.65.68 with SMTP id h4csp600558imn; Thu, 22 Mar 2018 04:42:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELuHImWDLyjqBMs0lJyjrIUoXWp7mooRb3aoPan3L+fSpW7l0TJrqbmRNZr/uAeHTpr49MGc X-Received: by 10.98.49.135 with SMTP id x129mr20105872pfx.75.1521718964458; Thu, 22 Mar 2018 04:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521718964; cv=none; d=google.com; s=arc-20160816; b=T4yKxdI+rIws03jIm2eDjTs+6zxNr0OBEWzqSHPvY+qE+5uRvHQfUMYrc7vE4zC4zn CnTKBGyMDq5tSZx2qAPEIwlx49cybk6Nc4gPF7k01NAsZpWoBmQB5egeqYEaOGrZznb+ pL9VJj4BH6dtpZ7/iX+zXfqMVFSkHJpMp5BqQnO3s08IWwSRKPTPImJghFaX4Az6jNqV 5c6OHqIattozVRg7rYPqtO+tc6W2mDwnBudmmcbAdN0GWcu4U+KT+UH9ceF4G2lnad0o 1/5B8nW5Ne9vfNee1K0NcvoL0RUBlQQ1B1xd7q5wxg1rQp90Gyoo2yoq7LTSOMNZIsVU 7hhw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hERPMPfA4yetZ7OX5wZj9CYRwg64/rWhsvCFMiUPBVs=; b=N2fMFResgw/5Xb333WGUawrXSYDNQodjsFY8jo/Riyh3ez0Ca58gNGfNtp7k4hBwZ1 fv1NCElMfI1TDpwxm6BSmYIc922pwXw3CzW3WOVkb8I3SG9YGb0EoyfXIyjatzO0UeDz Lwr9nooM+Ws7mf/xhLYGFqAeDixHtbBB8aWPURvi5Sl2whizGMQT56Hnj93btNK/xGq/ Y8ycvDCLj3UfRq5Lc5YzCz2XiMQbEMUhkyLxo9XPmrOxBngPYX6MsxyMLewzSs/BPXA2 07hd4rBem4R8ilNslWmYgRCKnPMZFnAja5BEtFOcexZf1mki45vDLogXzsGEOZy8bVVB CrRw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5-v6si5965717plf.396.2018.03.22.04.42.29; Thu, 22 Mar 2018 04:42:44 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752730AbeCVLj0 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 22 Mar 2018 07:39:26 -0400 Received: from gloria.sntech.de ([95.129.55.99]:55428 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751875AbeCVLjX (ORCPT ); Thu, 22 Mar 2018 07:39:23 -0400 Received: from ip9234b5ec.dynamic.kabel-deutschland.de ([146.52.181.236] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.1:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1eyyYr-0001iw-Ll; Thu, 22 Mar 2018 12:39:13 +0100 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Tomeu Vizoso Cc: linux-kernel@vger.kernel.org, Felipe Balbi , Amelie Delaunay , Minas Harutyunyan , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: Re: [PATCH] usb: dwc2: dwc2_vbus_supply_init: fix error check Date: Thu, 22 Mar 2018 12:39:13 +0100 Message-ID: <1711886.RiDBCvOSMq@diego> In-Reply-To: <20180322093943.49717-1-tomeu.vizoso@collabora.com> References: <20180322093943.49717-1-tomeu.vizoso@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="iso-8859-1" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Donnerstag, 22. M?rz 2018, 10:39:43 CET schrieb Tomeu Vizoso: > devm_regulator_get_optional returns -ENODEV if the regulator isn't > there, so if that's the case we have to make sure not to leave -ENODEV > in the regulator pointer. > > Also, make sure we return 0 in that case, but correctly propagate any > other errors. Also propagate the error from _dwc2_hcd_start. > > Fixes: 531ef5ebea96 ("usb: dwc2: add support for host mode external vbus > supply") Cc: Amelie Delaunay > Signed-off-by: Tomeu Vizoso Thanks for catching that oops in your tests. Reviewed-by: Heiko Stuebner > --- > drivers/usb/dwc2/hcd.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c > index dcfda5eb4cac..4ae211f65e85 100644 > --- a/drivers/usb/dwc2/hcd.c > +++ b/drivers/usb/dwc2/hcd.c > @@ -359,8 +359,13 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg *hsotg) > static int dwc2_vbus_supply_init(struct dwc2_hsotg *hsotg) > { > hsotg->vbus_supply = devm_regulator_get_optional(hsotg->dev, "vbus"); > - if (IS_ERR(hsotg->vbus_supply)) > - return 0; > + if (IS_ERR(hsotg->vbus_supply)) { > + hsotg->vbus_supply = NULL; > + if (PTR_ERR(hsotg->vbus_supply) == -ENODEV) > + return 0; > + else > + return PTR_ERR(hsotg->vbus_supply); > + } > > return regulator_enable(hsotg->vbus_supply); > } > @@ -4342,9 +4347,7 @@ static int _dwc2_hcd_start(struct usb_hcd *hcd) > > spin_unlock_irqrestore(&hsotg->lock, flags); > > - dwc2_vbus_supply_init(hsotg); > - > - return 0; > + return dwc2_vbus_supply_init(hsotg); > } > > /*