]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/cpuidle/driver.c
cpuidle: Do not unset the driver if it is there already
[mirror_ubuntu-bionic-kernel.git] / drivers / cpuidle / driver.c
index dc32f34e68d9379dceee6f04795fe81473a8f9ca..01acd88c419311a21b95108aae509c9d93a0367e 100644 (file)
@@ -62,24 +62,23 @@ static inline void __cpuidle_unset_driver(struct cpuidle_driver *drv)
  * __cpuidle_set_driver - set per CPU driver variables for the given driver.
  * @drv: a valid pointer to a struct cpuidle_driver
  *
- * For each CPU in the driver's cpumask, unset the registered driver per CPU
- * to @drv.
- *
- * Returns 0 on success, -EBUSY if the CPUs have driver(s) already.
+ * Returns 0 on success, -EBUSY if any CPU in the cpumask have a driver
+ * different from drv already.
  */
 static inline int __cpuidle_set_driver(struct cpuidle_driver *drv)
 {
        int cpu;
 
        for_each_cpu(cpu, drv->cpumask) {
+               struct cpuidle_driver *old_drv;
 
-               if (__cpuidle_get_cpu_driver(cpu)) {
-                       __cpuidle_unset_driver(drv);
+               old_drv = __cpuidle_get_cpu_driver(cpu);
+               if (old_drv && old_drv != drv)
                        return -EBUSY;
-               }
+       }
 
+       for_each_cpu(cpu, drv->cpumask)
                per_cpu(cpuidle_drivers, cpu) = drv;
-       }
 
        return 0;
 }