diff mbox

[8/8] cpuidle: Check the device is not already registered

Message ID 1371042535-22630-8-git-send-email-daniel.lezcano@linaro.org
State Accepted
Commit c878a52d3c7cabab5b24460825c24eafd8be7058
Headers show

Commit Message

Daniel Lezcano June 12, 2013, 1:08 p.m. UTC
Add a sanity check for cpuidle_register_device by testing if the device
was already registered or not.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpuidle/cpuidle.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 7c3f625..59b697877 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -400,13 +400,16 @@  static int __cpuidle_register_device(struct cpuidle_device *dev)
  */
 int cpuidle_register_device(struct cpuidle_device *dev)
 {
-	int ret;
+	int ret = -EBUSY;
 
 	if (!dev)
 		return -EINVAL;
 
 	mutex_lock(&cpuidle_lock);
 
+	if (dev->registered)
+		goto out_unlock;
+
 	ret = __cpuidle_device_init(dev);
 	if (ret)
 		goto out_unlock;