From patchwork Sun Feb 3 01:20:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2085531 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 37CCD3FD2B for ; Sun, 3 Feb 2013 01:27:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754111Ab3BCB04 (ORCPT ); Sat, 2 Feb 2013 20:26:56 -0500 Received: from mail-pb0-f41.google.com ([209.85.160.41]:54274 "EHLO mail-pb0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754066Ab3BCBWw (ORCPT ); Sat, 2 Feb 2013 20:22:52 -0500 Received: by mail-pb0-f41.google.com with SMTP id ro12so2684018pbb.28 for ; Sat, 02 Feb 2013 17:22:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=242hQEPUJZmJanEkpilRHjK4Ux8Xuduy9wkYkcSqWAw=; b=Gia9JCOPI1BMOf5HKLXtheIzcA14AMDVE4RnfmEAMLMIeXRL9vyPIqGs19hz9pMc9h N1/twp+uhnm8rgQfPv3xwVAkMy9TYC8KY3Fkk6T6x/H129UBRi3kWTCmOUb/uw5rgZ1A PYBL4ROxgmrRClQGfnWTvudlOvWZByvSazcawjkC+sDB8EiQK41kEHMyjGllEkxzKbTz P5uwgmHz6kmlz1qP77KKG759/sfLUS9CdtNpkuaUixn4AQ9KuGdTv3l4HB2kdjyokvuz pjR/ZbOu++eOEFw1p3xPRO5XWQ7Y+EdGgePZzZfX8OZ01+jJYGcWnj+JbsqYN/P4tylO AsFA== X-Received: by 10.68.230.135 with SMTP id sy7mr44485862pbc.76.1359854572154; Sat, 02 Feb 2013 17:22:52 -0800 (PST) Received: from htj.dyndns.org (c-69-181-251-227.hsd1.ca.comcast.net. [69.181.251.227]) by mx.google.com with ESMTPS id hs2sm13149467pbc.22.2013.02.02.17.22.50 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 02 Feb 2013 17:22:51 -0800 (PST) From: Tejun Heo To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, rusty@rustcorp.com.au, bfields@fieldses.org, skinsbursky@parallels.com, ebiederm@xmission.com, jmorris@namei.org, axboe@kernel.dk, Tejun Heo , Zhang Rui , linux-pm@vger.kernel.org Subject: [PATCH 48/62] thermal: convert to idr_alloc() Date: Sat, 2 Feb 2013 17:20:49 -0800 Message-Id: <1359854463-2538-49-git-send-email-tj@kernel.org> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1359854463-2538-1-git-send-email-tj@kernel.org> References: <1359854463-2538-1-git-send-email-tj@kernel.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Convert to the much saner new idr interface. Only compile tested. Signed-off-by: Tejun Heo Cc: Zhang Rui Cc: linux-pm@vger.kernel.org --- This patch depends on an earlier idr changes and I think it would be best to route these together through -mm. Please holler if there's any objection. Thanks. drivers/thermal/cpu_cooling.c | 17 +++++------------ drivers/thermal/thermal_sys.c | 17 +++++------------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 836828e..c33fa53 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -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; } diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 8c8ce80..84e95f3 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -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; }