Skip to content

Commit ed95347

Browse files
Daniel Lezcanorjwysocki
authored andcommitted
cpuidle: rename function name "__cpuidle_register_driver", v2
The function __cpuidle_register_driver name is confusing because it suggests, conforming to the coding style of the kernel, it registers the driver without taking a lock. Actually, it just fill the different power field states with a decresing value if the power has not been specified. Clarify the purpose of the function by changing its name and move the condition out of this function. This patch fix nothing and does not change the behavior of the function. It is just for the sake of clarity. IHMO, reading in the code: + if (!drv->power_specified) + set_power_states(drv); is much more explicit than: - __cpuidle_register_driver(drv); Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
1 parent a77de28 commit ed95347

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

‎drivers/cpuidle/driver.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ static struct cpuidle_driver *cpuidle_curr_driver;
1818
DEFINE_SPINLOCK(cpuidle_driver_lock);
1919
int cpuidle_driver_refcount;
2020

21-
static void __cpuidle_register_driver(struct cpuidle_driver *drv)
21+
static void set_power_states(struct cpuidle_driver *drv)
2222
{
2323
int i;
24+
2425
/*
2526
* cpuidle driver should set the drv->power_specified bit
2627
* before registering if the driver provides
@@ -35,10 +36,8 @@ static void __cpuidle_register_driver(struct cpuidle_driver *drv)
3536
* an power value of -1. So we use -2, -3, etc, for other
3637
* c-states.
3738
*/
38-
if (!drv->power_specified) {
39-
for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++)
40-
drv->states[i].power_usage = -1 - i;
41-
}
39+
for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++)
40+
drv->states[i].power_usage = -1 - i;
4241
}
4342

4443
/**
@@ -58,8 +57,12 @@ int cpuidle_register_driver(struct cpuidle_driver *drv)
5857
spin_unlock(&cpuidle_driver_lock);
5958
return -EBUSY;
6059
}
61-
__cpuidle_register_driver(drv);
60+
61+
if (!drv->power_specified)
62+
set_power_states(drv);
63+
6264
cpuidle_curr_driver = drv;
65+
6366
spin_unlock(&cpuidle_driver_lock);
6467

6568
return 0;

0 commit comments

Comments
 (0)