浏览代码

cpuidle: use the driver's state_count as default

If the state_count is not initialized for the device use
the driver's state count as the default. That will prevent
to add it manually in the cpuidle driver initialization
routine and will save us from duplicate line of code.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Len Brown <len.brown@intel.com>
Daniel Lezcano 13 年之前
父节点
当前提交
fc850f39ea
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      drivers/cpuidle/cpuidle.c
  2. 1 1
      drivers/cpuidle/driver.c

+ 1 - 1
drivers/cpuidle/cpuidle.c

@@ -268,7 +268,7 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
 	if (!drv || !cpuidle_curr_governor)
 		return -EIO;
 	if (!dev->state_count)
-		return -EINVAL;
+		dev->state_count = drv->state_count;
 
 	if (dev->registered == 0) {
 		ret = __cpuidle_register_device(dev);

+ 1 - 1
drivers/cpuidle/driver.c

@@ -47,7 +47,7 @@ static void __cpuidle_register_driver(struct cpuidle_driver *drv)
  */
 int cpuidle_register_driver(struct cpuidle_driver *drv)
 {
-	if (!drv)
+	if (!drv || !drv->state_count)
 		return -EINVAL;
 
 	if (cpuidle_disabled())