Skip to contentSkip to conversation

cpuidle / ACPI : remove unused definition

PATCH In review Daniel Lezcano 2 participants 9 messages Oct 19, 2012 – Oct 25, 2012 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 cpuidle / ACPI : remove unused definition

The different definitions are not used anywhere in the code.

---
 drivers/acpi/processor_idle.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
drivers/acpi/processor_idle.c +0 -7
index e8086c7..1f536a3 100644
@@ -60,14 +60,7 @@
 #include <asm/processor.h>
 
 #define PREFIX "ACPI: "
-
-#define ACPI_PROCESSOR_CLASS            "processor"
-#define _COMPONENT              ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("processor_idle");
-#define PM_TIMER_TICK_NS		(1000000000ULL/PM_TIMER_FREQUENCY)
-#define C2_OVERHEAD			1	/* 1us */
-#define C3_OVERHEAD			1	/* 1us */
-#define PM_TIMER_TICKS_TO_US(p)		(((p) * 1000)/(PM_TIMER_FREQUENCY/1000))
 
 static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER;
 module_param(max_cstate, uint, 0000);
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 2/5 cpuidle / ACPI : remove pointless headers

These different headers are not needed.

---
 drivers/acpi/processor_idle.c |   13 -------------
 1 files changed, 0 insertions(+), 13 deletions(-)
drivers/acpi/processor_idle.c +0 -13
index 1f536a3..9aac69b 100644
@@ -28,19 +28,10 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
-#include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/init.h>
-#include <linux/cpufreq.h>
-#include <linux/slab.h>
-#include <linux/acpi.h>
 #include <linux/dmi.h>
-#include <linux/moduleparam.h>
-#include <linux/sched.h>	/* need_resched() */
-#include <linux/pm_qos.h>
 #include <linux/clockchips.h>
 #include <linux/cpuidle.h>
-#include <linux/irqflags.h>
 
 /*
  * Include the apic definitions for x86 to have the APIC timer related defines
@@ -52,12 +43,8 @@
 #include <asm/apic.h>
 #endif
 
-#include <asm/io.h>
-#include <asm/uaccess.h>
-
 #include <acpi/acpi_bus.h>
 #include <acpi/processor.h>
-#include <asm/processor.h>
 
 #define PREFIX "ACPI: "
 ACPI_MODULE_NAME("processor_idle");
Signature · 1 line
1.7.5.4
#2 lore raw

Re: [PATCH 2/5] cpuidle / ACPI : remove pointless headers

Quoted 3 lines · Daniel Lezcano

These different headers are not needed.

The kernel doesn't build for me with this patch applied (presumably because the #defines from the previous patch were necessary after all).

Thanks,
Rafael

Quoted 42 lines
---
 drivers/acpi/processor_idle.c |   13 -------------
 1 files changed, 0 insertions(+), 13 deletions(-)
drivers/acpi/processor_idle.c +0 -13
index 1f536a3..9aac69b 100644
@@ -28,19 +28,10 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
-#include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/init.h>
-#include <linux/cpufreq.h>
-#include <linux/slab.h>
-#include <linux/acpi.h>
 #include <linux/dmi.h>
-#include <linux/moduleparam.h>
-#include <linux/sched.h>	/* need_resched() */
-#include <linux/pm_qos.h>
 #include <linux/clockchips.h>
 #include <linux/cpuidle.h>
-#include <linux/irqflags.h>
 
 /*
  * Include the apic definitions for x86 to have the APIC timer related defines
@@ -52,12 +43,8 @@
 #include <asm/apic.h>
 #endif
 
-#include <asm/io.h>
-#include <asm/uaccess.h>
-
 #include <acpi/acpi_bus.h>
 #include <acpi/processor.h>
-#include <asm/processor.h>
 
 #define PREFIX "ACPI: "
 ACPI_MODULE_NAME("processor_idle");
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#3 lore raw

PATCH 3/5 cpuidle / ACPI : pass the cpuidle_device parameter

In reply to Daniel Lezcano

The cpuidle_device is retrieved in the function by using directly the global variable. But the caller of this function already have this device and it can be passed as a parameter. That is one small step to encapsulate the code more.

---
 drivers/acpi/processor_idle.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
drivers/acpi/processor_idle.c +6 -5
index 9aac69b..5c4330f 100644
@@ -974,13 +974,14 @@ struct cpuidle_driver acpi_idle_driver = {
  * device i.e. per-cpu data
  *
  * @pr: the ACPI processor
+ * @dev : the cpuidle device
  */
