aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaojie Sun <shaojie.sun@linaro.com>2013-08-21 17:04:34 +0800
committerShaojie Sun <shaojie.sun@linaro.com>2013-08-21 17:10:29 +0800
commit73e5d97e2444609905e97779fdd95b93ec988056 (patch)
treeda88b9e7f6fb4212730d1664e4e9c31020419ba2
parentc1462e7ea1644e0bf942b265d0a3d4e7ab678fab (diff)
modify clock rate from int to unsigned int.
When clock is large than 2GHz, clock rate will overflow for using int type. So change clock rate type to unsigned int. Then clock rate can reach 4GHz. Signed-off-by: Shaojie Sun <shaojie.sun@linaro.com>
-rw-r--r--clocks.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/clocks.c b/clocks.c
index 95acf57..203411a 100644
--- a/clocks.c
+++ b/clocks.c
@@ -36,9 +36,14 @@
#include "tree.h"
#include "utils.h"
+#ifndef uint
+#define uint unsigned int
+#endif
+
+
struct clock_info {
int flags;
- int rate;
+ uint rate;
int usecount;
bool expanded;
char *prefix;
@@ -73,9 +78,9 @@ static struct clock_info *clock_alloc(void)
return ci;
}
-static inline const char *clock_rate(int *rate)
+static inline const char *clock_rate(uint *rate)
{
- int r;
+ uint r;
/* GHZ */
r = *rate >> 30;
@@ -107,7 +112,7 @@ static int dump_clock_cb(struct tree *t, void *data)
struct clock_info *pclk;
const char *unit;
int ret = 0;
- int rate = clk->rate;
+ uint rate = clk->rate;
if (!t->parent) {
printf("/\n");
@@ -125,7 +130,7 @@ static int dump_clock_cb(struct tree *t, void *data)
unit = clock_rate(&rate);
- printf("%s%s-- %s (flags:0x%x, usecount:%d, rate: %d %s)\n",
+ printf("%s%s-- %s (flags:0x%x, usecount:%d, rate: %u %s)\n",
clk->prefix, !t->next ? "`" : "", t->name, clk->flags,
clk->usecount, rate, unit);
@@ -156,14 +161,14 @@ static inline int read_clock_cb(struct tree *t, void *data)
if(clock_fw == CCF) {
file_read_value(t->path, "clk_flags", "%x", &clk->flags);
- file_read_value(t->path, "clk_rate", "%d", &clk->rate);
+ file_read_value(t->path, "clk_rate", "%u", &clk->rate);
file_read_value(t->path, "clk_prepare_count", "%d", &clk->preparecount);
file_read_value(t->path, "clk_enable_count", "%d", &clk->enablecount);
file_read_value(t->path, "clk_notifier_count", "%d", &clk->notifiercount);
}
else {
file_read_value(t->path, "flags", "%x", &clk->flags);
- file_read_value(t->path, "rate", "%d", &clk->rate);
+ file_read_value(t->path, "rate", "%u", &clk->rate);
file_read_value(t->path, "usecount", "%d", &clk->usecount);
}
@@ -211,7 +216,7 @@ static int is_collapsed(struct tree *t, void *data)
static char *clock_line(struct tree *t)
{
struct clock_info *clk;
- int rate;
+ uint rate;
const char *clkunit;
char *clkrate, *clkname, *clkline = NULL;