===================================================================
@@ -38,6 +38,7 @@
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#include <acpi/processor.h>
+#include <linux/sort.h>
#define ACPI_PROCESSOR_CLASS "processor"
#define ACPI_PROCESSOR_FILE_PERFORMANCE "performance"
@@ -246,6 +247,25 @@
return result;
}
+static int pss_cmp_func(const void *a, const void *b)
+{
+ struct acpi_processor_px *pxa, *pxb;
+ acpi_integer acpi_value;
+
+ pxa = (struct acpi_processor_px *)a;
+ pxb = (struct acpi_processor_px *)b;
+
+ acpi_value = pxb->core_frequency - pxa->core_frequency;
+ return (int) acpi_value;
+}
+static void pss_swap_func(void *a, void *b, int size)
+{
+ struct acpi_processor_px temp_px;
+
+ memcpy((void *)&temp_px, a, size);
+ memcpy(a, b, size);
+ memcpy(b, (void *)&temp_px, size);
+}
static int acpi_processor_get_performance_states(struct acpi_processor *pr)
{
int result = 0;
@@ -323,7 +343,10 @@
goto end;
}
}
-
+ sort((void *)(pr->performance->states), pr->performance->state_count,
+ sizeof(struct acpi_processor_px),
+ pss_cmp_func,
+ pss_swap_func);
end:
kfree(buffer.pointer);