-static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr)
+static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
+					   struct cpuidle_device *dev)
 {
 	int i, count = CPUIDLE_DRIVER_STATE_START;
 	struct acpi_processor_cx *cx;
 	struct cpuidle_state_usage *state_usage;
-	struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);
 
 	if (!pr->flags.power_setup_done)
 		return -EINVAL;
@@ -1132,7 +1133,7 @@ int acpi_processor_hotplug(struct acpi_processor *pr)
 	cpuidle_disable_device(dev);
 	acpi_processor_get_power_info(pr);
 	if (pr->flags.power) {
-		acpi_processor_setup_cpuidle_cx(pr);
+		acpi_processor_setup_cpuidle_cx(pr, dev);
 		ret = cpuidle_enable_device(dev);
 	}
 	cpuidle_resume_and_unlock();
@@ -1189,8 +1190,8 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
 				continue;
 			acpi_processor_get_power_info(_pr);
 			if (_pr->flags.power) {
-				acpi_processor_setup_cpuidle_cx(_pr);
 				dev = per_cpu(acpi_cpuidle_device, cpu);
+				acpi_processor_setup_cpuidle_cx(_pr, dev);
 				cpuidle_enable_device(dev);
 			}
 		}
@@ -1259,7 +1260,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
 			return -ENOMEM;
 		per_cpu(acpi_cpuidle_device, pr->id) = dev;
 
-		acpi_processor_setup_cpuidle_cx(pr);
+		acpi_processor_setup_cpuidle_cx(pr, dev);
 
 		/* Register per-cpu cpuidle_device. Cpuidle driver
 		 * must already be registered before registering device
Signature · 1 line
1.7.5.4
#4 lore raw

Re: [PATCH 3/5] cpuidle / ACPI : pass the cpuidle_device parameter

Quoted 18 lines · Daniel Lezcano

The cpuidle_device is retrieved in the function by using directly the global variable. But the caller of this function already have this device and it can be passed as a parameter. That is one small step to encapsulate the code more.

---
 drivers/acpi/processor_idle.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
drivers/acpi/processor_idle.c +0 -0
index 9aac69b..5c4330f 100644
@@ -974,13 +974,14 @@ struct cpuidle_driver acpi_idle_driver = {
  * device i.e. per-cpu data
  *
  * @pr: the ACPI processor

drivers/acpi/processor_idle.c struct cpuidle_driver acpi_idle_driver = { · line 983

Quoted 10 lines
drivers/acpi/processor_idle.c +3 -2
+ * @dev : the cpuidle device
  */
-static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr)
+static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
+					   struct cpuidle_device *dev)
 {
 	int i, count = CPUIDLE_DRIVER_STATE_START;
 	struct acpi_processor_cx *cx;
 	struct cpuidle_state_usage *state_usage;
-	struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);

I'm not sure if that's worth it. The value of dev should be in the cache anyway and the way it is makes it clear that this is a per-CPU variable without tracking the call sequence.

I'm not applying this unless you need it for some further changes.

Thanks,
Rafael

Quoted 32 lines
drivers/acpi/processor_idle.c +3 -3
 	if (!pr->flags.power_setup_done)
 		return -EINVAL;
@@ -1132,7 +1133,7 @@ int acpi_processor_hotplug(struct acpi_processor *pr)
 	cpuidle_disable_device(dev);
 	acpi_processor_get_power_info(pr);
 	if (pr->flags.power) {
-		acpi_processor_setup_cpuidle_cx(pr);
+		acpi_processor_setup_cpuidle_cx(pr, dev);
 		ret = cpuidle_enable_device(dev);
 	}
 	cpuidle_resume_and_unlock();
