Skip to contentSkip to conversation

cpuidle: use the driver's state_count as default

PATCH New Daniel Lezcano 2 participants 3 messages Mar 26, 2012 1 message not in the archive CPU idle time management framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 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.

---
 drivers/cpuidle/cpuidle.c |    2 +-
 drivers/cpuidle/driver.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/cpuidle/cpuidle.c +1 -1
index 27f77a4..b8a1faf 100644
@@ -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);
drivers/cpuidle/driver.c +1 -1
index 284d7af..40cd3f3 100644
@@ -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())
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/3 cpuidle: remove useless array definition in cpuidle_structure

In reply to a message not in the archive

All the modules name are ro-data, it is never copied to the array.

eg.

static struct cpuidle_driver intel_idle_driver = {
.name = "intel_idle",
.owner = THIS_MODULE,
};

It safe to assign the pointer of this ro-data to a const char *. By this way we save 12 bytes.

---
 include/linux/cpuidle.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/cpuidle.h +1 -1
index ca4e498..f7f1d90 100644
@@ -120,7 +120,7 @@ static inline int cpuidle_get_last_residency(struct cpuidle_device *dev)
  ****************************/
 
 struct cpuidle_driver {
-	char			name[CPUIDLE_NAME_LEN];
+	const char		*name;
 	struct module 		*owner;
 
 	unsigned int		power_specified:1;
Signature · 1 line
1.7.5.4
#3 lore raw

PATCH 3/3 cpuidle: remove unused 'governor_data' field

In reply to a message not in the archive

As far as I can see, this field is never used in the code.

---
 include/linux/cpuidle.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
include/linux/cpuidle.h +0 -1
index f7f1d90..f3ebbba 100644
@@ -98,7 +98,6 @@ struct cpuidle_device {
 	struct list_head 	device_list;
 	struct kobject		kobj;
 	struct completion	kobj_unregister;
-	void			*governor_data;
 };
 
 DECLARE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
Signature · 1 line
1.7.5.4