diff options
author | Shaojie Sun <shaojie.sun@linaro.com> | 2013-08-21 17:27:33 +0800 |
---|---|---|
committer | Shaojie Sun <shaojie.sun@linaro.com> | 2013-08-21 17:38:33 +0800 |
commit | 2489bc70a2e3084cb8d070c9b5b4cc711f67c0e0 (patch) | |
tree | a842bcb5182fa327e77e6bb4d967cb359e6a882b | |
parent | 73e5d97e2444609905e97779fdd95b93ec988056 (diff) |
The clock rates that are reported are incorrect
1. check clock rate is reported by hexadecimal or decimal.
2. clock rate is reported with interger instead of radix point,
for example 1.1GHz must be shown in 1100MHz.
Signed-off-by: Shaojie Sun <shaojie.sun@linaro.com>
-rw-r--r-- | clocks.c | 44 |
1 files changed, 34 insertions, 10 deletions
@@ -78,27 +78,51 @@ static struct clock_info *clock_alloc(void) return ci; } +static inline bool is_hex_clock(uint rate) +{ + return rate%10; +} + static inline const char *clock_rate(uint *rate) { - uint r; + uint r, mod; + bool is_hex = is_hex_clock(*rate); /* GHZ */ - r = *rate >> 30; - if (r) { - *rate = r; - return "GHZ"; - } + if (is_hex) { + r = *rate >> 30; + mod = *rate&((1<<30)-1); + } else { + r = *rate / 1000000000; + mod = *rate % 1000000000; + } + if (r && !mod) { + *rate = r; + return "GHZ"; + } /* MHZ */ - r = *rate >> 20; - if (r) { + if (is_hex) { + r = *rate >> 20; + mod = *rate&((1<<20)-1); + } else { + r = *rate / 1000000; + mod = *rate % 1000000; + } + if (r && !mod) { *rate = r; return "MHZ"; } /* KHZ */ - r = *rate >> 10; - if (r) { + if (is_hex) { + r = *rate >> 10; + mod = *rate&((1<<10)-1); + } else { + r = *rate / 1000; + mod = *rate % 1000; + } + if (r && !mod) { *rate = r; return "KHZ"; } |