]> git.karo-electronics.de Git - linux-beck.git/commitdiff
PM / QoS: Simplify PM QoS expansion/merge
authorAlex Frid <afrid@nvidia.com>
Sun, 29 Jan 2012 19:39:25 +0000 (20:39 +0100)
committerRafael J. Wysocki <rjw@sisk.pl>
Sun, 29 Jan 2012 19:39:25 +0000 (20:39 +0100)
 - Replace class ID #define with enumeration
 - Loop through PM QoS objects during initialization (rather than
   initializing them one-by-one)

Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-by: Antti Miettinen <amiettinen@nvidia.com>
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
Reviewed-by: Scott Williams <scwilliams@nvidia.com>
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>
Acked-by: markgross <markgross@thegnar.org>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
include/linux/pm_qos.h
kernel/power/qos.c

index e5bbcbaa6f5700f3bfcb9d14550cce632fcbd53d..5ac91d8e69de32ec09c5ed1c63467ed86f4aec30 100644 (file)
@@ -9,12 +9,16 @@
 #include <linux/miscdevice.h>
 #include <linux/device.h>
 
-#define PM_QOS_RESERVED 0
-#define PM_QOS_CPU_DMA_LATENCY 1
-#define PM_QOS_NETWORK_LATENCY 2
-#define PM_QOS_NETWORK_THROUGHPUT 3
+enum {
+       PM_QOS_RESERVED = 0,
+       PM_QOS_CPU_DMA_LATENCY,
+       PM_QOS_NETWORK_LATENCY,
+       PM_QOS_NETWORK_THROUGHPUT,
+
+       /* insert new class ID */
+       PM_QOS_NUM_CLASSES,
+};
 
-#define PM_QOS_NUM_CLASSES 4
 #define PM_QOS_DEFAULT_VALUE -1
 
 #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE       (2000 * USEC_PER_SEC)
index 995e3bd3417b930902317f9cb0e23dfa4811c36c..d6d6dbd1ecc09f673d987600981c549e5332ad50 100644 (file)
@@ -469,21 +469,18 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
 static int __init pm_qos_power_init(void)
 {
        int ret = 0;
+       int i;
 
-       ret = register_pm_qos_misc(&cpu_dma_pm_qos);
-       if (ret < 0) {
-               printk(KERN_ERR "pm_qos_param: cpu_dma_latency setup failed\n");
-               return ret;
-       }
-       ret = register_pm_qos_misc(&network_lat_pm_qos);
-       if (ret < 0) {
-               printk(KERN_ERR "pm_qos_param: network_latency setup failed\n");
-               return ret;
+       BUILD_BUG_ON(ARRAY_SIZE(pm_qos_array) != PM_QOS_NUM_CLASSES);
+
+       for (i = 1; i < PM_QOS_NUM_CLASSES; i++) {
+               ret = register_pm_qos_misc(pm_qos_array[i]);
+               if (ret < 0) {
+                       printk(KERN_ERR "pm_qos_param: %s setup failed\n",
+                              pm_qos_array[i]->name);
+                       return ret;
+               }
        }
-       ret = register_pm_qos_misc(&network_throughput_pm_qos);
-       if (ret < 0)
-               printk(KERN_ERR
-                       "pm_qos_param: network_throughput setup failed\n");
 
        return ret;
 }