@@ -1189,8 +1190,8 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
 				continue;
 			acpi_processor_get_power_info(_pr);
 			if (_pr->flags.power) {
-				acpi_processor_setup_cpuidle_cx(_pr);
 				dev = per_cpu(acpi_cpuidle_device, cpu);
+				acpi_processor_setup_cpuidle_cx(_pr, dev);
 				cpuidle_enable_device(dev);
 			}
 		}
@@ -1259,7 +1260,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
 			return -ENOMEM;
 		per_cpu(acpi_cpuidle_device, pr->id) = dev;
 
-		acpi_processor_setup_cpuidle_cx(pr);
+		acpi_processor_setup_cpuidle_cx(pr, dev);
 
 		/* Register per-cpu cpuidle_device. Cpuidle driver
 		 * must already be registered before registering device
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#5 lore raw

PATCH 4/5 cpuidle / ACPI : change indentation logic

In reply to Daniel Lezcano

This patch changes the indentation by returning from the function if pr->flags.power is not set. That allows to have the remaining code out of a 'if' section.

Even if the patch does not fix anything, it makes the code a bit more readable for the future cleanups.

---
 drivers/acpi/processor_idle.c |  112 +++++++++++++++++++++--------------------
 1 files changed, 58 insertions(+), 54 deletions(-)
drivers/acpi/processor_idle.c +58 -54
index 5c4330f..f87cb2e 100644
@@ -1164,40 +1164,39 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
 	 * system instead of once per-cpu.  This condition is a hack
 	 * to make the code that updates C-States be called once.
 	 */
+	if (pr->id != 0 || cpuidle_get_driver() != &acpi_idle_driver)
+		return 0;
 
