From: Sascha Hauer <s.hauer@pengutronix.de> To: Barebox List <barebox@lists.infradead.org> Subject: [PATCH] Add clk_round_rate command Date: Tue, 15 Jun 2021 15:18:49 +0200 [thread overview] Message-ID: <20210615131849.17418-1-s.hauer@pengutronix.de> (raw) clk_round_rate returns the rate a clk rate will result to if called clk_set_rate on it with that rate. Add a command for it as it comes in handy sometimes for testing and debugging purposes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- commands/clk.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/commands/clk.c b/commands/clk.c index 649a0a7cb2..2e21e9df58 100644 --- a/commands/clk.c +++ b/commands/clk.c @@ -82,6 +82,38 @@ BAREBOX_CMD_START(clk_set_rate) BAREBOX_CMD_COMPLETE(clk_name_complete) BAREBOX_CMD_END +static int do_clk_round_rate(int argc, char *argv[]) +{ + struct clk *clk; + unsigned long rate; + + if (argc != 3) + return COMMAND_ERROR_USAGE; + + clk = clk_lookup(argv[1]); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + rate = simple_strtoul(argv[2], NULL, 0); + + printf("%ld\n", clk_round_rate(clk, rate)); + + return 0; +} + +BAREBOX_CMD_HELP_START(clk_round_rate) +BAREBOX_CMD_HELP_TEXT("Set clock CLK to RATE") +BAREBOX_CMD_HELP_END + +BAREBOX_CMD_START(clk_round_rate) + .cmd = do_clk_round_rate, + BAREBOX_CMD_DESC("set a clocks rate") + BAREBOX_CMD_OPTS("CLK HZ") + BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP) + BAREBOX_CMD_HELP(cmd_clk_round_rate_help) + BAREBOX_CMD_COMPLETE(clk_name_complete) +BAREBOX_CMD_END + static int do_clk_get_rate(int argc, char *argv[]) { int opt; -- 2.29.2 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
reply other threads:[~2021-06-15 19:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210615131849.17418-1-s.hauer@pengutronix.de \ --to=s.hauer@pengutronix.de \ --cc=barebox@lists.infradead.org \ --subject='Re: [PATCH] Add clk_round_rate command' \ /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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox