Received: by 10.213.65.68 with SMTP id h4csp1733186imn; Thu, 5 Apr 2018 02:53:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+U99ExTenuu89Ej59oFIXaF3IC0ZHbd+/nPId23LBWjDBtzUIyT7z99qul+CcBxBsMCGlj X-Received: by 10.99.101.199 with SMTP id z190mr4123946pgb.385.1522921993086; Thu, 05 Apr 2018 02:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522921993; cv=none; d=google.com; s=arc-20160816; b=oGUr/JHX3XUTOgewrSOfs5VDa/msze+OeBpjxaWOfC2Hs3/kcZcbVu5GSSj0TWOKwk wNpseMrXI9MAEWtAVrZfY4HeeGFdXul8GpvWaaMNME6XcWTgPi+JncdvmvR4DRf4E+y0 d5MLkIlaFhkViHnE29UMSp5RNaB6q48+g/kDbn3hTOlpqDK1+OVtKbfoClcfQuTILkxL 8tsFMq2NXip1MoP7avIuWogylgBd2bRVzYpUC1y5ENtN+nHCeLjHgX5jjFZc2mR2MgjG iS5iqoVuVzoI4sDnDzzabPpT6tax+vbwmmambg7lkSROzFv1oSXbPqGQTaBd+GWshjxg 6PYQ== 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=uJLaDiqGbd5JzcJMLvXinHE2X8nIK2uaLdFJNrpkyh0=; b=uCVPMomXi48dzTfJxOpCwuOM1YvEWz+c802rqpaV+zBI8mjYNAAOgsersk6a5JnGGn H5XrL7LYZDe5L4uHRp6fD12ZwCKRHv08RyCoGkevLGW8uSf1A4XWjWhAT8re2buzzMxa opd58qp+V5aBNT0lygHHjkrvkGbHjcw6SrqDU04UQsZMBLjHDwnL2cMlJqGbmM63iJxl t9UcR02OxgTXJqJoNqLDHOtzcDM0bWCyUqic2Os8m+zc3mxb2HhbcFXxcuyAUdo0oS0O 1toF9e4XcCDB6xmUthhvJbD3GHTMq/YDg3LwZeyk9U2O2giOXThMjN71+Cu/o6EoZ/Lc ZglA== 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 29si3389097pfj.6.2018.04.05.02.52.59; Thu, 05 Apr 2018 02:53:13 -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 S1752461AbeDEJvj convert rfc822-to-8bit (ORCPT + 99 others); Thu, 5 Apr 2018 05:51:39 -0400 Received: from smtprelay.synopsys.com ([198.182.60.111]:43485 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752423AbeDEJvg (ORCPT ); Thu, 5 Apr 2018 05:51:36 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 16F4310C124D; Thu, 5 Apr 2018 02:51:36 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id EFE8A576D; Thu, 5 Apr 2018 02:51:35 -0700 (PDT) Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id D7E48576C; Thu, 5 Apr 2018 02:51:35 -0700 (PDT) Received: from AM04WEHTCB.internal.synopsys.com (10.116.16.192) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 5 Apr 2018 02:51:35 -0700 Received: from AM04WEMBXB.internal.synopsys.com ([fe80::1006:bcdd:1b7:579b]) by am04wehtcb.internal.synopsys.com ([::1]) with mapi id 14.03.0361.001; Thu, 5 Apr 2018 13:51:32 +0400 From: Minas Harutyunyan To: Grigor Tovmasyan , 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: AQHTxOD8nEoVzOZ04EOGN7z3QZ1Kzw== Date: Thu, 5 Apr 2018 09:51:31 +0000 Message-ID: <410670D7E743164D87FA6160E7907A560113AE54A5@am04wembxb.internal.synopsys.com> References: <20180322093943.49717-1-tomeu.vizoso@collabora.com> <20180326090001.57627-1-tomeu.vizoso@collabora.com> <32EB88BF8EC1614E9FB18BD3718BE1A116412614@am04wembxb.internal.synopsys.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.116.70.63] 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 4/5/2018 12:59 PM, Grigor Tovmasyan wrote: > 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 > Acked-by: Minas Harutyunyan