diff options
author | Dave Jones <davej@redhat.com> | 2006-05-30 17:37:15 -0400 |
---|---|---|
committer | Dave Jones <davej@redhat.com> | 2006-05-30 17:37:15 -0400 |
commit | e2aa8732ac11570acddf326874a34ab684752e34 (patch) | |
tree | 968a22e50a92b280ada993d5e92c6f2d3d120b57 /arch/i386/kernel/cpu/cpufreq | |
parent | 8cbe0169053ffa185ad349088eb0901946c14a09 (diff) |
[CPUFREQ] Clean up longhaul's speed pretty-printer
Getting ready to move to core cpufreq.
- Use snprintf
- Remove unnecessary nesting improving readability.
Signed-off-by: Dave Jones <davej@redhat.com>
Diffstat (limited to 'arch/i386/kernel/cpu/cpufreq')
-rw-r--r-- | arch/i386/kernel/cpu/cpufreq/longhaul.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c index 8ef38544453..31600576b7e 100644 --- a/arch/i386/kernel/cpu/cpufreq/longhaul.c +++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c @@ -77,13 +77,17 @@ static char speedbuffer[8]; static char *print_speed(int speed) { - if (speed > 1000) { - if (speed%1000 == 0) - sprintf (speedbuffer, "%dGHz", speed/1000); - else - sprintf (speedbuffer, "%d.%dGHz", speed/1000, (speed%1000)/100); - } else - sprintf (speedbuffer, "%dMHz", speed); + if (speed < 1000) { + snprintf(speedbuffer, sizeof(speedbuffer),"%dMHz", speed); + return speedbuffer; + } + + if (speed%1000 == 0) + snprintf(speedbuffer, sizeof(speedbuffer), + "%dGHz", speed/1000); + else + snprintf(speedbuffer, sizeof(speedbuffer), + "%d.%dGHz", speed/1000, (speed%1000)/100); return speedbuffer; } |