tools/power/x86/intel-speed-select: Max CPU count calculation when CPU0 is offline
[linux-2.6-microblaze.git] / tools / power / x86 / intel-speed-select / isst-config.c
index b8f4846..c773c6c 100644 (file)
@@ -316,10 +316,24 @@ static void set_max_cpu_num(void)
 {
        FILE *filep;
        unsigned long dummy;
+       int i;
 
        topo_max_cpus = 0;
-       filep = fopen_or_exit(
-               "/sys/devices/system/cpu/cpu0/topology/thread_siblings", "r");
+       for (i = 0; i < 256; ++i) {
+               char path[256];
+
+               snprintf(path, sizeof(path),
+                        "/sys/devices/system/cpu/cpu%d/topology/thread_siblings", i);
+               filep = fopen(path, "r");
+               if (filep)
+                       break;
+       }
+
+       if (!filep) {
+               fprintf(stderr, "Can't get max cpu number\n");
+               exit(0);
+       }
+
        while (fscanf(filep, "%lx,", &dummy) == 1)
                topo_max_cpus += BITMASK_SIZE;
        fclose(filep);