Received: by 10.213.65.68 with SMTP id h4csp523513imn; Thu, 22 Mar 2018 02:41:50 -0700 (PDT) X-Google-Smtp-Source: AG47ELtf1OBLeRZ+JZ9MeHzbTrjJd9uQCkQxCTD7sUVx6qpqt7Av+xM7GPYUa7fFnqbj6JH1o8Rx X-Received: by 10.101.75.12 with SMTP id r12mr701326pgq.36.1521711710901; Thu, 22 Mar 2018 02:41:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521711710; cv=none; d=google.com; s=arc-20160816; b=kCrYmQ/uo6BNzH5mmA/ZRtzcz3J13Yf7bLljYkioorskUIwDM/MwcEk9Q7ieA86J9s trK2sQ8kGnMYGKb4njZDTo3UnBXByYSUqsTSM4ELUhl8yfEw6Y2Ub9UvsHcdImFfdg83 SA3K2vIohrV3X6qwDaDkPt0LOOEtLN8n5AcQQ+RM3B78bvQr0n1zbircqnkCnp6vEP41 YEEMMC8AL5ojEdtxu1bMlD8Sj3XUKZ644M2feamrlKQZwUweKlaaoPwiX/LziAjW7Osg CBhz0S9neyQvr9IubShwThUyrxNz45BFrYxo+WDovecRXcUn+q1avTseACCcXNyRj3WT Egxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=KFtokh40tYC4iXpDYYuuJY+bIiHjZ9En/cL9bX+B9Ho=; b=flMYZuEM6RV8RJmQ8R7qey2gSkhvtNIdJVy4Y57rtQhvHLgVNh1uuQb4DhjyEZN3/V PToufPys+7yrld/T50xOPJciOZEeqaajkk52coMeTN7CknXJayzBPsQljU2YLWZUV3DP gQoS0ZmCu1bMnGj2XBT9qIRPXtW8+2l9CeJm96u6aZyKcQpXdOzI8y+vQ3XCb4svii9P ggl2Q8TYzODoBDiupcJ0UwThw7UWOangztpEA7wtNTaPb0BP0zhEo+wIGmJcB/J8EJHC co+2KnmZ7v7vSIhct7jkgsKdRVA7vwhOjxe7IfTtnmqJUAH2ddy/k7znhEuzUPtKux33 mU5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=WyQoGwwG; 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 j9si4532628pfh.200.2018.03.22.02.41.36; Thu, 22 Mar 2018 02:41:50 -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=WyQoGwwG; 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 S1753125AbeCVJkh (ORCPT + 99 others); Thu, 22 Mar 2018 05:40:37 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35210 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752805AbeCVJkd (ORCPT ); Thu, 22 Mar 2018 05:40:33 -0400 Received: by mail-wm0-f67.google.com with SMTP id r82so14860399wme.0; Thu, 22 Mar 2018 02:40:33 -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; bh=KFtokh40tYC4iXpDYYuuJY+bIiHjZ9En/cL9bX+B9Ho=; b=WyQoGwwGW2MjGbPvAu46sDyW/B/mfxdVNFGU9ZGjPH5F84jEBW5x2FVqCIIVujgQ92 9aEGFpddXFCoXKvJOy1TKKElBK3xUpbXBRVnhWl3n6lqkU8nwFuqICtuqU5GxtK+Hp0l Ybv8rTHrhf+pjhqchW2UVnF5D6ohFy83qGe+1uVfDbcD8P/CqAoJ3jyNs44EMD8sPhYA PJ4161/NY+0dcwFt2VXvU1uFsGSDGPGaB9CQ/L4058/CWH4ekTaBdMZWTr+H0hxUQOwj ArCzDX3ABQV1CSWSdHpC2sq5hZenxy654CND0qjKmEJLDDrVfdPGvFgqndbSYw/iDycm iWNw== 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; bh=KFtokh40tYC4iXpDYYuuJY+bIiHjZ9En/cL9bX+B9Ho=; b=bknqKOSYKEG0+Ki7IcUamQN+AhhvvnBG0UEuQ0KV/9PLkGav2HtpXWV+76hTUJuENh q9whCNFcsoGhqO4nWYhajZhwD0bQL0PUl0cFjL026uHTc3jVSfTSZPMfp00E8vMauzOC pV/2pFvpWUX75W7jdClWgn52y1QNbnrfptBeWxFMElayZmUysoTt4ChehsibD/nTGuxc qQ91UN3FiTYX0qf8ceyjEpMJ7CSvBgDMy6rL5fvDT9DCrmCqjowTTOdJHfinvu2gJ4FJ 1dz+Okt89C/FMxJ0PrbNBpf6T/HFD9WMEeS4VBsBGQUyFBZUG1b3PhDaNBzcp1D9xMV4 x1fA== X-Gm-Message-State: AElRT7H3LabeeVWp96bwdto6Zq3fKOqPQ3u6IdruUULLxRudF1XTes07 NmOPxIt/7V8GQVwvITGHICkgs5CE X-Received: by 10.28.133.200 with SMTP id h191mr5420842wmd.39.1521711632190; Thu, 22 Mar 2018 02:40:32 -0700 (PDT) Received: from cizrna.lan ([109.72.12.73]) by smtp.gmail.com with ESMTPSA id w74sm5220631wmd.27.2018.03.22.02.40.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Mar 2018 02:40:31 -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] usb: dwc2: dwc2_vbus_supply_init: fix error check Date: Thu, 22 Mar 2018 10:39:43 +0100 Message-Id: <20180322093943.49717-1-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.14.3 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 --- 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 dcfda5eb4cac..4ae211f65e85 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)) - return 0; + if (IS_ERR(hsotg->vbus_supply)) { + hsotg->vbus_supply = NULL; + if (PTR_ERR(hsotg->vbus_supply) == -ENODEV) + return 0; + else + 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