Skip to content

Commit fc850f3

Browse files
Daniel Lezcanolenb
authored andcommitted
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>
1 parent 3a53396 commit fc850f3

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/cpuidle/cpuidle.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
268268
if (!drv || !cpuidle_curr_governor)
269269
return -EIO;
270270
if (!dev->state_count)
271-
return -EINVAL;
271+
dev->state_count = drv->state_count;
272272

273273
if (dev->registered == 0) {
274274
ret = __cpuidle_register_device(dev);

‎drivers/cpuidle/driver.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static void __cpuidle_register_driver(struct cpuidle_driver *drv)
4747
*/
4848
int cpuidle_register_driver(struct cpuidle_driver *drv)
4949
{
50-
if (!drv)
50+
if (!drv || !drv->state_count)
5151
return -EINVAL;
5252

5353
if (cpuidle_disabled())

0 commit comments

Comments
 (0)