* [U-Boot] [PATCH v2] cmd: clk: Handle ENODEV from clk_get_rate
@ 2019-02-22 13:37 Ismael Luceno Cortes
2019-02-22 14:22 ` Matthias Brugger
0 siblings, 1 reply; 2+ messages in thread
From: Ismael Luceno Cortes @ 2019-02-22 13:37 UTC (permalink / raw)
To: u-boot
clk_get_rate may return -ENODEV if the clock isn't valid.
Also, make all the error cases go through a single path.
Signed-off-by: Ismael Luceno <ismael.luceno@silicon-gears.com>
---
CC: Matthias Brugger <mbrugger@suse.com>
Notes:
Changes since v1:
- Added further explanation to the commit message.
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH v2] cmd: clk: Handle ENODEV from clk_get_rate
2019-02-22 13:37 [U-Boot] [PATCH v2] cmd: clk: Handle ENODEV from clk_get_rate Ismael Luceno Cortes
@ 2019-02-22 14:22 ` Matthias Brugger
0 siblings, 0 replies; 2+ messages in thread
From: Matthias Brugger @ 2019-02-22 14:22 UTC (permalink / raw)
To: u-boot
On 22/02/2019 14:37, Ismael Luceno Cortes wrote:
> clk_get_rate may return -ENODEV if the clock isn't valid.
>
> Also, make all the error cases go through a single path.
>
Not sure if that is applied systematically to u-boot, but might be good to
mention the commit you fix with that, as printing -ENODEV as clock frequency is
a bug:
Fixes: ff8eee0330 ("cmd: clk: Add trivial implementation of clock dump for DM")
Other then that:
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
> Signed-off-by: Ismael Luceno <ismael.luceno@silicon-gears.com>
> ---
>
> CC: Matthias Brugger <mbrugger@suse.com>
>
> Notes:
> Changes since v1:
>
> - Added further explanation to the commit message.
>
> 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;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-22 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22 13:37 [U-Boot] [PATCH v2] cmd: clk: Handle ENODEV from clk_get_rate Ismael Luceno Cortes
2019-02-22 14:22 ` Matthias Brugger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.