]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
clk: add clk_valid()
authorFabrice Gasnier <fabrice.gasnier@st.com>
Tue, 24 Jul 2018 14:31:28 +0000 (16:31 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 3 Aug 2018 23:53:10 +0000 (19:53 -0400)
Add clk_valid() to check for optional clocks are valid.
Call clk_valid() in test/dm/clk.c and add relevant test routine to
sandbox clk tests.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/include/asm/clk.h
drivers/clk/clk_sandbox_test.c
include/clk.h
test/dm/clk.c

index d85cbadf6ec5d974ded6727486e278257b004346..2b1c49f78309798fbd2885f3753c3f8808952011 100644 (file)
@@ -138,5 +138,13 @@ int sandbox_clk_test_free(struct udevice *dev);
  * @return:    0 if OK, or a negative error code.
  */
 int sandbox_clk_test_release_bulk(struct udevice *dev);
+/**
+ * sandbox_clk_test_valid - Ask the sandbox clock test device to check its
+ * clocks are valid.
+ *
+ * @dev:       The sandbox clock test (client) devivce.
+ * @return:    0 if OK, or a negative error code.
+ */
+int sandbox_clk_test_valid(struct udevice *dev);
 
 #endif
index 8cd4abb84f573eb8bd6efc8c0fa0fe5c69be6482..e8465dbfad1d99fcbf23f0922071253f23955cdd 100644 (file)
@@ -116,6 +116,19 @@ int sandbox_clk_test_release_bulk(struct udevice *dev)
        return clk_release_bulk(&sbct->bulk);
 }
 
+int sandbox_clk_test_valid(struct udevice *dev)
+{
+       struct sandbox_clk_test *sbct = dev_get_priv(dev);
+       int i;
+
+       for (i = 0; i < SANDBOX_CLK_TEST_ID_COUNT; i++) {
+               if (!clk_valid(&sbct->clks[i]))
+                       return -EINVAL;
+       }
+
+       return 0;
+}
+
 static const struct udevice_id sandbox_clk_test_ids[] = {
        { .compatible = "sandbox,clk-test" },
        { }
index 9a357646ff04a893fc046eda5d96a381e103e674..f6d1cc53a1fc9c8b2d31a3cbcee44c5f3293b355 100644 (file)
@@ -294,4 +294,14 @@ int clk_disable_bulk(struct clk_bulk *bulk);
 
 int soc_clk_dump(void);
 
+/**
+ * clk_valid() - check if clk is valid
+ *
+ * @clk:       the clock to check
+ * @return true if valid, or false
+ */
+static inline bool clk_valid(struct clk *clk)
+{
+       return !!clk->dev;
+}
 #endif
index b06906a3ecfa42ac84383f56ecb1baf9e0ab9562..898c034e27bfb1de7dc0b18f190f2dfb354714e4 100644 (file)
@@ -28,6 +28,7 @@ static int dm_test_clk(struct unit_test_state *uts)
        ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test",
                                              &dev_test));
        ut_assertok(sandbox_clk_test_get(dev_test));
+       ut_assertok(sandbox_clk_test_valid(dev_test));
 
        ut_asserteq(1234,
                    sandbox_clk_test_get_rate(dev_test,