clk: check valid clock by clk_valid()
authorChunfeng Yun <chunfeng.yun@mediatek.com>
Thu, 9 Jan 2020 03:35:06 +0000 (11:35 +0800)
committerTom Rini <trini@konsulko.com>
Thu, 16 Jan 2020 14:39:45 +0000 (09:39 -0500)
Add valid check for clk->dev, it's useful when get optional
clock even when the clk point is valid, but its dev will be
NULL.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
drivers/clk/clk-uclass.c

index 2778b504c0f8754e81c6b7e602148131d6fe37d9..b7e18668cbd9a574d4fb078936039f4b3b07f8d3 100644 (file)
@@ -391,7 +391,7 @@ int clk_free(struct clk *clk)
        const struct clk_ops *ops;
 
        debug("%s(clk=%p)\n", __func__, clk);
-       if (!clk)
+       if (!clk_valid(clk))
                return 0;
        ops = clk_dev_ops(clk->dev);
 
@@ -406,7 +406,7 @@ ulong clk_get_rate(struct clk *clk)
        const struct clk_ops *ops;
 
        debug("%s(clk=%p)\n", __func__, clk);
-       if (!clk)
+       if (!clk_valid(clk))
                return 0;
        ops = clk_dev_ops(clk->dev);
 
@@ -422,7 +422,7 @@ struct clk *clk_get_parent(struct clk *clk)
        struct clk *pclk;
 
        debug("%s(clk=%p)\n", __func__, clk);
-       if (!clk)
+       if (!clk_valid(clk))
                return NULL;
 
        pdev = dev_get_parent(clk->dev);
@@ -439,7 +439,7 @@ long long clk_get_parent_rate(struct clk *clk)
        struct clk *pclk;
 
        debug("%s(clk=%p)\n", __func__, clk);
-       if (!clk)
+       if (!clk_valid(clk))
                return 0;
 
        pclk = clk_get_parent(clk);
@@ -462,7 +462,7 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
        const struct clk_ops *ops;
 
        debug("%s(clk=%p, rate=%lu)\n", __func__, clk, rate);
-       if (!clk)
+       if (!clk_valid(clk))
                return 0;
        ops = clk_dev_ops(clk->dev);
 
@@ -477,7 +477,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
        const struct clk_ops *ops;
 
        debug("%s(clk=%p, parent=%p)\n", __func__, clk, parent);
-       if (!clk)
+       if (!clk_valid(clk))
                return 0;
        ops = clk_dev_ops(clk->dev);
 
@@ -494,7 +494,7 @@ int clk_enable(struct clk *clk)
        int ret;
 
        debug("%s(clk=%p)\n", __func__, clk);
-       if (!clk)
+       if (!clk_valid(clk))
                return 0;
        ops = clk_dev_ops(clk->dev);
 
@@ -554,7 +554,7 @@ int clk_disable(struct clk *clk)
        int ret;
 
        debug("%s(clk=%p)\n", __func__, clk);
-       if (!clk)
+       if (!clk_valid(clk))
                return 0;
        ops = clk_dev_ops(clk->dev);