Skip to content

Commit

Permalink
[CPUFREQ] Clean up longhaul's speed pretty-printer
Browse files Browse the repository at this point in the history
Getting ready to move to core cpufreq.
- Use snprintf
- Remove unnecessary nesting improving readability.

Signed-off-by: Dave Jones <davej@redhat.com>
  • Loading branch information
Dave Jones committed May 30, 2006
1 parent 8cbe016 commit e2aa873
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions arch/i386/kernel/cpu/cpufreq/longhaul.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e2aa873

Please sign in to comment.