/* cpuidle_lock mutex must be held before this is called  */
static int __cpuidle_register_device(struct cpuidle_device *dev)
/* cpuidle_lock mutex must be held before this is called  */
static int __cpuidle_register_device(struct cpuidle_device *dev)
{
	int ret;
	struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu);
	if (!sys_dev)
		return -EINVAL;
	if (!try_module_get(cpuidle_curr_driver->owner))
		return -EINVAL;
	init_completion(&dev->kobj_unregister);
	poll_idle_init(dev);
	per_cpu(cpuidle_devices, dev->cpu) = dev;
	list_add(&dev->device_list, &cpuidle_detected_devices);
	if ((ret = cpuidle_add_sysfs(sys_dev))) {
		module_put(cpuidle_curr_driver->owner);
		return ret;
	}
	dev->registered = 1;
	return 0;
}