Skip to contentSkip to conversation

misc clk-related changes

PATCH Applied Antony Pavlov 2 participants 5 messages Oct 22, 2015

lore
Share & tools
lore
#0 lore raw

cover misc clk-related changes

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(-)
Signature · 7 lines
2.6.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/3 commands: add clk_get_rate command

---
 commands/clk.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
commands/clk.c +55 -0
index 4e7ca60..469d9b3 100644
@@ -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;
Signature · 7 lines
2.6.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/3 clock.h: include <types.h> under guard macro

In reply to Antony Pavlov
---
 include/clock.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
include/clock.h +1 -2
index 7f0f1ec..d65e404 100644
@@ -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)
Signature · 7 lines
2.6.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 3/3 commands: clk_dump: use COMMAND_SUCCESS instead of 0 return code

In reply to Antony Pavlov
---
 commands/clk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
commands/clk.c +1 -1
index 469d9b3..2bfdfdf 100644
@@ -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)
Signature · 7 lines
2.6.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#4 lore raw
In reply to Antony Pavlov
Quoted 8 lines · Antony Pavlov

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

Signature · 9 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox