ARM: sunxi_defconfig: enable CONFIG_REGULATOR
[cascardo/linux.git] / kernel / cpu.c
index 81e2a38..356450f 100644 (file)
@@ -79,6 +79,8 @@ static struct {
 
 /* Lockdep annotations for get/put_online_cpus() and cpu_hotplug_begin/end() */
 #define cpuhp_lock_acquire_read() lock_map_acquire_read(&cpu_hotplug.dep_map)
+#define cpuhp_lock_acquire_tryread() \
+                                 lock_map_acquire_tryread(&cpu_hotplug.dep_map)
 #define cpuhp_lock_acquire()      lock_map_acquire(&cpu_hotplug.dep_map)
 #define cpuhp_lock_release()      lock_map_release(&cpu_hotplug.dep_map)
 
@@ -91,10 +93,22 @@ void get_online_cpus(void)
        mutex_lock(&cpu_hotplug.lock);
        cpu_hotplug.refcount++;
        mutex_unlock(&cpu_hotplug.lock);
-
 }
 EXPORT_SYMBOL_GPL(get_online_cpus);
 
+bool try_get_online_cpus(void)
+{
+       if (cpu_hotplug.active_writer == current)
+               return true;
+       if (!mutex_trylock(&cpu_hotplug.lock))
+               return false;
+       cpuhp_lock_acquire_tryread();
+       cpu_hotplug.refcount++;
+       mutex_unlock(&cpu_hotplug.lock);
+       return true;
+}
+EXPORT_SYMBOL_GPL(try_get_online_cpus);
+
 void put_online_cpus(void)
 {
        if (cpu_hotplug.active_writer == current)