Received: by 10.213.65.68 with SMTP id h4csp676513imn; Thu, 22 Mar 2018 06:17:34 -0700 (PDT) X-Google-Smtp-Source: AG47ELsxjOBr7sfq2bpQSscLEpUhpB5YeRJA3ilZehiRBf8aLbaEg8Id6880uw8jyAKnGFfro72r X-Received: by 2002:a17:902:822:: with SMTP id 31-v6mr24558282plk.362.1521724654092; Thu, 22 Mar 2018 06:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521724654; cv=none; d=google.com; s=arc-20160816; b=zd7hPN99zz5h5swLT9TKDrvfksPY+ZZebEM8O6uz/L+nKTzFJPR8XDd1oArCV6xnsX mEsq3sZFjgt4Jx/aPZtcUCQRyG6j8szPCsZMRtyU4dnZkrNCW2UPvU6yejW14lCOqQqS WYmvC+eku7RCKr0nItTtL1KrSXG7voEi+svVykVg6mhEHmo03UGdPJMZOXqROdutTlgc YfSwkDkooVR4Itkp4c49XXvnq92xxsigzhwYYwxIOzXCX7zVPjH/OEYyPM+J3k+5NpHr lW3E0yvfPoqesXHjwty7Gw82LMd9mkBWEuz3m6vHwr2pprxx6svrKMboPpdsBsMJTJPY QzeQ== 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=OTN5fcY4D05x2aLJsFXenKBgUlvWaaZhkND8ovWTlfE=; b=cGztLmZA67lgdxeos7LYTqaMFIMtBlfFGTh3/+WBLQDL9MlJr0kFighnTj7uS3NLcj e0M4wjlAGE4vAAqkCwdLBalWsfLLTWG4OdiJTfrYmFn/YtcTkcgfPnSkuDWltozbdnLJ B22r/6GCiZlgwbtprIKY7T3I62/BFeP0SmlRm88ijN6kFl7tutcLaEmyrD2DmuE2W15W osuR/pOEyBaspheCrJAQiFj6SfbEwhW1a+sqKEyJjD+gL0kdcvex15F7tfz3q7szkume GHq5ysQUdydob3KURe38VXi9Eop4fefwHC2KstpZnwUfMwVv+kamfT8is9kjT5AzDLyE vTQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=O8jZnGRn; 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 64-v6si6161158ply.528.2018.03.22.06.17.19; Thu, 22 Mar 2018 06:17: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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=O8jZnGRn; 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 S1755422AbeCVNPM (ORCPT + 99 others); Thu, 22 Mar 2018 09:15:12 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:46783 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752265AbeCVNPH (ORCPT ); Thu, 22 Mar 2018 09:15:07 -0400 Received: by mail-wr0-f193.google.com with SMTP id s10so8636023wra.13; Thu, 22 Mar 2018 06:15:06 -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=OTN5fcY4D05x2aLJsFXenKBgUlvWaaZhkND8ovWTlfE=; b=O8jZnGRneYmdYD4WWD8NY89s3+yEP1/7WkA66JJQcjm2nVflnnPGOLrGkwy+80URcz pNrxd2Tx/nZpMI6eCAe1DXo596lJAxKLBe3ZC0FyoxzMWfDLAh7Jr+sLjEe+Z+DErPSr Z7b6pf1Dzk3TizWthGkxxvMDULKYDWMeo/HBayQ/DJirBM0nVzg3gg1GVLMcb7TfMwhZ zLZU/C+1k/IQzBc+2CMzHsrNoHcc9M08Ov8aygbDgF9CBtOXjcAFvwXVaO0C6hwVNkEz fw8ZBtEyblb293V8f5QEIODOIXTbV0banxjvlM+vuJv6P0TwzkbNP3fW43HoY8wp9kfD nBLQ== 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=OTN5fcY4D05x2aLJsFXenKBgUlvWaaZhkND8ovWTlfE=; b=FiIDt7nhg6szg/EnGE9lwvcJ2Iob/EkkP5Yv0URobY6hIARnGGKUPeDS3SrzsyebHa i7xgAU3AWUe1DgOTFpCxfBPglSRYQW9HKH/K/GkX9qTEpI4GrlZ6hTIttwBzSCYMpEbM gHdXTJ3PxmZb3htBO2LTmuMPBgxlOWpiCHkPN6APxbSrKiaWpBuR7c4iEcibNBkAU55c kPu657cyXFdll+14p5VjdT/hK0rm9UFtdd02fM7UNcZs2Woo4fZOM4D7anqP/gJtPFP8 EmsiH4a3kkh7fSwu8huLvyQEOXud3kdgjwjGZbcd4Vpz6ItgEOkpfBoo6FzG6gNkh6WJ oP+w== X-Gm-Message-State: AElRT7F/6j5ROgg425bpmAcjf761RDds/Oin8V1NLsK4QGbESURtZeYm ARZNCQAhH6ER8QwU8/iDrZDmWtqD X-Received: by 10.223.145.135 with SMTP id 7mr10312025wri.7.1521724505887; Thu, 22 Mar 2018 06:15:05 -0700 (PDT) Received: from cizrna.lan ([109.72.12.73]) by smtp.gmail.com with ESMTPSA id e53sm7412429wrg.34.2018.03.22.06.15.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Mar 2018 06:15:05 -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 v3] usb: dwc2: dwc2_vbus_supply_init: fix error check Date: Thu, 22 Mar 2018 14:14:51 +0100 Message-Id: <20180322131451.12631-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 --- drivers/usb/dwc2/hcd.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index dcfda5eb4cac..863aed20517f 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)) + if (PTR_ERR(hsotg->vbus_supply) == -ENODEV) { + hsotg->vbus_supply = NULL; return 0; + } else if (IS_ERR(hsotg->vbus_supply)) { + hsotg->vbus_supply = NULL; + 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); } /* -- 2.14.3