From patchwork Wed May 19 06:39:44 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: 12266439 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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=unavailable 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 B8C11C433B4 for ; Wed, 19 May 2021 06:52:44 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4746C60BBB for ; Wed, 19 May 2021 06:52:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4746C60BBB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=dMf0/sllv6M/HtZJdBFYQO8z6Tii2QDZ96h9QNrlptI=; b=qPQla1GN8bRppt08NuFWXcSqur 9jBpGF9Xq5+SD0AZv+JS658hBrf1PXxlEif+8CVN3Z+O2s9Ki5VqvXxVNZXpq3K4CUSeYih4rW4W/ DeAwMPBBB4EOyvKb5LMI8Yyrkt2zxXHbg/MgiBC5qmZ/iuPmzRx2JQdsdAwFZ+Sso5V4lrPaNcBAu VjDTlLgLFNwyujFDKxFZvvPim2yejyuMlPbENolcgIrr+7P5AT66DZtB/xm0B8KD8xKcY2QqYJMg0 3pJtcn36oT8URzneK2SfSKNr3iKMmrDA1649U40F0K9L72yC/QHHXoErNNSboPpPW88DM9VJxZ3or 7vMZsl8w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljG2X-00335X-KQ; Wed, 19 May 2021 06:50:46 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljG24-0032z4-R8; Wed, 19 May 2021 06:50:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-ID:Content-Description:In-Reply-To:References; bh=Yu9xHamOG4rjVz4F5uxNkjRcn+EEFyADPLMaxANAN50=; b=2/6053q4nCJ0EnDK9VeO5SvSW1 65+sqk9daYo9Bv7GzkXuxMe4PV8ncPxymt12mBlJzxXBj1TKZpIp+F6Qn+Ebo/dRb188EPlGvEr5M DGqCOENaYr/THUuMMh5p/g12dTzuCARQEd8qnpeq6Rt1z2qDN8+7rewybKxHjvuDj3dOKO7piJZev GpQmccvi4EV+CglnEzBo2x9iATfy4WTctAoj6gAVkar3nLl046HVtpuxbdTBdF940eCxRYCUSETGS i6JFonj3JJNzSVkLm+p+cSiuJn/WpkZnfUKsjTXurfaYrciYSdwC0SuupPBg4TA7meAvs0vHnZ+f4 jT6p6law==; Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljG22-00FC49-83; Wed, 19 May 2021 06:50:15 +0000 X-UUID: 752bcd5ba5144bfa86e736daa248efad-20210518 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=Yu9xHamOG4rjVz4F5uxNkjRcn+EEFyADPLMaxANAN50=; b=tiiTYH2gic4Y0E2P8aXq9RooUcTOZxcxNyLFmRsOXxbWFA8/sfY2o9YehToFUQFq4VfEbIMX9PadUK9fa23OhTjR14LEW6C6KRILyhrOhpB6Lku1QCfsQ/BsybubMPlUa2RXe20xQ+qJ9OdCA+jKMRDT0i8x8TXBy/L/tX1Bn7c=; X-UUID: 752bcd5ba5144bfa86e736daa248efad-20210518 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 85069077; Tue, 18 May 2021 23:50:04 -0700 Received: from MTKMBS31N2.mediatek.inc (172.27.4.87) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 18 May 2021 23:39:56 -0700 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:53 +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:52 +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 1/3] usb: common: usb-conn-gpio: fix NULL pointer dereference of charger Date: Wed, 19 May 2021 14:39:44 +0800 Message-ID: <1621406386-18838-1-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty MIME-Version: 1.0 X-TM-SNTS-SMTP: DF0E149C1591C14F9E946A4E74FD92CB5C856779CBF27C32AF978A275F8FE3AC2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_235014_339704_3F82BD62 X-CRM114-Status: GOOD ( 18.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When power on system with OTG cable, IDDIG's interrupt arises before the charger registration, it will cause a NULL pointer dereference, fix the issue by registering the power supply before requesting IDDIG/VBUS irq. Signed-off-by: Chunfeng Yun --- v2: no changes --- drivers/usb/common/usb-conn-gpio.c | 44 ++++++++++++++++++------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c index 6c4e3a19f42c..c9545a4eff66 100644 --- a/drivers/usb/common/usb-conn-gpio.c +++ b/drivers/usb/common/usb-conn-gpio.c @@ -149,14 +149,32 @@ static int usb_charger_get_property(struct power_supply *psy, return 0; } -static int usb_conn_probe(struct platform_device *pdev) +static int usb_conn_psy_register(struct usb_conn_info *info) { - struct device *dev = &pdev->dev; - struct power_supply_desc *desc; - struct usb_conn_info *info; + struct device *dev = info->dev; + struct power_supply_desc *desc = &info->desc; struct power_supply_config cfg = { .of_node = dev->of_node, }; + + desc->name = "usb-charger"; + desc->properties = usb_charger_properties; + desc->num_properties = ARRAY_SIZE(usb_charger_properties); + desc->get_property = usb_charger_get_property; + desc->type = POWER_SUPPLY_TYPE_USB; + cfg.drv_data = info; + + info->charger = devm_power_supply_register(dev, desc, &cfg); + if (IS_ERR(info->charger)) + dev_err(dev, "Unable to register charger\n"); + + return PTR_ERR_OR_ZERO(info->charger); +} + +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; @@ -218,6 +236,10 @@ static int usb_conn_probe(struct platform_device *pdev) return PTR_ERR(info->role_sw); } + ret = usb_conn_psy_register(info); + if (ret) + goto put_role_sw; + if (info->id_gpiod) { info->id_irq = gpiod_to_irq(info->id_gpiod); if (info->id_irq < 0) { @@ -252,20 +274,6 @@ static int usb_conn_probe(struct platform_device *pdev) } } - desc = &info->desc; - desc->name = "usb-charger"; - desc->properties = usb_charger_properties; - desc->num_properties = ARRAY_SIZE(usb_charger_properties); - desc->get_property = usb_charger_get_property; - desc->type = POWER_SUPPLY_TYPE_USB; - cfg.drv_data = info; - - info->charger = devm_power_supply_register(dev, desc, &cfg); - if (IS_ERR(info->charger)) { - dev_err(dev, "Unable to register charger\n"); - return PTR_ERR(info->charger); - } - platform_set_drvdata(pdev, info); /* Perform initial detection */ From patchwork Wed May 19 06:39:45 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: 12266437 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 32738C433B4 for ; Wed, 19 May 2021 06:52:35 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B01626135B for ; Wed, 19 May 2021 06:52:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B01626135B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OQ1snsklyke7Trb6ghaV3uItJGoQKTwU78ljRbheoSE=; b=GEBFYIiTeCvWeHeVmEdkYAQMo BlebNffeEp+SBa29K3Un/Q3tg2spHvM5oc3KvBMIgtv0gzblqAgzFhEICjFB7zJ6zbg5JCxr5SdI2 9WYiJSqsyT4q5A98DWt0GSx4hV9Z0W3lfEcQYiiuw/d0eHQob08+b41FX3InSzE2VRWjcbuOg9NH/ fQYfALTTvAz1xAoWH0PkmGDZLrmvbZKOoJLRLjuDwwY2Bk5iESS09rM1XPPTMlHVi3+KETQh4pRXT pieDwm2nCQ/v2aL44q+4QpO6EL47tpI/w2zBwlgibG/LtGDve2ZLxKKgssFVncEMDS2rCE4ITvXGK BKxFLcCzQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljG2K-00331C-J9; Wed, 19 May 2021 06:50:33 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljG23-0032yl-El; Wed, 19 May 2021 06:50:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=IagDgK6VgohJO/pjzC4dK8hthBHmtse7C3hsDO+Xxy4=; b=ajRgAE2dqh8S5nH77NAs0VnZIY wWbAQL9nmggqCC4lNFt32TcnxSFaLpiDKtLkQzymHwe2J53a+zW2LNqN7AVXqdwcdfMbvFVrdomVG DnqLx/Mes01DYynSd+wt3lotf5EHvJOubfsd2dja7p50GM1zKh7eaBzYQZ4P6f3pwhQSXrTk+I9CK ZA+5dzArgLLyVPKzM/Z7dQez/Lda+wcvfxhjlReYqtArlnEAHc8NBJohPW8iBpoURZkwjLklxrk5S yKmMLdjnqCYjRAV//6QSESmvC5ueu7QC6hykLbYWtUqfDOrxG4MCeW0khSFv+EOEU7qqDO05aIagD PYrx6rkw==; Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljG1y-00FC2y-O8; Wed, 19 May 2021 06:50:14 +0000 X-UUID: c990fcd723274a2fa6bca917237269c2-20210518 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=IagDgK6VgohJO/pjzC4dK8hthBHmtse7C3hsDO+Xxy4=; b=XExFoxgy4ad9I54h/LSyBsH9ufctEdHTv0vVmLCjjDV9BtX67Rro8cKluda4dzUWHvrYGZ1WQLUH89SNcA8k++0o0cpU57fZoPVSe5BOTkBnpyf33WXmmgJ3JO6i3+Vvsv1FqqtEdFaAW38B++24VKpTISP/vSbnjP2ZMVmR9i4=; X-UUID: c990fcd723274a2fa6bca917237269c2-20210518 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1972636932; Tue, 18 May 2021 23:50:04 -0700 Received: from MTKMBS31N2.mediatek.inc (172.27.4.87) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 18 May 2021 23:40:03 -0700 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:54 +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:53 +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 2/3] usb: common: usb-conn-gpio: use dev_err_probe() to print log Date: Wed, 19 May 2021 14:39:45 +0800 Message-ID: <1621406386-18838-2-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: 730A46FE6FA82AE1E7BACAD98544DE91B3AC4C7E7FA83417CA21920A6BC81EF42000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_235010_816668_357F0C99 X-CRM114-Status: GOOD ( 14.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use dev_err_probe() to print debug or error message depending on whether the error value is -DPROBE_DEFER or not. Signed-off-by: Chunfeng Yun --- v2: no changes --- drivers/usb/common/usb-conn-gpio.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c index c9545a4eff66..dfbbc4f51ed6 100644 --- a/drivers/usb/common/usb-conn-gpio.c +++ b/drivers/usb/common/usb-conn-gpio.c @@ -223,18 +223,14 @@ static int usb_conn_probe(struct platform_device *pdev) } if (IS_ERR(info->vbus)) { - if (PTR_ERR(info->vbus) != -EPROBE_DEFER) - dev_err(dev, "failed to get vbus: %ld\n", PTR_ERR(info->vbus)); - return PTR_ERR(info->vbus); + ret = PTR_ERR(info->vbus); + return dev_err_probe(dev, ret, "failed to get vbus :%d\n", ret); } info->role_sw = usb_role_switch_get(dev); - if (IS_ERR(info->role_sw)) { - if (PTR_ERR(info->role_sw) != -EPROBE_DEFER) - dev_err(dev, "failed to get role switch\n"); - - return PTR_ERR(info->role_sw); - } + if (IS_ERR(info->role_sw)) + return dev_err_probe(dev, PTR_ERR(info->role_sw), + "failed to get role switch\n"); ret = usb_conn_psy_register(info); if (ret) 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: 12266435 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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=unavailable 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 60504C433ED for ; Wed, 19 May 2021 06:52:24 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DE151610CD for ; Wed, 19 May 2021 06:52:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE151610CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aUYuKC1ClUPXKAxJ4AH4DD5jjSIPejYWR7dloD684/8=; b=XD2MfgI8PtrI8sk08bc2QsCQ6 +vvabWnjdT03aGZ0Q66rD+nTjQHfs07yVKkSn3zVGH7/JAkDd+Klp9Nx81bq8MMP8KgwNioB2rET5 moZP2TuKwj5+nWm6o9HsHwDBPT+FJ8x2tAKvvUqo+iY9koy0ZAdFuMcVqJg2v4q4BA4hZ+YkzP9tR qAqsry3z2HLRfgJ3ciAyhIcNx831vB/b3X1E2GayYY0OWHov/AIZkGjGZqS5LmAqAU2AOk+T1o3bP pwWAw4RDzaTwSpjqAVa6t2QuOF5CtyWtN448FqwvITLWHFf3aTmuNpo+zsh5Z9QgmkopehQyH4ei8 S4ONVyniA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljG24-0032yo-4L; Wed, 19 May 2021 06:50:16 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljG20-0032yF-Lv; Wed, 19 May 2021 06:50:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=yf3j0i+IsS2HDLwpRWDeNcl69YmoTlrxTWRCwWXxdHE=; b=h4xmblJB0lDJWdG18tCLUNDwtP obW52K7uIXwJPIN4YHjjQlw33o/aHgPL8wESgjer2HyWgU6pLUC1my24gGjJ+mKgNtpsyaYSMuet6 4llBuKxBsxZQUuuwUk76PPbzKudEoQWJ+uNDl7pUmV56WkOAlBYdFrX8GAxe1PTmoldtEx1UZmT6s tpepQniR9RrFlPCGYl2bm3NXEYrssLi78yYcfjjHxZWbYGG3PLOwibGgkGQBR4lfnpP8+heVIyuSg C7WfWt86hwtYr7KKC+M0z/Xp/kznEVyYsgAuO3K3A/fz67KeAuDyGfXgxlOsv+97c0VAO3R0izcJW Ksav9NRQ==; Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljG1v-00FC2y-Gq; Wed, 19 May 2021 06:50:10 +0000 X-UUID: bad0e3c8e67d4441b346f76efdf0abe4-20210518 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=yf3j0i+IsS2HDLwpRWDeNcl69YmoTlrxTWRCwWXxdHE=; b=PImMcEvAOolKyQVSK5zFEiOV09mi83Ji56ecQQmYgbdw7hdnQFkd+fIzqyo/YgeOZGTto43RpSq5/SSx6/NWZaNgFrruYrIdZlC+jGGpXrSdrQ6PTCuGGhl0XUmaHZbjaf6i9JLmVQU9UV95HxIISH04Ya3LNB8n7Mo+ZysyaHg=; X-UUID: bad0e3c8e67d4441b346f76efdf0abe4-20210518 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 588833310; Tue, 18 May 2021 23:50:04 -0700 Received: from MTKMBS31N2.mediatek.inc (172.27.4.87) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 18 May 2021 23:40:04 -0700 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_235008_131855_ABFE4112 X-CRM114-Status: GOOD ( 19.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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);