[U-Boot] [PATCH] cmd: clk: Handle ENODEV from clk_get_rate

Ismael Luceno Cortes ismael.luceno at silicon-gears.com
Thu Feb 21 16:15:09 UTC 2019


Signed-off-by: Ismael Luceno <ismael.luceno at silicon-gears.com>
---
 cmd/clk.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/cmd/clk.c b/cmd/clk.c
index fd4231589c..41f2ae0a50 100644
--- a/cmd/clk.c
+++ b/cmd/clk.c
@@ -26,20 +26,23 @@ int __weak soc_clk_dump(void)
 	uclass_foreach_dev(dev, uc) {
 		memset(&clk, 0, sizeof(clk));
 		ret = device_probe(dev);
-		if (ret) {
-			printf("%-30.30s : ? Hz\n", dev->name);
-			continue;
-		}
+		if (ret)
+			goto noclk;
 
 		ret = clk_request(dev, &clk);
-		if (ret) {
-			printf("%-30.30s : ? Hz\n", dev->name);
-			continue;
-		}
-
-		printf("%-30.30s : %lu Hz\n", dev->name, clk_get_rate(&clk));
+		if (ret)
+			goto noclk;
 
+		ulong rate = clk_get_rate(&clk);
 		clk_free(&clk);
+
+		if (rate == -ENODEV)
+			goto noclk;
+
+		printf("%-30.30s : %lu Hz\n", dev->name, rate);
+		continue;
+	noclk:
+		printf("%-30.30s : ? Hz\n", dev->name);
 	}
 
 	return 0;
-- 
2.19.1


More information about the U-Boot mailing list