]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/acpi/processor_throttling.c
acpi: fix printk format warning
[mirror_ubuntu-artful-kernel.git] / drivers / acpi / processor_throttling.c
index 0bba3a914e865562c51b11703fca695cfd0051a0..0622ace05220b26d02ff6b72c49155a67e71213c 100644 (file)
@@ -71,7 +71,7 @@ static int acpi_processor_update_tsd_coord(void)
         * coordination between all CPUs.
         */
        for_each_possible_cpu(i) {
-               pr = processors[i];
+               pr = per_cpu(processors, i);
                if (!pr)
                        continue;
 
@@ -93,7 +93,7 @@ static int acpi_processor_update_tsd_coord(void)
 
        cpus_clear(covered_cpus);
        for_each_possible_cpu(i) {
-               pr = processors[i];
+               pr = per_cpu(processors, i);
                if (!pr)
                        continue;
 
@@ -119,7 +119,7 @@ static int acpi_processor_update_tsd_coord(void)
                        if (i == j)
                                continue;
 
-                       match_pr = processors[j];
+                       match_pr = per_cpu(processors, j);
                        if (!match_pr)
                                continue;
 
@@ -152,7 +152,7 @@ static int acpi_processor_update_tsd_coord(void)
                        if (i == j)
                                continue;
 
-                       match_pr = processors[j];
+                       match_pr = per_cpu(processors, j);
                        if (!match_pr)
                                continue;
 
@@ -172,7 +172,7 @@ static int acpi_processor_update_tsd_coord(void)
 
 err_ret:
        for_each_possible_cpu(i) {
-               pr = processors[i];
+               pr = per_cpu(processors, i);
                if (!pr)
                        continue;
 
@@ -214,7 +214,7 @@ static int acpi_processor_throttling_notifier(unsigned long event, void *data)
        struct acpi_processor_throttling *p_throttling;
 
        cpu = p_tstate->cpu;
-       pr = processors[cpu];
+       pr = per_cpu(processors, cpu);
        if (!pr) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid pr pointer\n"));
                return 0;
@@ -1035,7 +1035,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
                 * cpus.
                 */
                for_each_cpu_mask(i, online_throttling_cpus) {
-                       match_pr = processors[i];
+                       match_pr = per_cpu(processors, i);
                        /*
                         * If the pointer is invalid, we will report the
                         * error message and continue.
@@ -1232,7 +1232,10 @@ static ssize_t acpi_processor_write_throttling(struct file *file,
        int result = 0;
        struct seq_file *m = file->private_data;
        struct acpi_processor *pr = m->private;
-       char state_string[12] = { '\0' };
+       char state_string[5] = "";
+       char *charp = NULL;
+       size_t state_val = 0;
+       char tmpbuf[5] = "";
 
        if (!pr || (count > sizeof(state_string) - 1))
                return -EINVAL;
@@ -1241,10 +1244,23 @@ static ssize_t acpi_processor_write_throttling(struct file *file,
                return -EFAULT;
 
        state_string[count] = '\0';
+       if ((count > 0) && (state_string[count-1] == '\n'))
+               state_string[count-1] = '\0';
 
-       result = acpi_processor_set_throttling(pr,
-                                              simple_strtoul(state_string,
-                                                             NULL, 0));
+       charp = state_string;
+       if ((state_string[0] == 't') || (state_string[0] == 'T'))
+               charp++;
+
+       state_val = simple_strtoul(charp, NULL, 0);
+       if (state_val >= pr->throttling.state_count)
+               return -EINVAL;
+
+       snprintf(tmpbuf, 5, "%zu", state_val);
+
+       if (strcmp(tmpbuf, charp) != 0)
+               return -EINVAL;
+
+       result = acpi_processor_set_throttling(pr, state_val);
        if (result)
                return result;
 
@@ -1252,6 +1268,7 @@ static ssize_t acpi_processor_write_throttling(struct file *file,
 }
 
 struct file_operations acpi_processor_throttling_fops = {
+       .owner = THIS_MODULE,
        .open = acpi_processor_throttling_open_fs,
        .read = seq_read,
        .write = acpi_processor_write_throttling,