From patchwork Wed May 19 06:39:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 12266411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AB09C433B4 for ; Wed, 19 May 2021 06:40:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DFD66135C for ; Wed, 19 May 2021 06:40:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231737AbhESGlZ (ORCPT ); Wed, 19 May 2021 02:41:25 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:4979 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S231354AbhESGlY (ORCPT ); Wed, 19 May 2021 02:41:24 -0400 X-UUID: 05b2b5c7794149e08e460b4625d20830-20210519 X-UUID: 05b2b5c7794149e08e460b4625d20830-20210519 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1879630647; Wed, 19 May 2021 14:39:59 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 19 May 2021 14:39:55 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 19 May 2021 14:39:54 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Thierry Reding CC: Liam Girdwood , Mark Brown , Matthias Brugger , Chunfeng Yun , Paul Cercueil , Lee Jones , , , , Subject: [PATCH v2 3/3] Revert "usb: common: usb-conn-gpio: Make VBUS supply optional" Date: Wed, 19 May 2021 14:39:46 +0800 Message-ID: <1621406386-18838-3-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1621406386-18838-1-git-send-email-chunfeng.yun@mediatek.com> References: <1621406386-18838-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 164287284D5D51868550B33931481A8944D3E274C0BECC5DD68242334BA10D312000:8 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Vbus is already an optional supply, if the vbus-supply is not provided in DTS, will use a dummy regulator, the warning log is as below: "supply vbus not found, using dummy regulator" This reverts commit 4ddf1ac79e5f082451cd549283d2eb7559ab6ca9. Cc: Thierry Reding Signed-off-by: Chunfeng Yun --- v2: remove unused variable "need_vbus" --- drivers/usb/common/usb-conn-gpio.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c index dfbbc4f51ed6..65d89140cd19 100644 --- a/drivers/usb/common/usb-conn-gpio.c +++ b/drivers/usb/common/usb-conn-gpio.c @@ -91,14 +91,14 @@ static void usb_conn_detect_cable(struct work_struct *work) return; } - if (info->last_role == USB_ROLE_HOST && info->vbus) + if (info->last_role == USB_ROLE_HOST) regulator_disable(info->vbus); ret = usb_role_switch_set_role(info->role_sw, role); if (ret) dev_err(info->dev, "failed to set role: %d\n", ret); - if (role == USB_ROLE_HOST && info->vbus) { + if (role == USB_ROLE_HOST) { ret = regulator_enable(info->vbus); if (ret) dev_err(info->dev, "enable vbus regulator failed\n"); @@ -106,9 +106,8 @@ static void usb_conn_detect_cable(struct work_struct *work) info->last_role = role; - if (info->vbus) - dev_dbg(info->dev, "vbus regulator is %s\n", - regulator_is_enabled(info->vbus) ? "enabled" : "disabled"); + dev_dbg(info->dev, "vbus regulator is %s\n", + regulator_is_enabled(info->vbus) ? "enabled" : "disabled"); power_supply_changed(info->charger); } @@ -175,7 +174,6 @@ static int usb_conn_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct usb_conn_info *info; - bool need_vbus = true; int ret = 0; info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); @@ -205,23 +203,7 @@ static int usb_conn_probe(struct platform_device *pdev) INIT_DELAYED_WORK(&info->dw_det, usb_conn_detect_cable); - /* - * If the USB connector is a child of a USB port and that port already provides the VBUS - * supply, there's no need for the USB connector to provide it again. - */ - if (dev->parent && dev->parent->of_node) { - if (of_find_property(dev->parent->of_node, "vbus-supply", NULL)) - need_vbus = false; - } - - if (!need_vbus) { - info->vbus = devm_regulator_get_optional(dev, "vbus"); - if (PTR_ERR(info->vbus) == -ENODEV) - info->vbus = NULL; - } else { - info->vbus = devm_regulator_get(dev, "vbus"); - } - + info->vbus = devm_regulator_get(dev, "vbus"); if (IS_ERR(info->vbus)) { ret = PTR_ERR(info->vbus); return dev_err_probe(dev, ret, "failed to get vbus :%d\n", ret); @@ -288,7 +270,7 @@ static int usb_conn_remove(struct platform_device *pdev) cancel_delayed_work_sync(&info->dw_det); - if (info->last_role == USB_ROLE_HOST && info->vbus) + if (info->last_role == USB_ROLE_HOST) regulator_disable(info->vbus); usb_role_switch_put(info->role_sw);