}
 
 static int no_rounding;
-static void print_speed(unsigned long speed)
-{
-       unsigned long tmp;
-
-       if (no_rounding) {
-               if (speed > 1000000)
-                       printf("%u.%06u GHz", ((unsigned int) speed/1000000),
-                               ((unsigned int) speed%1000000));
-               else if (speed > 1000)
-                       printf("%u.%03u MHz", ((unsigned int) speed/1000),
-                               (unsigned int) (speed%1000));
-               else
-                       printf("%lu kHz", speed);
-       } else {
-               if (speed > 1000000) {
-                       tmp = speed%10000;
-                       if (tmp >= 5000)
-                               speed += 10000;
-                       printf("%u.%02u GHz", ((unsigned int) speed/1000000),
-                               ((unsigned int) (speed%1000000)/10000));
-               } else if (speed > 100000) {
-                       tmp = speed%1000;
-                       if (tmp >= 500)
-                               speed += 1000;
-                       printf("%u MHz", ((unsigned int) speed/1000));
-               } else if (speed > 1000) {
-                       tmp = speed%100;
-                       if (tmp >= 50)
-                               speed += 100;
-                       printf("%u.%01u MHz", ((unsigned int) speed/1000),
-                               ((unsigned int) (speed%1000)/100));
-               }
-       }
-
-       return;
-}
-
 static void print_duration(unsigned long duration)
 {
        unsigned long tmp;
        if (freqs) {
                printf(_("  boost frequency steps: "));
                while (freqs->next) {
-                       print_speed(freqs->frequency);
+                       print_speed(freqs->frequency, no_rounding);
                        printf(", ");
                        freqs = freqs->next;
                }
-               print_speed(freqs->frequency);
+               print_speed(freqs->frequency, no_rounding);
                printf("\n");
                cpufreq_put_available_frequencies(freqs);
        }
                return -EINVAL;
        }
        if (human) {
-               print_speed(freq);
+               print_speed(freq, no_rounding);
        } else
                printf("%lu", freq);
        printf(_(" (asserted by call to kernel)\n"));
                return -EINVAL;
        }
        if (human) {
-               print_speed(freq);
+               print_speed(freq, no_rounding);
        } else
                printf("%lu", freq);
        printf(_(" (asserted by call to hardware)\n"));
 
        if (human) {
                printf(_("  hardware limits: "));
-               print_speed(min);
+               print_speed(min, no_rounding);
                printf(" - ");
-               print_speed(max);
+               print_speed(max, no_rounding);
                printf("\n");
        } else {
                printf("%lu %lu\n", min, max);
                return -EINVAL;
        }
        printf(_("  current policy: frequency should be within "));
-       print_speed(policy->min);
+       print_speed(policy->min, no_rounding);
        printf(_(" and "));
-       print_speed(policy->max);
+       print_speed(policy->max, no_rounding);
 
        printf(".\n                  ");
        printf(_("The governor \"%s\" may decide which speed to use\n"
        struct cpufreq_stats *stats = cpufreq_get_stats(cpu, &total_time);
        while (stats) {
                if (human) {
-                       print_speed(stats->frequency);
+                       print_speed(stats->frequency, no_rounding);
                        printf(":%.2f%%",
                                (100.0 * stats->time_in_state) / total_time);
                } else
        if (freqs) {
                printf(_("  available frequency steps:  "));
                while (freqs->next) {
-                       print_speed(freqs->frequency);
+                       print_speed(freqs->frequency, no_rounding);
                        printf(", ");
                        freqs = freqs->next;
                }
-               print_speed(freqs->frequency);
+               print_speed(freqs->frequency, no_rounding);
                printf("\n");
                cpufreq_put_available_frequencies(freqs);
        }
 
                printf(_("cpupower set operation was not performed on them\n"));
        }
 }
+
+/*
+ * print_speed
+ *
+ * Print the exact CPU frequency with appropriate unit
+ */
+void print_speed(unsigned long speed, int no_rounding)
+{
+       unsigned long tmp;
+
+       if (no_rounding) {
+               if (speed > 1000000)
+                       printf("%u.%06u GHz", ((unsigned int)speed / 1000000),
+                              ((unsigned int)speed % 1000000));
+               else if (speed > 1000)
+                       printf("%u.%03u MHz", ((unsigned int)speed / 1000),
+                              (unsigned int)(speed % 1000));
+               else
+                       printf("%lu kHz", speed);
+       } else {
+               if (speed > 1000000) {
+                       tmp = speed % 10000;
+                       if (tmp >= 5000)
+                               speed += 10000;
+                       printf("%u.%02u GHz", ((unsigned int)speed / 1000000),
+                              ((unsigned int)(speed % 1000000) / 10000));
+               } else if (speed > 100000) {
+                       tmp = speed % 1000;
+                       if (tmp >= 500)
+                               speed += 1000;
+                       printf("%u MHz", ((unsigned int)speed / 1000));
+               } else if (speed > 1000) {
+                       tmp = speed % 100;
+                       if (tmp >= 50)
+                               speed += 100;
+                       printf("%u.%01u MHz", ((unsigned int)speed / 1000),
+                              ((unsigned int)(speed % 1000) / 100));
+               }
+       }
+}