Received: by 10.213.65.68 with SMTP id h4csp3839210imn; Tue, 10 Apr 2018 05:35:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+zqIJ2sw40ILlfr8p6CN4LxUfMz7qWLYrOrDsYMFR5D+GZdM79d67b3nfkvzmAVxCv73K2 X-Received: by 2002:a17:902:6a10:: with SMTP id m16-v6mr243574plk.370.1523363734337; Tue, 10 Apr 2018 05:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523363734; cv=none; d=google.com; s=arc-20160816; b=luxFx+TYyUD++TuXjqdYyVUwj7sTsyHWPXGcnKsA1B+1AZX9MMKlEwbKGZBofZmK7/ Z+62DEGtKkupqotdlpVIcAzvbSR3Nhyy2S/s4Cj6qeYtFEkApWJE1uznuBpmJAxY3aR8 xj5N7wQBnJWgUWerZ3e/vZsLkRtgum5TCmbJPo8hWpSslC9DULMXcQ1HXNUlLrnHF+Wk eJn+0qW4qvy9st5CSTFlkBbgeLAzoxtUCUwYkED5FbSMEnWp7ZKvddBQsqu0jSWO4wQV BBrayfF6RnmJaUoBikEWbid93XZaCOZ5UTIQmkwv7UCT5sXlcbxIaUtzbox9KUiEfmf1 4rDQ== 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=OS6MnnPsS8ywbwsbK6E3vX7rPzQ8mzRtcbIWGXbciXQ=; b=dHa7nLHss9XHMQD4uP7b4xRbyA49JWcASm/2vqvhKTOMSA7VBaa9tR0wEW6FI7m/OG 3Sg44tMDXa7/qqrvpj0Me2xH8Cy5cFx/kfICIbdR8Ack0MyQzyCZDw/gaf0N3usYdvvC X1KjA5hYmQRPmwDdpI6zbTQQjweNyl+7jjkzBBAFJkFu9dcA43wMTEaK84iM5emhlMEx /QA+A2YdS4YuAhtMzwudgoO4FNU+vrJnlBbOQi0kPKh5AP+phXnOVRC5dapx5UX7D0p8 79eg4vEPUR3M3eYsjnoM7nvDtQk1cE1Lr9NMI4n0vbrGdcerwfViou0U6r7iZz2s8xGq qffQ== 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 s3-v6si2305429plp.682.2018.04.10.05.34.57; Tue, 10 Apr 2018 05:35:34 -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 S1752877AbeDJM2u convert rfc822-to-8bit (ORCPT + 99 others); Tue, 10 Apr 2018 08:28:50 -0400 Received: from gloria.sntech.de ([95.129.55.99]:53236 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752700AbeDJM2s (ORCPT ); Tue, 10 Apr 2018 08:28:48 -0400 Received: from wd0542.dip.tu-dresden.de ([141.76.110.30] helo=phil.localnet) by gloria.sntech.de with esmtpsa (TLS1.1:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1f5sO9-0004Qs-13; Tue, 10 Apr 2018 14:28:41 +0200 From: Heiko Stuebner 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 v4] usb: dwc2: dwc2_vbus_supply_init: fix error check Date: Tue, 10 Apr 2018 14:28:35 +0200 Message-ID: <4613360.AXT7q7Ng0i@phil> In-Reply-To: <20180326090001.57627-1-tomeu.vizoso@collabora.com> References: <20180322093943.49717-1-tomeu.vizoso@collabora.com> <20180326090001.57627-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 Montag, 26. M?rz 2018, 11:00:01 CEST 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 The patch that gets fixed here also breaks display-output on dwc2-based Rockchip devices (likely even more), probably due to making the regulator framework hickup. With this patch applied, apart from not seeing the NULL-ptr, I also get display output on my rk3288-veycron Chromebook again, so Tested-by: Heiko Stuebner > v2: Only overwrite the error in the pointer after checking it (Heiko > St?bner ) > v3: Remove hunks that shouldn't be in this patch > v4: Don't overwrite the error code before returning it (kbuild test > robot ) > --- > 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 190f95964000..c51b73b3e048 100644 > --- a/drivers/usb/dwc2/hcd.c > +++ b/drivers/usb/dwc2/hcd.c > @@ -358,9 +358,14 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg *hsotg) > > static int dwc2_vbus_supply_init(struct dwc2_hsotg *hsotg) > { > + int ret; > + > hsotg->vbus_supply = devm_regulator_get_optional(hsotg->dev, "vbus"); > - if (IS_ERR(hsotg->vbus_supply)) > - return 0; > + if (IS_ERR(hsotg->vbus_supply)) { > + ret = PTR_ERR(hsotg->vbus_supply); > + hsotg->vbus_supply = NULL; > + return ret == -ENODEV ? 0 : ret; > + } > > 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); > } > > /* >