From patchwork Mon Mar 26 09:00:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 132402 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp3580200ljb; Mon, 26 Mar 2018 02:01:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELu4XUJFZWbT6zIYW/GDn299tBBce1ohgQTtUrAsiV0Pv7AK7FknZbGX/W1SWjRZsuEtFgN5 X-Received: by 10.99.109.75 with SMTP id i72mr22425570pgc.403.1522054865806; Mon, 26 Mar 2018 02:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522054865; cv=none; d=google.com; s=arc-20160816; b=C5DvC4uEtW9/i2uSQA5vC8Try4PKTKbW2J5gnBKydBS6I2xLdozE7HWkTrJLMZsSTn CcRspsCzNN+BqFlmTsZzzyLUWDvR6WaHJZ1dgAY6S2ueMalTydXwUjyvlAOVXvXtFm3U UyjagVx0F39wzvgW1Qrjk9op0kreEAHPI1BTinqiPMAC5DGg9R6xEU7B+ypubwM+Tq5q USM7OtXCIPLR0SrYMAtHsColOVlMxA/KT3jqFUl+150QJeHu/lgnRMt+7A8Ur15AlqPr ofgCondp0MuHDXcMSt7CIpMwWps5m8DoDphvCribxzOON2q9rIf+sGv9+ltfpYiGDLIz jMbw== 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=WfzNzJdIIxuxKX4LLDB4NcwhSvXgkE15cGF1nOzcM8Q=; b=o5qVZi/iIzDfcDW6dBK2ODwAsWq1AnztMluKznTyyktq4JIDzvVnjQKxlRGN4hO9Fl snqA/A9WPwD8Ev35hzUd+37LJUzakm5YToakU0CI8uCUuaj2FZzfTBxyZ1zIAHlBreMD wwGI9k/AJJJ76kq2S2Vp2CyqrK2k0d5uOe/zxsqCOuKTVeQYUxAKE1b9ToG8/S4rPi9T 8B4pyyEC7Yd09LpMMcTgsv39QmziQ+G9IQgb+vldHWMHUE688RJ3zQTOU1Emh4jUCfW1 IszQhMP398bEX4rA4GqWB0y+oABQsHOuc+dg6hKmmTh1/688Jvq9dJ22GUVJzoHSPlWD t/4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=jr4BwuHe; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-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 1-v6si7473585plx.463.2018.03.26.02.01.05; Mon, 26 Mar 2018 02:01:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=jr4BwuHe; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-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 S1751752AbeCZJBD (ORCPT + 3 others); Mon, 26 Mar 2018 05:01:03 -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 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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(-) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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); } /*