Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3699745imm; Wed, 5 Sep 2018 04:42:27 -0700 (PDT) X-Google-Smtp-Source: ANB0VdazYLgyWsvVlVHzUWpP3nJFjjzap0P5D8U/n1hrHnowliWuM+cyfyEger8HR++qzZ+kP4qy X-Received: by 2002:a17:902:e5:: with SMTP id a92-v6mr14987526pla.273.1536147746955; Wed, 05 Sep 2018 04:42:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536147746; cv=none; d=google.com; s=arc-20160816; b=b0YRMWMdWPSVvzAUFR0KDg027yMsMHPvEgsEaniW/A9kEjBd3W/+E0cuIjI8hiwdfO FLnfe98+vfE9L23rw8ZCLuPolb1fdLa+iJ1wSnBk5zrQFJ/9EAF7tLTYGPSra48Xf4yr eAb1sF2fV05I97dLFlZ4wDl6ABOFpPeYv+XVglGhvTXRqOjhNSaYGsF061sVxUFUs52S lBoqaBYp6SbeOxX/DqfiqyIbyyFQYRn+6FNABTJ1pW2Qf5ANoY6mFkiHIHqFASrNjedg Mgjb4woFnLaaGpgCpqJu23ivLj/ExlRR0EWor4v73NrOdmw9987/mdIo5/QnVSeCySxC mnQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=RqnMvPp8NDuMuETPm0rKp4XBdycUrvvZ4C1+aHIZjU4=; b=t50Pit2nWWnxBSAxzZeq/vMo2q9oSvcs8FOYpOTSRDSCH0kH0L86187PfElrfWTZVD Ggg2F2PmTWnwXp5cvVSqkix/Z6Nc/X/MUeIi8MlW0dmyGqwJsvOdq0nkEhn3rn6BACSG eG1Ed6kEK2IY2kLDg7e0AFklN6wYkPwRiQVQh86yv4MtYp3xF3RF1pqONlujj2Yv/eTv QCO9A3xDNtZ/xvySBKAxaJIMHymKPeW+J1Ltgd676JQ6ekBC6B/2nzyNRPAH+8v168hd AhRfRoiw2Tg8xqHT/O60HmRTq9N1ZT9xiFtqZNagbmYZeLZg5wWRmu0a3arxlHWCeqG7 iRBg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o9-v6si1694818pgf.331.2018.09.05.04.42.11; Wed, 05 Sep 2018 04:42:26 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727257AbeIEQKW (ORCPT + 99 others); Wed, 5 Sep 2018 12:10:22 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:52635 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbeIEQKW (ORCPT ); Wed, 5 Sep 2018 12:10:22 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w85BXwCh009969; Wed, 5 Sep 2018 13:40:24 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2macxjghs2-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 05 Sep 2018 13:40:24 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A7AA131; Wed, 5 Sep 2018 11:40:23 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8D3932B7E; Wed, 5 Sep 2018 11:40:23 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 5 Sep 2018 13:40:23 +0200 Received: from localhost (10.201.20.5) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 5 Sep 2018 13:40:22 +0200 From: Amelie Delaunay To: Minas Harutyunyan , Felipe Balbi , Greg Kroah-Hartman CC: , , , Fabrice Gasnier , Amelie Delaunay Subject: [PATCH 1/4] usb: dwc2: get optional vbus-supply regulator once Date: Wed, 5 Sep 2018 13:40:02 +0200 Message-ID: <1536147605-26279-2-git-send-email-amelie.delaunay@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536147605-26279-1-git-send-email-amelie.delaunay@st.com> References: <1536147605-26279-1-git-send-email-amelie.delaunay@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.201.20.5] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-05_07:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabrice Gasnier Move devm_regulator_get_optional() call to probe routine. This avoids 'vbus-supply' regulator to be requested lots of times, upon each call to dwc2_vbus_supply_init(), e.g. like with runtime pm. Fixes: 531ef5ebea96 ("usb: dwc2: add support for host mode external vbus supply") Signed-off-by: Fabrice Gasnier Signed-off-by: Amelie Delaunay --- drivers/usb/dwc2/hcd.c | 12 +++--------- drivers/usb/dwc2/platform.c | 8 ++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 2bd6e6b..c205cfa 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -358,16 +358,10 @@ 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)) { - ret = PTR_ERR(hsotg->vbus_supply); - hsotg->vbus_supply = NULL; - return ret == -ENODEV ? 0 : ret; - } + if (hsotg->vbus_supply) + return regulator_enable(hsotg->vbus_supply); - return regulator_enable(hsotg->vbus_supply); + return 0; } static int dwc2_vbus_supply_exit(struct dwc2_hsotg *hsotg) diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 9a53a58..957e342 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -434,6 +434,14 @@ static int dwc2_driver_probe(struct platform_device *dev) if (retval) return retval; + hsotg->vbus_supply = devm_regulator_get_optional(hsotg->dev, "vbus"); + if (IS_ERR(hsotg->vbus_supply)) { + retval = PTR_ERR(hsotg->vbus_supply); + hsotg->vbus_supply = NULL; + if (retval != -ENODEV) + return retval; + } + retval = dwc2_lowlevel_hw_enable(hsotg); if (retval) return retval; -- 2.7.4