mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 05:31:32 +00:00
cmd: clk: Handle ENODEV from clk_get_rate
clk_get_rate may return -ENODEV if the clock isn't valid.
Also, make the error cases go through a single path.
Fixes: ff8eee0330
("cmd: clk: Add trivial implementation of clock dump
for DM")
Signed-off-by: Ismael Luceno <ismael.luceno@silicon-gears.com>
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
This commit is contained in:
parent
4862830b69
commit
80b44fb376
1 changed files with 14 additions and 10 deletions
24
cmd/clk.c
24
cmd/clk.c
|
@ -17,6 +17,7 @@ int __weak soc_clk_dump(void)
|
||||||
struct uclass *uc;
|
struct uclass *uc;
|
||||||
struct clk clk;
|
struct clk clk;
|
||||||
int ret;
|
int ret;
|
||||||
|
ulong rate;
|
||||||
|
|
||||||
/* Device addresses start at 1 */
|
/* Device addresses start at 1 */
|
||||||
ret = uclass_get(UCLASS_CLK, &uc);
|
ret = uclass_get(UCLASS_CLK, &uc);
|
||||||
|
@ -26,20 +27,23 @@ int __weak soc_clk_dump(void)
|
||||||
uclass_foreach_dev(dev, uc) {
|
uclass_foreach_dev(dev, uc) {
|
||||||
memset(&clk, 0, sizeof(clk));
|
memset(&clk, 0, sizeof(clk));
|
||||||
ret = device_probe(dev);
|
ret = device_probe(dev);
|
||||||
if (ret) {
|
if (ret)
|
||||||
printf("%-30.30s : ? Hz\n", dev->name);
|
goto noclk;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = clk_request(dev, &clk);
|
ret = clk_request(dev, &clk);
|
||||||
if (ret) {
|
if (ret)
|
||||||
printf("%-30.30s : ? Hz\n", dev->name);
|
goto noclk;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("%-30.30s : %lu Hz\n", dev->name, clk_get_rate(&clk));
|
|
||||||
|
|
||||||
|
rate = clk_get_rate(&clk);
|
||||||
clk_free(&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;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue