aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-02-27 20:04:46 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:19 -0500
commit6deb69facebb2f9a2b15a8e5e33ab00ebc7c44cb (patch)
tree4f23dc9cea95c526ef23c28e895379a19197e3b8 /drivers
parentab51603672a335d325963ca410d9c527d9f834f7 (diff)
thermal: convert to idr_alloc()
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/thermal/cpu_cooling.c17
-rw-r--r--drivers/thermal/thermal_sys.c17
2 files changed, 10 insertions, 24 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 836828e29a87..c33fa5315d6b 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -73,21 +73,14 @@ static struct cpufreq_cooling_device *notify_device;
73 */ 73 */
74static int get_idr(struct idr *idr, int *id) 74static int get_idr(struct idr *idr, int *id)
75{ 75{
76 int err; 76 int ret;
77again:
78 if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0))
79 return -ENOMEM;
80 77
81 mutex_lock(&cooling_cpufreq_lock); 78 mutex_lock(&cooling_cpufreq_lock);
82 err = idr_get_new(idr, NULL, id); 79 ret = idr_alloc(idr, NULL, 0, 0, GFP_KERNEL);
83 mutex_unlock(&cooling_cpufreq_lock); 80 mutex_unlock(&cooling_cpufreq_lock);
84 81 if (unlikely(ret < 0))
85 if (unlikely(err == -EAGAIN)) 82 return ret;
86 goto again; 83 *id = ret;
87 else if (unlikely(err))
88 return err;
89
90 *id = *id & MAX_IDR_MASK;
91 return 0; 84 return 0;
92} 85}
93 86
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 8c8ce806180f..84e95f32cdb6 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -132,23 +132,16 @@ EXPORT_SYMBOL_GPL(thermal_unregister_governor);
132 132
133static int get_idr(struct idr *idr, struct mutex *lock, int *id) 133static int get_idr(struct idr *idr, struct mutex *lock, int *id)
134{ 134{
135 int err; 135 int ret;
136
137again:
138 if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0))
139 return -ENOMEM;
140 136
141 if (lock) 137 if (lock)
142 mutex_lock(lock); 138 mutex_lock(lock);
143 err = idr_get_new(idr, NULL, id); 139 ret = idr_alloc(idr, NULL, 0, 0, GFP_KERNEL);
144 if (lock) 140 if (lock)
145 mutex_unlock(lock); 141 mutex_unlock(lock);
146 if (unlikely(err == -EAGAIN)) 142 if (unlikely(ret < 0))
147 goto again; 143 return ret;
148 else if (unlikely(err)) 144 *id = ret;
149 return err;
150
151 *id = *id & MAX_IDR_MASK;
152 return 0; 145 return 0;
153} 146}
154 147