From patchwork Wed May 19 06:34:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunfeng Yun X-Patchwork-Id: 12266421 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 8B80AC433B4 for ; Wed, 19 May 2021 06:47:14 +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 1109D610CD for ; Wed, 19 May 2021 06:47:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1109D610CD 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=cTdseO6esVBm/tsGUOFBg/Xn4rsFJi1BP7Wo8asBe7o=; b=fJSRiyB4zkJgbbS0TjPPgnjQN7 lpuwf4q6OJr3Ulzhw3zbAVGM3wesZ5zGAPbMHwVN1tEpSb64ZS/ledHJpXmziFJrMz5ikGfPtYMae Pg533doYx6Oi5sFfLAyRSdpE7L6iUPSh/uVKTYl+WzqySBGYa0F66uaRs28KToYscRUYKHKaEOX4k lJlzGt1MAE7dupQHSdWF+wqUheCGfujI/L2lhkZgiwhnssh30F0feHJrdv5SjJXJHxvj+EpLFvwHg EVQ9dCaB3ZESSFd2nO0KnYTsX3GvL08pCdzI8yiHtCkXRof7P0CndeHV/zD8/+Mx+hkPxQBKulRSr KCbCJO/A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljFwi-00322a-Bh; Wed, 19 May 2021 06:44:44 +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 1ljFwd-00321q-Hw; Wed, 19 May 2021 06:44:39 +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=8z++B8XVLCARu24JUi0rTZSYSrWtbXfC5DOMZvKLaJ4=; b=sMYODdC8N4WJPBecB86aUuImyV hkg6CqUoRB8M+9xb+nVby7Q/t0AR9rGoIv0mva8R2hiU4ygleZd8AFi/qMsgdwEhXZIV5bNtnWd3e qA00nqZuEWr5dgT2zzJSLIgc77GtUzV8ttlGFnQzfyrAMWDLW26YMMTUKNa+yBH/FzoDQsZyB0WXu JMcAHf+rZkfvlmKZDCFVWOoXEMPoGu68B4H2o8fv5yASz5pYhsHOGgvLa+BM1kMD/eHxQuvZRtIbw R+21LXyYYiwYWhlG+aTZgCsirrQ19d48v2Blht3G+YHOhUw41QhauMtPKNDzZJfaBpU9tN9YNOQ5V f4yc4wkQ==; Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljFwa-00FBni-VB; Wed, 19 May 2021 06:44:38 +0000 X-UUID: 0fed63a3924e4d57b510175f88a1b383-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=8z++B8XVLCARu24JUi0rTZSYSrWtbXfC5DOMZvKLaJ4=; b=K8jje7riaa8K9W+veRlDF7Ug/SbjQOJ7MOTcJ0a1IzBGYE5B8bs7XtMKI8y/cHkhoc0NnU4tbbWgRuxk6PzZhilhF++cn+siB8UQ+tYUTj8vfS5FbZ5YKesqk10+cuC3Kep+OagVQMKhqjM0Ll+7wZmXRNk37yW4Yo58DS6qeyo=; X-UUID: 0fed63a3924e4d57b510175f88a1b383-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 303085790; Tue, 18 May 2021 23:44:28 -0700 Received: from MTKMBS31N2.mediatek.inc (172.27.4.87) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 18 May 2021 23:34:26 -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:34:17 +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:34:16 +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 1/3] usb: common: usb-conn-gpio: fix NULL pointer dereference of charger Date: Wed, 19 May 2021 14:34:13 +0800 Message-ID: <1621406055-18749-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: 53867D13806BE60B2B21A7355853E7694597F6E76BB9D625F402C7EDB8800A432000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_234437_038428_9924D764 X-CRM114-Status: GOOD ( 18.27 ) 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 --- 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:34:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunfeng Yun X-Patchwork-Id: 12266403 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 6E3DAC433B4 for ; Wed, 19 May 2021 06:41:19 +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 E7FC960FE4 for ; Wed, 19 May 2021 06:41:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7FC960FE4 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=ozkSRw+7e6o+C3TC2RkvC3Iz6vTGbSf319Ko4q0rJME=; b=hdtpu5a0WdXyLR7lQCNAXV/Pd bl+aBc8txHaGdelRxRVRyU9CkkB97+vRatcd0EwrlHAXrUcFsWeyRSdSOLRWNV/f20uO6Z1ZQnfG1 qjjSdK8wuPH5ZdAjc7IRtnJ0vhYSK+oxgYz//6yPswWmJcptAhbmFOTdDGNEjgMgnnaVlQt6xHSd5 xEavPcAmOZB9bKGmuP7V/7y2I+ZMU3GX0WgkaBUFDjlo90Olk5Hah0b90zktvPGBkxsdOJhdTGCsB 1vbX0qpmFoXLQCbJLrjVtgFVQZvCHrJIthKx5MlBT68L7W0Ks3Ulqb7EoG9xNYKtjjYVu7DaD2E7c 5KG8Fz7Tw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljFr9-00314j-8y; Wed, 19 May 2021 06:39:01 +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 1ljFr5-00314J-D2; Wed, 19 May 2021 06:38:55 +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=jYh7zL2Ctfmwpb/jYXcNM13KNhb4dHl5kzVLMnmkvAc=; b=1A0bErRZBI6ZwO8/Vc0ZWnYfAd StSHLNjt9juVfJq5WVf4Wl1WlP7xx7DW+Jic4gbppaFGfLLlTZDWOlOIl3200dlGc+fsQ5CDCfPnH wlKfLsDLX6o+irjHrxK+FPqbXJxXuXO02CUUrwANHo2GrBcjAj0rHjuY2BQd6V0y12OTl8tKYe3+Z mEKCy512B6u9l9NfYv9/76A/TE5poFFfpB48rMhfmNMY+nWTXv73CV/gH2MUO/5SHkovMBkQzFZiq eZYAvx+tMtfOGrtf0K9UiJh+TYBC4RU7Ff2Sj9zeqJ5p98/jZwKIh5LcKHkCLdnBQ/7fElPIOhW8+ o2kyWmOQ==; Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljFr1-00FBYF-0s; Wed, 19 May 2021 06:38:53 +0000 X-UUID: 4342b91610624556843afba3642e5394-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=jYh7zL2Ctfmwpb/jYXcNM13KNhb4dHl5kzVLMnmkvAc=; b=bTTjLbCoaYAAmjHmRSaYmPcZZEMtNZSW0Ad8wzgw0LprNtYXCOsHTqOEXbrRJQQv9LoIMvzaWgGQ92ANlURZUFD2IMvXv1HUtg30Q+KMm5kRNQH/Jnay98/wvnNr3YS99qaNC4J/dI+Y4LfXa3wPGI5BIGWguBfrBWU5M8oYpBc=; X-UUID: 4342b91610624556843afba3642e5394-20210518 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1648345234; Tue, 18 May 2021 23:38:48 -0700 Received: from MTKMBS31N1.mediatek.inc (172.27.4.69) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 18 May 2021 23:34:22 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 19 May 2021 14:34:18 +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:34:18 +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 2/3] usb: common: usb-conn-gpio: use dev_err_probe() to print log Date: Wed, 19 May 2021 14:34:14 +0800 Message-ID: <1621406055-18749-2-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1621406055-18749-1-git-send-email-chunfeng.yun@mediatek.com> References: <1621406055-18749-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 834019DAF55A3585D8007107D5C15830EA56476F357C7886A1BAC557F4CD4F1F2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_233852_570487_8250514A X-CRM114-Status: GOOD ( 15.08 ) 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 --- 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:34:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunfeng Yun X-Patchwork-Id: 12266423 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 034C9C433B4 for ; Wed, 19 May 2021 06:47:28 +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 6D9846108C for ; Wed, 19 May 2021 06:47:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D9846108C 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=VGwGdtyF0cshV8UvTtz1ffB0oVSK3/peyxayxk4O7NM=; b=Hp64cMrCQ3wFyPrrJbejqkQIT OF9qQuf4xH5Wj+vN5t4uZcydi2gmiY8BIYDNr6HM7/xyh1Y9ArT9IxBLn1QVrTy51KflSNKVdyo50 gzJ6GW/uFYa+O5jWuy1UmONrfKe3gSwh7cmC8NviN0E1/lCLeHV1l+LIdXqd3CWXj7S6st92BSXwD bQiOkj7fIVWUc6tEvhWC/I0/vV9/M+JuTG6hka8gmgaCG0l/POtH0SKnxQCClyLgdySb6nvCvj2rc 0Lw5YSeE8Hjxrz2xLhH2lzCbaslHNTQQxIMF+Fxzyw5vSpPApVPxhZ5SfSZP8VANUp5ixwlrMBzid QYWYjrU5g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljFwt-00324T-RC; Wed, 19 May 2021 06:44:55 +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 1ljFwd-00321Y-5L; Wed, 19 May 2021 06:44:39 +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=WptadbQ4jCa57vAznmDmHO9I76lcJbXhSK3aQCB6Amg=; b=A7LKLyvxGHF5xQGOBUVTe9AHmk jeEXZ9uneYw82rX98d8Q0muhi1FFqG4OZ0EjxrUxXSjLQ31vuyvM/eZa4NzkPA2SqU3yMmzM8n1Lf 5SFw1kEvGc9GTNrAnB8hjyg/0Ppw/d+4JAboCMjuCVv/q6oGSqL7s1xi7e+a1q9ETnM85DddXTRRM 5fESzWvP886Oy3Z2iCbet3fP6d2JgBmpqIgXn4YSGO3G4hRV/M1DtBA0L3jB4JwERyMLmTwUtSdwD 7CbBy0vwBr2Jq2heqieCfG/2tU52vOX8WStapyliyCziBWLcb9PL+0cBnjXb3RxN0Kv9gfj0xF3K+ f2xAYhTw==; Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljFwW-00FBni-OX; Wed, 19 May 2021 06:44:36 +0000 X-UUID: d847fcfce6b74aafae93963dd9871398-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=WptadbQ4jCa57vAznmDmHO9I76lcJbXhSK3aQCB6Amg=; b=HJKW92R/LnEm4uCSm7sqXWK1NYy6JRHzKS2DgeghHcCiHQppdXOeP0eFZJGWve+ifEE6BL9T74FeXVNyoGvAi/JP6DCA1KNeiAP34R4e2s7bp1O+N7JllsF8oPtahy0yf1zKgyQ0dBACiZBGhzq09DRpT74PeZ/xI+vELZVjaS8=; X-UUID: d847fcfce6b74aafae93963dd9871398-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 2280508; Tue, 18 May 2021 23:44:28 -0700 Received: from MTKMBS31N2.mediatek.inc (172.27.4.87) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 18 May 2021 23:34:27 -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:34:20 +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:34:19 +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 3/3] Revert "usb: common: usb-conn-gpio: Make VBUS supply optional" Date: Wed, 19 May 2021 14:34:15 +0800 Message-ID: <1621406055-18749-3-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1621406055-18749-1-git-send-email-chunfeng.yun@mediatek.com> References: <1621406055-18749-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: EC0D35134169962D652787113D82E54CFD756EFEAD831699B6318AC78E25A0602000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_234432_842972_D3B6524A X-CRM114-Status: GOOD ( 17.95 ) 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 --- drivers/usb/common/usb-conn-gpio.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c index dfbbc4f51ed6..143bbd8f557a 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); } @@ -205,23 +204,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 +271,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);