Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6deb69fa authored by Tejun Heo's avatar Tejun Heo Committed by Linus Torvalds
Browse files

thermal: convert to idr_alloc()



Convert to the much saner new idr interface.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ab516036
Loading
Loading
Loading
Loading
+5 −12
Original line number Original line Diff line number Diff line
@@ -73,21 +73,14 @@ static struct cpufreq_cooling_device *notify_device;
 */
 */
static int get_idr(struct idr *idr, int *id)
static int get_idr(struct idr *idr, int *id)
{
{
	int err;
	int ret;
again:
	if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0))
		return -ENOMEM;


	mutex_lock(&cooling_cpufreq_lock);
	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);
	mutex_unlock(&cooling_cpufreq_lock);

	if (unlikely(ret < 0))
	if (unlikely(err == -EAGAIN))
		return ret;
		goto again;
	*id = ret;
	else if (unlikely(err))
		return err;

	*id = *id & MAX_IDR_MASK;
	return 0;
	return 0;
}
}


+5 −12
Original line number Original line Diff line number Diff line
@@ -132,23 +132,16 @@ EXPORT_SYMBOL_GPL(thermal_unregister_governor);


static int get_idr(struct idr *idr, struct mutex *lock, int *id)
static int get_idr(struct idr *idr, struct mutex *lock, int *id)
{
{
	int err;
	int ret;

again:
	if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0))
		return -ENOMEM;


	if (lock)
	if (lock)
		mutex_lock(lock);
		mutex_lock(lock);
	err = idr_get_new(idr, NULL, id);
	ret = idr_alloc(idr, NULL, 0, 0, GFP_KERNEL);
	if (lock)
	if (lock)
		mutex_unlock(lock);
		mutex_unlock(lock);
	if (unlikely(err == -EAGAIN))
	if (unlikely(ret < 0))
		goto again;
		return ret;
	else if (unlikely(err))
	*id = ret;
		return err;

	*id = *id & MAX_IDR_MASK;
	return 0;
	return 0;
}
}