Skip to content

Commit

Permalink
thermal: convert to idr_alloc()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tejun Heo authored and Linus Torvalds committed Feb 28, 2013
1 parent ab51603 commit 6deb69f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
17 changes: 5 additions & 12 deletions drivers/thermal/cpu_cooling.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
17 changes: 5 additions & 12 deletions drivers/thermal/thermal_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,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;
}

Expand Down

0 comments on commit 6deb69f

Please sign in to comment.