cpuidle: Check if device is already registered

Make __cpuidle_register_device() check whether or not the device has
been registered already and return -EBUSY immediately if that's the
case.

[rjw: Changelog]
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Daniel Lezcano 2013-06-12 15:08:55 +02:00 committed by Rafael J. Wysocki
parent 5df0aa7341
commit c878a52d3c

View File

@ -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;