]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
thermal: convert to idr_alloc()
authorTejun Heo <tj@kernel.org>
Wed, 20 Feb 2013 02:16:24 +0000 (13:16 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Feb 2013 05:53:52 +0000 (16:53 +1100)
Convert to the much saner new idr interface.

Only compile tested.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/thermal/cpu_cooling.c
drivers/thermal/thermal_sys.c

index 455c77a961dec5119048fe7b687bc5cb100ed3f5..8dc44cbb3e09fe253546347e376c0834957efc1e 100644 (file)
@@ -73,21 +73,14 @@ static struct cpufreq_cooling_device *notify_device;
  */
 static int get_idr(struct idr *idr, int *id)
 {
-       int err;
-again:
-       if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0))
-               return -ENOMEM;
+       int ret;
 
        mutex_lock(&cooling_cpufreq_lock);
-       err = idr_get_new(idr, NULL, id);
+       ret = idr_alloc(idr, NULL, 0, 0, GFP_KERNEL);
        mutex_unlock(&cooling_cpufreq_lock);
-
-       if (unlikely(err == -EAGAIN))
-               goto again;
-       else if (unlikely(err))
-               return err;
-
-       *id = *id & MAX_IDR_MASK;
+       if (unlikely(ret < 0))
+               return ret;
+       *id = ret;
        return 0;
 }
 
index 6472e7e9f969025f565e17d62ad83eaef80eedaf..2eaaaa60fb0970c47c4513525f9649adebb395fe 100644 (file)
@@ -131,23 +131,16 @@ EXPORT_SYMBOL_GPL(thermal_unregister_governor);
 
 static int get_idr(struct idr *idr, struct mutex *lock, int *id)
 {
-       int err;
-
-again:
-       if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0))
-               return -ENOMEM;
+       int ret;
 
        if (lock)
                mutex_lock(lock);
-       err = idr_get_new(idr, NULL, id);
+       ret = idr_alloc(idr, NULL, 0, 0, GFP_KERNEL);
        if (lock)
                mutex_unlock(lock);
-       if (unlikely(err == -EAGAIN))
-               goto again;
-       else if (unlikely(err))
-               return err;
-
-       *id = *id & MAX_IDR_MASK;
+       if (unlikely(ret < 0))
+               return ret;
+       *id = ret;
        return 0;
 }