Received: by 10.213.65.68 with SMTP id h4csp1691449imn; Thu, 5 Apr 2018 02:00:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/D3ETpqurL/Ij5EBZkp74kZkHvdlr9PeIR0EBmx8UVrM2hn16cPUbdrO+FZNRi0ANojqxc X-Received: by 2002:a17:902:7201:: with SMTP id ba1-v6mr14430753plb.0.1522918834489; Thu, 05 Apr 2018 02:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522918834; cv=none; d=google.com; s=arc-20160816; b=JArXl6/1XbN3YF6415DLY/bBknKINBgCXBraBv+3rENX9Tua0HOKZqF+Q9cxlyKaoA OCVpbN0AwsWZZ49AkzgnYo1Xk5Lv2yOr0jK8Y6wllB8++EUFRoaY5OYPXN/AhZiL/j71 /7fVM0Xpb2JZUJ8MOiJOu4ESbHBXJMCSnwvoaLcZ9fQ/zt+idpnAxSwOK4vy53wFxJmv L2CJoHW1CSQ0znXpD36vT2sC4Swv3nYCQVoDrF6us5sXTO+D7PdJD80FsFuayPw2WVio bgMDa8wn7sueEdTC8sLtN5xMAZklVmpef+kg6owIG9V+tmrqWbdGnRDv36Y3dZYTmuHF jxBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=pj5HIM8yo5m/w2qBhEt8kV6dWCRwIQAuaCcv6g6rnik=; b=F0+c6e88yTeJ5fqo2MR7J1PfuJ5LPyf9NEXhcojYWtxhiGtv/gzr7neV/bgvCMIkED xPBuNg5mSPNwaWJDW/4kOqcBykdB1Ue/DVeze4W8O3FyqO+2ppZoOXje6M4eMngYZvzP wnRMaJf8p18uhpnKHjRra6VZkndEnfFpOBEEq0rNrTmhOlwlOdfYdRbMDhONbUE2MIMr BVz2R6cdh309yOTn4uH7NnDSgYG0cCvjyVemmQCk8P+W83BpWKyICXqTl8NWVOiHolOX kYT6QGoLjudXUuH0oBowUXoxPfQle56qEFXp1xBHPGX6JQoierJYTB5Wlhc/bDFNumBH VG2g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e33-v6si5363952pld.404.2018.04.05.02.00.20; Thu, 05 Apr 2018 02:00: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751425AbeDEI7B convert rfc822-to-8bit (ORCPT + 99 others); Thu, 5 Apr 2018 04:59:01 -0400 Received: from smtprelay.synopsys.com ([198.182.60.111]:42456 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751251AbeDEI67 (ORCPT ); Thu, 5 Apr 2018 04:58:59 -0400 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 2CFA210C12E3; Thu, 5 Apr 2018 01:58:59 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id DDFFD3A3F; Thu, 5 Apr 2018 01:58:58 -0700 (PDT) Received: from US01WEHTC2.internal.synopsys.com (us01wehtc2-vip.internal.synopsys.com [10.12.239.238]) by mailhost.synopsys.com (Postfix) with ESMTP id 494D33A3A; Thu, 5 Apr 2018 01:58:58 -0700 (PDT) Received: from AM04WEHTCA.internal.synopsys.com (10.116.16.190) by US01WEHTC2.internal.synopsys.com (10.12.239.237) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 5 Apr 2018 01:58:58 -0700 Received: from AM04WEMBXB.internal.synopsys.com ([fe80::1006:bcdd:1b7:579b]) by am04wehtca.internal.synopsys.com ([::1]) with mapi id 14.03.0361.001; Thu, 5 Apr 2018 12:58:55 +0400 From: Grigor Tovmasyan To: Tomeu Vizoso , "linux-kernel@vger.kernel.org" CC: Felipe Balbi , Heiko Stuebner , 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 Thread-Topic: [PATCH v4] usb: dwc2: dwc2_vbus_supply_init: fix error check Thread-Index: AQHTxOD/EnRsRkoOHE2ZtYRlyd+fGg== Date: Thu, 5 Apr 2018 08:58:54 +0000 Message-ID: <32EB88BF8EC1614E9FB18BD3718BE1A116412614@am04wembxb.internal.synopsys.com> References: <20180322093943.49717-1-tomeu.vizoso@collabora.com> <20180326090001.57627-1-tomeu.vizoso@collabora.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.116.104.144] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/26/2018 1:01 PM, Tomeu Vizoso wrote: > 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 > > --- > > 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); > } > > /* > Reviewed-by: Grigor Tovmasyan