mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] misc clk-related changes
@ 2015-10-22  5:45 Antony Pavlov
  2015-10-22  5:45 ` [PATCH 1/3] commands: add clk_get_rate command Antony Pavlov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Antony Pavlov @ 2015-10-22  5:45 UTC (permalink / raw)
  To: barebox

Antony Pavlov (3):
  commands: add clk_get_rate command
  clock.h: include <types.h> under guard macro
  commands: clk_dump: use COMMAND_SUCCESS instead of 0 return code

 commands/clk.c  | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 include/clock.h |  3 +--
 2 files changed, 57 insertions(+), 3 deletions(-)

-- 
2.6.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] commands: add clk_get_rate command
  2015-10-22  5:45 [PATCH 0/3] misc clk-related changes Antony Pavlov
@ 2015-10-22  5:45 ` Antony Pavlov
  2015-10-22  5:45 ` [PATCH 2/3] clock.h: include <types.h> under guard macro Antony Pavlov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Antony Pavlov @ 2015-10-22  5:45 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 commands/clk.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/commands/clk.c b/commands/clk.c
index 4e7ca60..469d9b3 100644
--- a/commands/clk.c
+++ b/commands/clk.c
@@ -3,6 +3,8 @@
 #include <getopt.h>
 #include <linux/clk.h>
 #include <linux/err.h>
+#include <environment.h>
+#include <malloc.h>
 
 static int do_clk_enable(int argc, char *argv[])
 {
@@ -77,6 +79,59 @@ BAREBOX_CMD_START(clk_set_rate)
 	BAREBOX_CMD_HELP(cmd_clk_set_rate_help)
 BAREBOX_CMD_END
 
+static int do_clk_get_rate(int argc, char *argv[])
+{
+	int opt;
+	struct clk *clk;
+	unsigned long rate;
+	const char *variable_name = NULL;
+
+	while ((opt = getopt(argc, argv, "s:")) > 0) {
+		switch (opt) {
+		case 's':
+			variable_name = optarg;
+			break;
+		default:
+			return COMMAND_ERROR_USAGE;
+		}
+	}
+
+	if (optind == argc) {
+		fprintf(stderr, "No clock name given\n");
+		return COMMAND_ERROR_USAGE;
+	}
+
+	clk = clk_lookup(argv[optind]);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
+	rate = clk_get_rate(clk);
+
+	if (variable_name) {
+		char *t;
+
+		t = asprintf("%lu", rate);
+		setenv(variable_name, t);
+		free(t);
+	} else
+		printf("%lu\n", rate);
+
+	return COMMAND_SUCCESS;
+}
+
+BAREBOX_CMD_HELP_START(clk_get_rate)
+BAREBOX_CMD_HELP_TEXT("Show clock CLK rate")
+BAREBOX_CMD_HELP_OPT("-s VARNAME",  "set variable VARNAME instead of showing information")
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(clk_get_rate)
+	.cmd		= do_clk_get_rate,
+	BAREBOX_CMD_DESC("get a clocks rate")
+	BAREBOX_CMD_OPTS("[-s VARNAME] CLK")
+	BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
+	BAREBOX_CMD_HELP(cmd_clk_get_rate_help)
+BAREBOX_CMD_END
+
 static int do_clk_dump(int argc, char *argv[])
 {
 	int opt, verbose = 0;
-- 
2.6.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] clock.h: include <types.h> under guard macro
  2015-10-22  5:45 [PATCH 0/3] misc clk-related changes Antony Pavlov
  2015-10-22  5:45 ` [PATCH 1/3] commands: add clk_get_rate command Antony Pavlov
@ 2015-10-22  5:45 ` Antony Pavlov
  2015-10-22  5:45 ` [PATCH 3/3] commands: clk_dump: use COMMAND_SUCCESS instead of 0 return code Antony Pavlov
  2015-10-22  7:34 ` [PATCH 0/3] misc clk-related changes Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Antony Pavlov @ 2015-10-22  5:45 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 include/clock.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/clock.h b/include/clock.h
index 7f0f1ec..d65e404 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -1,8 +1,7 @@
-#include <types.h>
-
 #ifndef CLOCK_H
 #define CLOCK_H
 
+#include <types.h>
 #include <linux/time.h>
 
 #define CLOCKSOURCE_MASK(bits) (uint64_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
-- 
2.6.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] commands: clk_dump: use COMMAND_SUCCESS instead of 0 return code
  2015-10-22  5:45 [PATCH 0/3] misc clk-related changes Antony Pavlov
  2015-10-22  5:45 ` [PATCH 1/3] commands: add clk_get_rate command Antony Pavlov
  2015-10-22  5:45 ` [PATCH 2/3] clock.h: include <types.h> under guard macro Antony Pavlov
@ 2015-10-22  5:45 ` Antony Pavlov
  2015-10-22  7:34 ` [PATCH 0/3] misc clk-related changes Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Antony Pavlov @ 2015-10-22  5:45 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 commands/clk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands/clk.c b/commands/clk.c
index 469d9b3..2bfdfdf 100644
--- a/commands/clk.c
+++ b/commands/clk.c
@@ -149,7 +149,7 @@ static int do_clk_dump(int argc, char *argv[])
 
 	clk_dump(verbose);
 
-	return 0;
+	return COMMAND_SUCCESS;
 }
 
 BAREBOX_CMD_HELP_START(clk_dump)
-- 
2.6.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] misc clk-related changes
  2015-10-22  5:45 [PATCH 0/3] misc clk-related changes Antony Pavlov
                   ` (2 preceding siblings ...)
  2015-10-22  5:45 ` [PATCH 3/3] commands: clk_dump: use COMMAND_SUCCESS instead of 0 return code Antony Pavlov
@ 2015-10-22  7:34 ` Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2015-10-22  7:34 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Thu, Oct 22, 2015 at 08:45:24AM +0300, Antony Pavlov wrote:
> Antony Pavlov (3):
>   commands: add clk_get_rate command
>   clock.h: include <types.h> under guard macro
>   commands: clk_dump: use COMMAND_SUCCESS instead of 0 return code
> 
>  commands/clk.c  | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  include/clock.h |  3 +--
>  2 files changed, 57 insertions(+), 3 deletions(-)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-22  7:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-22  5:45 [PATCH 0/3] misc clk-related changes Antony Pavlov
2015-10-22  5:45 ` [PATCH 1/3] commands: add clk_get_rate command Antony Pavlov
2015-10-22  5:45 ` [PATCH 2/3] clock.h: include <types.h> under guard macro Antony Pavlov
2015-10-22  5:45 ` [PATCH 3/3] commands: clk_dump: use COMMAND_SUCCESS instead of 0 return code Antony Pavlov
2015-10-22  7:34 ` [PATCH 0/3] misc clk-related changes Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox