usb: xhci-mtk: get optional clock by devm_clk_get_optional()
authorChunfeng Yun <chunfeng.yun@mediatek.com>
Wed, 17 Apr 2019 08:28:16 +0000 (16:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Apr 2019 12:23:34 +0000 (14:23 +0200)
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 <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-mtk.c

index 60987c787e44f457d918659140a0671ed7a717e8..026fe18972d3e5b30232c2507105ff6f9542ef4d 100644 (file)
@@ -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);
 }