[PATCH 4.6 061/121] cpuidle: Indicate when a device has been unregistered

From: Greg Kroah-Hartman
Date: Sun Jun 05 2016 - 18:11:13 EST

4.6-stable review patch. If anyone has any objections, please let me know.


From: Dave Gerlach <d-gerlach@xxxxxx>

commit c998c07836f985b24361629dc98506ec7893e7a0 upstream.

Currently the 'registered' member of the cpuidle_device struct is set
to 1 during cpuidle_register_device. In this same function there are
checks to see if the device is already registered to prevent duplicate
calls to register the device, but this value is never set to 0 even on
unregister of the device. Because of this, any attempt to call
cpuidle_register_device after a call to cpuidle_unregister_device will
fail which shouldn't be the case.

To prevent this, set registered to 0 when the device is unregistered.

Fixes: c878a52d3c7c (cpuidle: Check if device is already registered)
Signed-off-by: Dave Gerlach <d-gerlach@xxxxxx>
Acked-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

drivers/cpuidle/cpuidle.c | 2 ++
1 file changed, 2 insertions(+)

--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -433,6 +433,8 @@ static void __cpuidle_unregister_device(
per_cpu(cpuidle_devices, dev->cpu) = NULL;
+ dev->registered = 0;

static void __cpuidle_device_init(struct cpuidle_device *dev)