mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-13 17:28:56 +00:00
[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>
This commit is contained in:
parent
8cbe016905
commit
e2aa8732ac
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user