From patchwork Wed Apr 17 08:28:16 2019 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: 10904915 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06FA2161F for ; Wed, 17 Apr 2019 08:28:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E592E28A57 for ; Wed, 17 Apr 2019 08:28:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9A6028A77; Wed, 17 Apr 2019 08:28:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A2A628A57 for ; Wed, 17 Apr 2019 08:28:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731295AbfDQI2i (ORCPT ); Wed, 17 Apr 2019 04:28:38 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:43504 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726237AbfDQI2h (ORCPT ); Wed, 17 Apr 2019 04:28:37 -0400 X-UUID: a42a5e03da3d432da16e735a1c7ba2a4-20190417 X-UUID: a42a5e03da3d432da16e735a1c7ba2a4-20190417 Received: from mtkcas34.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1789847386; Wed, 17 Apr 2019 16:28:25 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 17 Apr 2019 16:28:23 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 17 Apr 2019 16:28:23 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , Marek Szyprowski , , , , Subject: [PATCH v3 1/6] usb: xhci-mtk: get optional clock by devm_clk_get_optional() Date: Wed, 17 Apr 2019 16:28:16 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use devm_clk_get_optional() to get optional clock instead of optional_clk_get() which uses devm_clk_get() to get clock and checks for -EPROBE_DEFER but not -ENOENT as devm_clk_get_optional() does, in fact, only ignoring -ENOENT will cover more errors, so the replacement doesn't change original purpose. Signed-off-by: Chunfeng Yun --- v3: modify changelog comment v2: no changes --- drivers/usb/host/xhci-mtk.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index 60987c787e44..026fe18972d3 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -206,19 +206,6 @@ static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk) return xhci_mtk_host_enable(mtk); } -/* ignore the error if the clock does not exist */ -static struct clk *optional_clk_get(struct device *dev, const char *id) -{ - struct clk *opt_clk; - - opt_clk = devm_clk_get(dev, id); - /* ignore error number except EPROBE_DEFER */ - if (IS_ERR(opt_clk) && (PTR_ERR(opt_clk) != -EPROBE_DEFER)) - opt_clk = NULL; - - return opt_clk; -} - static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk) { struct device *dev = mtk->dev; @@ -229,15 +216,15 @@ static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk) return PTR_ERR(mtk->sys_clk); } - mtk->ref_clk = optional_clk_get(dev, "ref_ck"); + mtk->ref_clk = devm_clk_get_optional(dev, "ref_ck"); if (IS_ERR(mtk->ref_clk)) return PTR_ERR(mtk->ref_clk); - mtk->mcu_clk = optional_clk_get(dev, "mcu_ck"); + mtk->mcu_clk = devm_clk_get_optional(dev, "mcu_ck"); if (IS_ERR(mtk->mcu_clk)) return PTR_ERR(mtk->mcu_clk); - mtk->dma_clk = optional_clk_get(dev, "dma_ck"); + mtk->dma_clk = devm_clk_get_optional(dev, "dma_ck"); return PTR_ERR_OR_ZERO(mtk->dma_clk); } From patchwork Wed Apr 17 08:28:17 2019 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: 10904929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6DA4F161F for ; Wed, 17 Apr 2019 08:29:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 571A728A57 for ; Wed, 17 Apr 2019 08:29:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 490DC28A89; Wed, 17 Apr 2019 08:29:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1FE528A57 for ; Wed, 17 Apr 2019 08:29:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729519AbfDQI2g (ORCPT ); Wed, 17 Apr 2019 04:28:36 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:5599 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727177AbfDQI2g (ORCPT ); Wed, 17 Apr 2019 04:28:36 -0400 X-UUID: afdf65d152914621a311a6ebc93f2c16-20190417 X-UUID: afdf65d152914621a311a6ebc93f2c16-20190417 Received: from mtkcas35.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 44844121; Wed, 17 Apr 2019 16:28:27 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 17 Apr 2019 16:28:25 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 17 Apr 2019 16:28:24 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , Marek Szyprowski , , , , Subject: [PATCH v3 2/6] usb: host: xhci-plat: get optional clock by devm_clk_get_optional() Date: Wed, 17 Apr 2019 16:28:17 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the driver tries to get optional clock, it ignores all errors except -EPROBE_DEFER, but if only ignores -ENOENT, it will cover some real errors, such as -ENOMEM, so use devm_clk_get_optional() to get optional clock. Cc: Mathias Nyman Signed-off-by: Chunfeng Yun --- v3: modify changelog comment v2: no changes --- drivers/usb/host/xhci-plat.c | 39 +++++++++++++++++------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 0ac4ec975547..998241f5fce3 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -165,8 +165,6 @@ static int xhci_plat_probe(struct platform_device *pdev) struct xhci_hcd *xhci; struct resource *res; struct usb_hcd *hcd; - struct clk *clk; - struct clk *reg_clk; int ret; int irq; @@ -235,31 +233,32 @@ static int xhci_plat_probe(struct platform_device *pdev) hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); + xhci = hcd_to_xhci(hcd); + /* * Not all platforms have clks so it is not an error if the * clock do not exist. */ - reg_clk = devm_clk_get(&pdev->dev, "reg"); - if (!IS_ERR(reg_clk)) { - ret = clk_prepare_enable(reg_clk); - if (ret) - goto put_hcd; - } else if (PTR_ERR(reg_clk) == -EPROBE_DEFER) { - ret = -EPROBE_DEFER; + xhci->reg_clk = devm_clk_get_optional(&pdev->dev, "reg"); + if (IS_ERR(xhci->reg_clk)) { + ret = PTR_ERR(xhci->reg_clk); goto put_hcd; } - clk = devm_clk_get(&pdev->dev, NULL); - if (!IS_ERR(clk)) { - ret = clk_prepare_enable(clk); - if (ret) - goto disable_reg_clk; - } else if (PTR_ERR(clk) == -EPROBE_DEFER) { - ret = -EPROBE_DEFER; + ret = clk_prepare_enable(xhci->reg_clk); + if (ret) + goto put_hcd; + + xhci->clk = devm_clk_get_optional(&pdev->dev, NULL); + if (IS_ERR(xhci->clk)) { + ret = PTR_ERR(xhci->clk); goto disable_reg_clk; } - xhci = hcd_to_xhci(hcd); + ret = clk_prepare_enable(xhci->clk); + if (ret) + goto disable_reg_clk; + priv_match = of_device_get_match_data(&pdev->dev); if (priv_match) { struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); @@ -271,8 +270,6 @@ static int xhci_plat_probe(struct platform_device *pdev) device_wakeup_enable(hcd->self.controller); - xhci->clk = clk; - xhci->reg_clk = reg_clk; xhci->main_hcd = hcd; xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, dev_name(&pdev->dev), hcd); @@ -348,10 +345,10 @@ static int xhci_plat_probe(struct platform_device *pdev) usb_put_hcd(xhci->shared_hcd); disable_clk: - clk_disable_unprepare(clk); + clk_disable_unprepare(xhci->clk); disable_reg_clk: - clk_disable_unprepare(reg_clk); + clk_disable_unprepare(xhci->reg_clk); put_hcd: usb_put_hcd(hcd); From patchwork Wed Apr 17 08:28:18 2019 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: 10904925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84EDC161F for ; Wed, 17 Apr 2019 08:29:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70D0828A57 for ; Wed, 17 Apr 2019 08:29:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6510828A77; Wed, 17 Apr 2019 08:29:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4376A28A57 for ; Wed, 17 Apr 2019 08:29:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731349AbfDQI2n (ORCPT ); Wed, 17 Apr 2019 04:28:43 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:47506 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1731311AbfDQI2l (ORCPT ); Wed, 17 Apr 2019 04:28:41 -0400 X-UUID: dc898f7e83794882b3c0610678ae8681-20190417 X-UUID: dc898f7e83794882b3c0610678ae8681-20190417 Received: from mtkcas35.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 500815480; Wed, 17 Apr 2019 16:28:29 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 17 Apr 2019 16:28:27 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 17 Apr 2019 16:28:26 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , Marek Szyprowski , , , , , Dongjin Kim Subject: [PATCH v3 3/6] usb: misc: usb3503: get optional clock by devm_clk_get_optional() Date: Wed, 17 Apr 2019 16:28:18 +0800 Message-ID: <7c1d28cb44102d96b224157f93f856ef84950a97.1555488276.git.chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the driver tries to get optional clock, it ignores all errors except -EPROBE_DEFER, but if only ignores -ENOENT, it will cover some real errors, such as -ENOMEM, so use devm_clk_get_optional() to get optional clock. And remove unnecessary stack variable clk. Cc: Dongjin Kim Signed-off-by: Chunfeng Yun --- v3: modify changelog comment v2: no changes --- drivers/usb/misc/usb3503.c | 48 ++++++++++++++------------------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index d5141aa79dd4..72f39a9751b5 100644 --- a/drivers/usb/misc/usb3503.c +++ b/drivers/usb/misc/usb3503.c @@ -172,7 +172,6 @@ static int usb3503_probe(struct usb3503 *hub) hub->gpio_reset = pdata->gpio_reset; hub->mode = pdata->initial_mode; } else if (np) { - struct clk *clk; u32 rate = 0; hub->port_off_mask = 0; @@ -198,34 +197,29 @@ static int usb3503_probe(struct usb3503 *hub) } } - clk = devm_clk_get(dev, "refclk"); - if (IS_ERR(clk) && PTR_ERR(clk) != -ENOENT) { + hub->clk = devm_clk_get_optional(dev, "refclk"); + if (IS_ERR(hub->clk)) { dev_err(dev, "unable to request refclk (%ld)\n", - PTR_ERR(clk)); - return PTR_ERR(clk); + PTR_ERR(hub->clk)); + return PTR_ERR(hub->clk); } - if (!IS_ERR(clk)) { - hub->clk = clk; - - if (rate != 0) { - err = clk_set_rate(hub->clk, rate); - if (err) { - dev_err(dev, - "unable to set reference clock rate to %d\n", - (int) rate); - return err; - } - } - - err = clk_prepare_enable(hub->clk); + if (rate != 0) { + err = clk_set_rate(hub->clk, rate); if (err) { dev_err(dev, - "unable to enable reference clock\n"); + "unable to set reference clock rate to %d\n", + (int)rate); return err; } } + err = clk_prepare_enable(hub->clk); + if (err) { + dev_err(dev, "unable to enable reference clock\n"); + return err; + } + property = of_get_property(np, "disabled-ports", &len); if (property && (len / sizeof(u32)) > 0) { int i; @@ -324,8 +318,7 @@ static int usb3503_i2c_remove(struct i2c_client *i2c) struct usb3503 *hub; hub = i2c_get_clientdata(i2c); - if (hub->clk) - clk_disable_unprepare(hub->clk); + clk_disable_unprepare(hub->clk); return 0; } @@ -348,8 +341,7 @@ static int usb3503_platform_remove(struct platform_device *pdev) struct usb3503 *hub; hub = platform_get_drvdata(pdev); - if (hub->clk) - clk_disable_unprepare(hub->clk); + clk_disable_unprepare(hub->clk); return 0; } @@ -358,18 +350,14 @@ static int usb3503_platform_remove(struct platform_device *pdev) static int usb3503_suspend(struct usb3503 *hub) { usb3503_switch_mode(hub, USB3503_MODE_STANDBY); - - if (hub->clk) - clk_disable_unprepare(hub->clk); + clk_disable_unprepare(hub->clk); return 0; } static int usb3503_resume(struct usb3503 *hub) { - if (hub->clk) - clk_prepare_enable(hub->clk); - + clk_prepare_enable(hub->clk); usb3503_switch_mode(hub, hub->mode); return 0; From patchwork Wed Apr 17 08:28:19 2019 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: 10904927 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEE7214DB for ; Wed, 17 Apr 2019 08:29:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB43028A57 for ; Wed, 17 Apr 2019 08:29:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF57528A5F; Wed, 17 Apr 2019 08:29:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72D4C28A95 for ; Wed, 17 Apr 2019 08:29:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731337AbfDQI2m (ORCPT ); Wed, 17 Apr 2019 04:28:42 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:29693 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727177AbfDQI2m (ORCPT ); Wed, 17 Apr 2019 04:28:42 -0400 X-UUID: 9f20facb5542416ea0c07cf66b6475c8-20190417 X-UUID: 9f20facb5542416ea0c07cf66b6475c8-20190417 Received: from mtkcas32.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 848568013; Wed, 17 Apr 2019 16:28:30 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 17 Apr 2019 16:28:29 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 17 Apr 2019 16:28:28 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , Marek Szyprowski , , , , , Minas Harutyunyan Subject: [PATCH v3 4/6] usb: dwc2: get optional clock by devm_clk_get_optional() Date: Wed, 17 Apr 2019 16:28:19 +0800 Message-ID: <39be1493f7760c3c06858046f64d02e7cb86884e.1555488276.git.chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the driver tries to get optional clock, it ignores all errors, but if only ignores -ENOENT, it will cover some real errors, such as -EPROBE_DEFER, so use devm_clk_get_optional() to get optional clock. Cc: Minas Harutyunyan Signed-off-by: Chunfeng Yun Acked-by: Minas Harutyunyan --- v3: modify changelog comment v2: add Acked-by Minas Harutyunyan --- drivers/usb/dwc2/platform.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index c0b64d483552..9aa9682a5cd2 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -284,10 +284,10 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) } /* Clock */ - hsotg->clk = devm_clk_get(hsotg->dev, "otg"); + hsotg->clk = devm_clk_get_optional(hsotg->dev, "otg"); if (IS_ERR(hsotg->clk)) { - hsotg->clk = NULL; - dev_dbg(hsotg->dev, "cannot get otg clock\n"); + dev_err(hsotg->dev, "cannot get otg clock\n"); + return PTR_ERR(hsotg->clk); } /* Regulators */ From patchwork Wed Apr 17 08:28:20 2019 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: 10904917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B258514DB for ; Wed, 17 Apr 2019 08:28:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ECE128A57 for ; Wed, 17 Apr 2019 08:28:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9252928A77; Wed, 17 Apr 2019 08:28:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3763828A57 for ; Wed, 17 Apr 2019 08:28:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731400AbfDQI2s (ORCPT ); Wed, 17 Apr 2019 04:28:48 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:3550 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1731366AbfDQI2s (ORCPT ); Wed, 17 Apr 2019 04:28:48 -0400 X-UUID: 2fb472d24ea9453aadadc8170d0525c6-20190417 X-UUID: 2fb472d24ea9453aadadc8170d0525c6-20190417 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1631658962; Wed, 17 Apr 2019 16:28:38 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 17 Apr 2019 16:28:33 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 17 Apr 2019 16:28:29 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , Marek Szyprowski , , , , , Peter Chen Subject: [PATCH v3 5/6] usb: chipidea: msm: get optional clock by devm_clk_get_optional() Date: Wed, 17 Apr 2019 16:28:20 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the driver tries to get optional clock, it ignores all errors except -EPROBE_DEFER, but if only ignores -ENOENT, it will cover some real errors, such as -ENOMEM, so use devm_clk_get_optional() to get optional clock. Cc: Peter Chen Signed-off-by: Chunfeng Yun Acked-by: Peter Chen --- v3: modify changelog comment v2: add Acked-by Peter Chen --- drivers/usb/chipidea/ci_hdrc_msm.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index 880009987460..b8b3caad889c 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -205,12 +205,9 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) if (IS_ERR(clk)) return PTR_ERR(clk); - ci->fs_clk = clk = devm_clk_get(&pdev->dev, "fs"); - if (IS_ERR(clk)) { - if (PTR_ERR(clk) == -EPROBE_DEFER) - return -EPROBE_DEFER; - ci->fs_clk = NULL; - } + ci->fs_clk = clk = devm_clk_get_optional(&pdev->dev, "fs"); + if (IS_ERR(clk)) + return PTR_ERR(clk); res = platform_get_resource(pdev, IORESOURCE_MEM, 1); ci->base = devm_ioremap_resource(&pdev->dev, res); From patchwork Wed Apr 17 08:28:21 2019 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: 10904921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DA09161F for ; Wed, 17 Apr 2019 08:29:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A10028A57 for ; Wed, 17 Apr 2019 08:29:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DDD428A77; Wed, 17 Apr 2019 08:29:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D16BD28A57 for ; Wed, 17 Apr 2019 08:28:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731375AbfDQI2p (ORCPT ); Wed, 17 Apr 2019 04:28:45 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:61757 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1731363AbfDQI2p (ORCPT ); Wed, 17 Apr 2019 04:28:45 -0400 X-UUID: b551e11c62bc4ef4adf0f522d45f8f81-20190417 X-UUID: b551e11c62bc4ef4adf0f522d45f8f81-20190417 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 589636522; Wed, 17 Apr 2019 16:28:39 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 17 Apr 2019 16:28:37 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 17 Apr 2019 16:28:37 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , Marek Szyprowski , , , , Subject: [PATCH v3 6/6] usb: mtu3: get optional clock by devm_clk_get_optional() Date: Wed, 17 Apr 2019 16:28:21 +0800 Message-ID: <80f2a1a7ff74202ab2d2af74addcf1f8551fff19.1555488276.git.chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use devm_clk_get_optional() to get optional clock instead of optional_clk_get() which uses devm_clk_get() to get clock and checks for -EPROBE_DEFER but not -ENOENT as devm_clk_get_optional() does, in fact, only ignoring -ENOENT will cover more errors, so the replacement doesn't change original purpose. Signed-off-by: Chunfeng Yun Reviewed-by: Matthias Brugger --- v3: 1. modify changelog comment 2. add Reviewed-by Matthias v2: new patch, merged into this series from https://patchwork.kernel.org/patch/10878235/ --- drivers/usb/mtu3/mtu3_plat.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c index e086630e41a9..745a1da5c9c0 100644 --- a/drivers/usb/mtu3/mtu3_plat.c +++ b/drivers/usb/mtu3/mtu3_plat.c @@ -210,19 +210,6 @@ static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb) mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN); } -/* ignore the error if the clock does not exist */ -static struct clk *get_optional_clk(struct device *dev, const char *id) -{ - struct clk *opt_clk; - - opt_clk = devm_clk_get(dev, id); - /* ignore error number except EPROBE_DEFER */ - if (IS_ERR(opt_clk) && (PTR_ERR(opt_clk) != -EPROBE_DEFER)) - opt_clk = NULL; - - return opt_clk; -} - static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) { struct device_node *node = pdev->dev.of_node; @@ -245,15 +232,15 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) return PTR_ERR(ssusb->sys_clk); } - ssusb->ref_clk = get_optional_clk(dev, "ref_ck"); + ssusb->ref_clk = devm_clk_get_optional(dev, "ref_ck"); if (IS_ERR(ssusb->ref_clk)) return PTR_ERR(ssusb->ref_clk); - ssusb->mcu_clk = get_optional_clk(dev, "mcu_ck"); + ssusb->mcu_clk = devm_clk_get_optional(dev, "mcu_ck"); if (IS_ERR(ssusb->mcu_clk)) return PTR_ERR(ssusb->mcu_clk); - ssusb->dma_clk = get_optional_clk(dev, "dma_ck"); + ssusb->dma_clk = devm_clk_get_optional(dev, "dma_ck"); if (IS_ERR(ssusb->dma_clk)) return PTR_ERR(ssusb->dma_clk);