cmd: clk: Handle ENODEV from clk_get_rate
PATCH v3 1/1 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.
for DM")
---
Notes:
Changes since v2:
- Further improved commit message.
Changes since v1:
- Added further explanation to the commit message.
cmd/clk.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
cmd/clk.c +13 -10
@@ -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 ;
Signature · 1 line
2.19.1
PATCH v3 1/1 cmd: clk: Handle ENODEV from clk_get_rate
Quoted 10 lines · Ismael Luceno
clk_get_ratemay return-ENODEVif the clock isn't valid.Also, make the error cases go through a single path.
Fixes ff8eee0330a6 ("cmd: clk: Add trivial implementation of clock dumpfor DM")
Signed-off-by Ismael Luceno <[email protected]>Reviewed-by Matthias Brugger <[email protected]>---
<...>
Ping.
PATCH v3 1/1 cmd: clk: Handle ENODEV from clk_get_rate
In reply to Ismael Luceno CortesQuoted 41 lines · Ismael Luceno Cortes
clk_get_ratemay return-ENODEVif the clock isn't valid.Also, make the error cases go through a single path.
Fixes ff8eee0330a6 ("cmd: clk: Add trivial implementation of clock dumpfor DM")
Signed-off-by Ismael Luceno <[email protected]>Reviewed-by Matthias Brugger <[email protected]>---
CC Matthias Brugger <[email protected]>Notes:
Changes since v2:- Further improved commit message.
Changes since v1:
- Added further explanation to the commit message.
cmd/clk.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)cmd/clk.c +2
-4@@ -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);
cmd/clk.c int __weak soc_clk_dump(void) · line 36
Quoted 10 lines
cmd/clk.c +3
-6-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);
Please declare your variables at the beginning of the function.
Otherwise looks good,
Send a V2, CC Tom, collect my R-B and this can go into current release as a fix.
Quoted 13 lines
cmd/clk.c +8
-0clk_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 ;
Signature · 2 lines
Best regards, Marek Vasut