-	if (pr->id == 0 && cpuidle_get_driver() == &acpi_idle_driver) {
-
-		cpuidle_pause_and_lock();
-		/* Protect against cpu-hotplug */
-		get_online_cpus();
+	cpuidle_pause_and_lock();
+	/* Protect against cpu-hotplug */
+	get_online_cpus();
 
-		/* Disable all cpuidle devices */
-		for_each_online_cpu(cpu) {
-			_pr = per_cpu(processors, cpu);
-			if (!_pr || !_pr->flags.power_setup_done)
-				continue;
-			dev = per_cpu(acpi_cpuidle_device, cpu);
-			cpuidle_disable_device(dev);
-		}
+	/* Disable all cpuidle devices */
+	for_each_online_cpu(cpu) {
+		_pr = per_cpu(processors, cpu);
+		if (!_pr || !_pr->flags.power_setup_done)
+			continue;
+		dev = per_cpu(acpi_cpuidle_device, cpu);
+		cpuidle_disable_device(dev);
+	}
 
-		/* Populate Updated C-state information */
-		acpi_processor_setup_cpuidle_states(pr);
+	/* Populate Updated C-state information */
+	acpi_processor_setup_cpuidle_states(pr);
 
-		/* Enable all cpuidle devices */
-		for_each_online_cpu(cpu) {
-			_pr = per_cpu(processors, cpu);
-			if (!_pr || !_pr->flags.power_setup_done)
-				continue;
-			acpi_processor_get_power_info(_pr);
-			if (_pr->flags.power) {
-				dev = per_cpu(acpi_cpuidle_device, cpu);
-				acpi_processor_setup_cpuidle_cx(_pr, dev);
-				cpuidle_enable_device(dev);
-			}
+	/* Enable all cpuidle devices */
+	for_each_online_cpu(cpu) {
+		_pr = per_cpu(processors, cpu);
+		if (!_pr || !_pr->flags.power_setup_done)
+			continue;
+		acpi_processor_get_power_info(_pr);
+		if (_pr->flags.power) {
+			dev = per_cpu(acpi_cpuidle_device, cpu);
+			acpi_processor_setup_cpuidle_cx(_pr, dev);
+			cpuidle_enable_device(dev);
 		}
-		put_online_cpus();
-		cpuidle_resume_and_unlock();
 	}
+	put_online_cpus();
+	cpuidle_resume_and_unlock();
 
 	return 0;
 }
@@ -1229,7 +1228,8 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
 
 	if (acpi_gbl_FADT.cst_control && !nocst) {
 		status =
-		    acpi_os_write_port(acpi_gbl_FADT.smi_command, acpi_gbl_FADT.cst_control, 8);
+		    acpi_os_write_port(acpi_gbl_FADT.smi_command,
+				       acpi_gbl_FADT.cst_control, 8);
 		if (ACPI_FAILURE(status)) {
 			ACPI_EXCEPTION((AE_INFO, status,
 					"Notifying BIOS of _CST ability failed"));
@@ -1239,40 +1239,44 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
 	acpi_processor_get_power_info(pr);
 	pr->flags.power_setup_done = 1;
 
+	if (!pr->flags.power)
+		return 0;
+
 	/*
 	 * Install the idle handler if processor power management is supported.
 	 * Note that we use previously set idle handler will be used on
 	 * platforms that only support C1.
 	 */
-	if (pr->flags.power) {
-		/* Register acpi_idle_driver if not already registered */
-		if (!acpi_processor_registered) {
-			acpi_processor_setup_cpuidle_states(pr);
-			retval = cpuidle_register_driver(&acpi_idle_driver);
-			if (retval)
-				return retval;
-			printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n",
-					acpi_idle_driver.name);
-		}
 
-		dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-		if (!dev)
-			return -ENOMEM;
-		per_cpu(acpi_cpuidle_device, pr->id) = dev;
+	/* Register acpi_idle_driver if not already registered */
+	if (!acpi_processor_registered) {
+		acpi_processor_setup_cpuidle_states(pr);
+		retval = cpuidle_register_driver(&acpi_idle_driver);
+		if (retval)
+			return retval;
+		printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n",
+		       acpi_idle_driver.name);
+	}
 
-		acpi_processor_setup_cpuidle_cx(pr, dev);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return -ENOMEM;
+	per_cpu(acpi_cpuidle_device, pr->id) = dev;
 
-		/* Register per-cpu cpuidle_device. Cpuidle driver
-		 * must already be registered before registering device
-		 */
-		retval = cpuidle_register_device(dev);
-		if (retval) {
-			if (acpi_processor_registered == 0)
-				cpuidle_unregister_driver(&acpi_idle_driver);
-			return retval;
-		}
-		acpi_processor_registered++;
+	acpi_processor_setup_cpuidle_cx(pr, dev);
+
+	/* Register per-cpu cpuidle_device. Cpuidle driver
+	 * must already be registered before registering device
+	 */
+	retval = cpuidle_register_device(dev);
+	if (retval) {
+		if (acpi_processor_registered == 0)
+			cpuidle_unregister_driver(&acpi_idle_driver);
+		return retval;
 	}
+
+	acpi_processor_registered++;
+
 	return 0;
 }
 
Signature · 1 line
1.7.5.4
#6 lore raw

Re: [PATCH 4/5] cpuidle / ACPI : change indentation logic

Quoted 8 lines · Daniel Lezcano

This patch changes the indentation by returning from the function if pr->flags.power is not set. That allows to have the remaining code out of a 'if' section.

Even if the patch does not fix anything, it makes the code a bit more readable for the future cleanups.

Care to rebase so that it applies without [1-3/5]? Or fix those patches and resend the whole series?

I'm assuming that [5/5] will not apply as well without the previous ones.

Thanks,
Rafael

Quoted 157 lines
---
 drivers/acpi/processor_idle.c |  112 +++++++++++++++++++++--------------------
 1 files changed, 58 insertions(+), 54 deletions(-)
drivers/acpi/processor_idle.c +58 -54
index 5c4330f..f87cb2e 100644
@@ -1164,40 +1164,39 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
 	 * system instead of once per-cpu.  This condition is a hack
 	 * to make the code that updates C-States be called once.
 	 */
+	if (pr->id != 0 || cpuidle_get_driver() != &acpi_idle_driver)
+		return 0;
 
-	if (pr->id == 0 && cpuidle_get_driver() == &acpi_idle_driver) {
-
-		cpuidle_pause_and_lock();
-		/* Protect against cpu-hotplug */
-		get_online_cpus();
+	cpuidle_pause_and_lock();
+	/* Protect against cpu-hotplug */
+	get_online_cpus();
 
-		/* Disable all cpuidle devices */
-		for_each_online_cpu(cpu) {
-			_pr = per_cpu(processors, cpu);
-			if (!_pr || !_pr->flags.power_setup_done)
-				continue;
-			dev = per_cpu(acpi_cpuidle_device, cpu);
-			cpuidle_disable_device(dev);
-		}
+	/* Disable all cpuidle devices */
+	for_each_online_cpu(cpu) {
+		_pr = per_cpu(processors, cpu);
+		if (!_pr || !_pr->flags.power_setup_done)
+			continue;
+		dev = per_cpu(acpi_cpuidle_device, cpu);
+		cpuidle_disable_device(dev);
+	}
 
-		/* Populate Updated C-state information */
-		acpi_processor_setup_cpuidle_states(pr);
+	/* Populate Updated C-state information */
+	acpi_processor_setup_cpuidle_states(pr);
 
-		/* Enable all cpuidle devices */
-		for_each_online_cpu(cpu) {
-			_pr = per_cpu(processors, cpu);
-			if (!_pr || !_pr->flags.power_setup_done)
-				continue;
-			acpi_processor_get_power_info(_pr);
-			if (_pr->flags.power) {
-				dev = per_cpu(acpi_cpuidle_device, cpu);
-				acpi_processor_setup_cpuidle_cx(_pr, dev);
-				cpuidle_enable_device(dev);
-			}
+	/* Enable all cpuidle devices */
+	for_each_online_cpu(cpu) {
+		_pr = per_cpu(processors, cpu);
+		if (!_pr || !_pr->flags.power_setup_done)
+			continue;
+		acpi_processor_get_power_info(_pr);
+		if (_pr->flags.power) {
+			dev = per_cpu(acpi_cpuidle_device, cpu);
+			acpi_processor_setup_cpuidle_cx(_pr, dev);
+			cpuidle_enable_device(dev);
 		}
-		put_online_cpus();
-		cpuidle_resume_and_unlock();
 	}
+	put_online_cpus();
+	cpuidle_resume_and_unlock();
 
 	return 0;
 }
@@ -1229,7 +1228,8 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
 
 	if (acpi_gbl_FADT.cst_control && !nocst) {
 		status =
-		    acpi_os_write_port(acpi_gbl_FADT.smi_command, acpi_gbl_FADT.cst_control, 8);
+		    acpi_os_write_port(acpi_gbl_FADT.smi_command,
+				       acpi_gbl_FADT.cst_control, 8);
 		if (ACPI_FAILURE(status)) {
 			ACPI_EXCEPTION((AE_INFO, status,
 					"Notifying BIOS of _CST ability failed"));
@@ -1239,40 +1239,44 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
 	acpi_processor_get_power_info(pr);
 	pr->flags.power_setup_done = 1;
 
+	if (!pr->flags.power)
+		return 0;
+
 	/*
 	 * Install the idle handler if processor power management is supported.
 	 * Note that we use previously set idle handler will be used on
 	 * platforms that only support C1.
 	 */
-	if (pr->flags.power) {
-		/* Register acpi_idle_driver if not already registered */
-		if (!acpi_processor_registered) {
-			acpi_processor_setup_cpuidle_states(pr);
-			retval = cpuidle_register_driver(&acpi_idle_driver);
-			if (retval)
-				return retval;
-			printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n",
-					acpi_idle_driver.name);
-		}
 
-		dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-		if (!dev)
-			return -ENOMEM;
-		per_cpu(acpi_cpuidle_device, pr->id) = dev;
+	/* Register acpi_idle_driver if not already registered */
+	if (!acpi_processor_registered) {
+		acpi_processor_setup_cpuidle_states(pr);
+		retval = cpuidle_register_driver(&acpi_idle_driver);
+		if (retval)
+			return retval;
+		printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n",
+		       acpi_idle_driver.name);
+	}
 
-		acpi_processor_setup_cpuidle_cx(pr, dev);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return -ENOMEM;
+	per_cpu(acpi_cpuidle_device, pr->id) = dev;
 
-		/* Register per-cpu cpuidle_device. Cpuidle driver
-		 * must already be registered before registering device
-		 */
-		retval = cpuidle_register_device(dev);
-		if (retval) {
-			if (acpi_processor_registered == 0)
-				cpuidle_unregister_driver(&acpi_idle_driver);
-			return retval;
-		}
-		acpi_processor_registered++;
+	acpi_processor_setup_cpuidle_cx(pr, dev);
+
+	/* Register per-cpu cpuidle_device. Cpuidle driver
+	 * must already be registered before registering device
+	 */
+	retval = cpuidle_register_device(dev);
+	if (retval) {
+		if (acpi_processor_registered == 0)
+			cpuidle_unregister_driver(&acpi_idle_driver);
+		return retval;
 	}
+
+	acpi_processor_registered++;
+
 	return 0;
 }
 
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#7 lore raw

PATCH 5/5 cpuidle / ACPI : pass the cpuidle driver as parameter

In reply to Daniel Lezcano

Instead of refering to a global variable in the function, let's pass the cpuidle_driver as a parameter to this function.

---
 drivers/acpi/processor_idle.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
drivers/acpi/processor_idle.c +6 -5
index f87cb2e..da38a4b 100644
@@ -1030,12 +1030,12 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
  *
  * @pr: the ACPI processor
  */
-static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
+static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr,
+					       struct cpuidle_driver *drv)
 {
 	int i, count = CPUIDLE_DRIVER_STATE_START;
 	struct acpi_processor_cx *cx;
 	struct cpuidle_state *state;
-	struct cpuidle_driver *drv = &acpi_idle_driver;
 
 	if (!pr->flags.power_setup_done)
 		return -EINVAL;
@@ -1146,6 +1146,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
 	int cpu;
 	struct acpi_processor *_pr;
 	struct cpuidle_device *dev;
+	struct cpuidle_driver *drv = cpuidle_get_driver();
 
 	if (disabled_by_idle_boot_param())
 		return 0;
@@ -1164,7 +1165,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
 	 * system instead of once per-cpu.  This condition is a hack
 	 * to make the code that updates C-States be called once.
 	 */
-	if (pr->id != 0 || cpuidle_get_driver() != &acpi_idle_driver)
+	if (pr->id != 0 || drv != &acpi_idle_driver)
 		return 0;
 
 	cpuidle_pause_and_lock();
@@ -1181,7 +1182,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
 	}
 
 	/* Populate Updated C-state information */
-	acpi_processor_setup_cpuidle_states(pr);
+	acpi_processor_setup_cpuidle_states(pr, drv);
 
 	/* Enable all cpuidle devices */
 	for_each_online_cpu(cpu) {
@@ -1250,7 +1251,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
 
 	/* Register acpi_idle_driver if not already registered */
 	if (!acpi_processor_registered) {
-		acpi_processor_setup_cpuidle_states(pr);
+		acpi_processor_setup_cpuidle_states(pr, &acpi_idle_driver);
 		retval = cpuidle_register_driver(&acpi_idle_driver);
 		if (retval)
 			return retval;
Signature · 1 line
1.7.5.4
#8 lore raw
In reply to Daniel Lezcano
Quoted 3 lines · Daniel Lezcano

The different definitions are not used anywhere in the code.

If you tried to build the kernel with this patch applied, I wonder what .config you used. :-)

It doesn't build for me, because _COMPONENT is actually used.

And in the future, please check the *code* in addition to build-testing.

Thanks,
Rafael

Quoted 24 lines
---
 drivers/acpi/processor_idle.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
drivers/acpi/processor_idle.c +0 -7
index e8086c7..1f536a3 100644
@@ -60,14 +60,7 @@
 #include <asm/processor.h>
 
 #define PREFIX "ACPI: "
-
-#define ACPI_PROCESSOR_CLASS            "processor"
-#define _COMPONENT              ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("processor_idle");
-#define PM_TIMER_TICK_NS		(1000000000ULL/PM_TIMER_FREQUENCY)
-#define C2_OVERHEAD			1	/* 1us */
-#define C3_OVERHEAD			1	/* 1us */
-#define PM_TIMER_TICKS_TO_US(p)		(((p) * 1000)/(PM_TIMER_FREQUENCY/1000))
 
 static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER;
 module_param(max_cstate, uint, 0000);
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.