From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] cmd: clk: Handle ENODEV from clk_get_rate
Date: Mon, 18 Mar 2019 13:02:56 +0100 [thread overview]
Message-ID: <25549545-c9cd-28c8-0c7e-0069bc739b00@gmail.com> (raw)
In-Reply-To: <20190222155242.10276-1-ismael.luceno@silicon-gears.com>
On 2/22/19 4:52 PM, Ismael Luceno Cortes wrote:
> clk_get_rate may return -ENODEV if the clock isn't valid.
>
> Also, make the error cases go through a single path.
>
> Fixes: ff8eee0330a6 ("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>
> ---
>
> CC: Matthias Brugger <mbrugger@suse.com>
>
> 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(-)
>
> 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);
Please declare your variables at the beginning of the function.
Otherwise looks good,
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Send a V2, CC Tom, collect my R-B and this can go into current release
as a fix.
> 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;
>
--
Best regards,
Marek Vasut
prev parent reply other threads:[~2019-03-18 12:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 15:52 [U-Boot] [PATCH v3] cmd: clk: Handle ENODEV from clk_get_rate Ismael Luceno Cortes
2019-03-18 11:58 ` Ismael Luceno Cortes
2019-03-18 12:02 ` Marek Vasut [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25549545-c9cd-28c8-0c7e-0069bc739b00@gmail.com \
--to=marek.vasut@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox