Received: by 10.213.65.68 with SMTP id h4csp1167567imn; Mon, 26 Mar 2018 02:02:52 -0700 (PDT) X-Google-Smtp-Source: AG47ELtrhvPun8FNpmJ2jvslzt4Z3UOTXEpur9AkntX+u9UveY9H3qZ8aluItZuNG2RPp96812zF X-Received: by 2002:a17:902:a610:: with SMTP id u16-v6mr39251089plq.293.1522054972522; Mon, 26 Mar 2018 02:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522054972; cv=none; d=google.com; s=arc-20160816; b=Y65DZyz2kTTrgjDtTvbmGJAJeKB1RT2UXYWIu8vze8YiO+cJsHZvjqIu/wjGZyJ2Mp HWwThX00DryIi2eOiOIdvMc26Fm2XyJ2BuTCKGlpDqGIsykFi2dxDaxOeyu4HAkxcX98 DuKWWjYaoSrTCc9pxjMNduiEPtIpL6BgwVdxodAdZIz8OiQ792P5lB8b1P2y51aCI4ts Ape3EQFsyvLq1/AxR/x2eV6BJrqOP16aI9UGaUtC+ePZ/UCF7qArqblbSIFNYLYQcBnj 62guERRP+5IKewusqtLVu8kgAB813XCRVKj3Rj05UJN9ofwinkSxuy+lfRaPyokkA75g qKfA== 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 :dkim-signature:arc-authentication-results; bh=dpCuwO5ic8sr998ujF8XA9u7muRq892WvSDtnUohuGE=; b=qgBF5bC5IN8In+eE+fvw9gzCOV2DoLcz3v1H9YEpwxKSlwT5PrHLut0CQu436H2hoR HyyFo0lFX5n+GUT19EHMGlp8A0KdhNCL6iCi/io01reh3tUJNO5ghIGXASk3fg2aFSFx 6FPGMCv9j+Djd3RZkPGAv48C+okIrqpdoWevqAL9ICehAvNyu9OYh4T0Zwri6RGqEO8K lwVG4WnUwcUm/uuinxX0zPF3xSK+Fl4bSGPYnRe8WY4MyvGSekFTkqdytzgIyQWrAcAp XjD08Ouy3ui6pUv+bQFw7y2hHtfWZgWWfbl0FeHogt3RZPGn9QZvf5a5NWvWCLlscpYO Pzng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=jr4BwuHe; 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=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61-v6si14266333plr.136.2018.03.26.02.02.37; Mon, 26 Mar 2018 02:02:52 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=jr4BwuHe; 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751980AbeCZJBE (ORCPT + 99 others); Mon, 26 Mar 2018 05:01:04 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:39345 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750972AbeCZJBC (ORCPT ); Mon, 26 Mar 2018 05:01:02 -0400 Received: by mail-wm0-f65.google.com with SMTP id f125so13894599wme.4; Mon, 26 Mar 2018 02:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dpCuwO5ic8sr998ujF8XA9u7muRq892WvSDtnUohuGE=; b=jr4BwuHePdiIe9v2+2aDbFAyggJb/BbXR7T2W/EoPHG4kjdNub9gCLQ9y7vIYpvcjC eJO2H83ZfsDoBiQwj9S042UaeFyHiece8YaKtdXsxABkO2ACnqgvnIaS1jdoHRIWnaLI bvu0IUTLuCHs5M0z/3vMwoR53leUWwkGGuqgsIKuNIeobXsfW8WB5AymDPxn3GUdrfWF 7woF5zdynKC6/AZwuZOZ/BXgJVTWxaBlwVezxcLSVZTx+86LA1TiFe0AYZtjk6LzumTP 7FB1oAf9F/uN0cD5MATkwSHDL0dbRxaND/wnZ0vCVnubGYApxo2c/dw7WO3hLtAyIit5 rVZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=dpCuwO5ic8sr998ujF8XA9u7muRq892WvSDtnUohuGE=; b=PX7axkrHjf2I44tF6fZC1X/9ynq9P6S+WfMSsr2xJ/bEVuOWcq3TcKE1se/t/bIBzb 3jtYOZCgZqCZP44ieutz747QGwePiu17w/nAvmqvYLcZ7vCKHsZV5nkQYA3Jguy1c5/j /rfOt59D97HJ1DejCgOxljAUGTcVX3m2y7SPLtP7hlu9ow0De9Rq1GO7+7u/Ee58mlVY tirthQ3GQv/rHqjk362fbWx4iytkDhOcBUKYR0DX7K/rrKrW/KhFRZ8ZhyZVOl2QAMc2 1R5Buv7ILcFvGaqlfFlivrS6O0LKOk8tLRBwvaUh4Ajnva79Th9jmtJeYiHeGk1Pr8vj SlKw== X-Gm-Message-State: AElRT7FPFZCNo2QlVT1cYOixq9VhI4c/m0AQ/Zp0Pg+ASGCcAU+mYj33 YBrLaR80Bdea2W0A4tcLYQiFE83u X-Received: by 10.28.47.3 with SMTP id v3mr15668192wmv.96.1522054861166; Mon, 26 Mar 2018 02:01:01 -0700 (PDT) Received: from cizrna.lan ([109.72.12.210]) by smtp.gmail.com with ESMTPSA id w18sm11870472wra.25.2018.03.26.02.00.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Mar 2018 02:01:00 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Cc: Felipe Balbi , Heiko Stuebner , Tomeu Vizoso , Amelie Delaunay , Minas Harutyunyan , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [PATCH v4] usb: dwc2: dwc2_vbus_supply_init: fix error check Date: Mon, 26 Mar 2018 11:00:01 +0200 Message-Id: <20180326090001.57627-1-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180322093943.49717-1-tomeu.vizoso@collabora.com> References: <20180322093943.49717-1-tomeu.vizoso@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); } /* -- 2.14.3