From patchwork Wed Feb 6 19:40:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2107091 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 621B7DF2A1 for ; Wed, 6 Feb 2013 19:56:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758454Ab3BFT4V (ORCPT ); Wed, 6 Feb 2013 14:56:21 -0500 Received: from mail-ob0-f177.google.com ([209.85.214.177]:65297 "EHLO mail-ob0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030239Ab3BFTvH (ORCPT ); Wed, 6 Feb 2013 14:51:07 -0500 Received: by mail-ob0-f177.google.com with SMTP id wc18so1845881obb.22 for ; Wed, 06 Feb 2013 11:51:07 -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=hpuNdgSy3F06FvLl2gNorzaZgWWdCk8iry+I9TNkxTQ=; b=GhhNBD3PLTxaETnDYmufsgnkxfGX4bUcVgZ5zq0FQHH7lf6oZ6+v/8AYv+1Pd0CJeK 0R9fiGGsdgHZMifDfk/oKDv7Sc2FVqTC+a8J/S5lj/8fuPaMM9vNudjGTUEpMWcwKH/G lfBCMGeiD09X0NwEeRwCxLm5xf8SWSMFhZNd4RPL3lu30u6HazKJUna7veHTItMsscqI Wm/TfR2TlzHioVx82F0eE435Cf9b7cjVZJxtdvM8OJMYAna59VEyZFfIP9baoRNRE1/W qezVPpLc9s/kXpOxIbSCvRSygqlS93pi2zgCWhUvXPpAM3bXp9rB/RoJBbS20sOIbs3y dk0w== X-Received: by 10.182.15.5 with SMTP id t5mr21800954obc.40.1360180267097; Wed, 06 Feb 2013 11:51:07 -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 l5sm39989590pax.10.2013.02.06.11.51.05 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 06 Feb 2013 11:51:06 -0800 (PST) From: Tejun Heo To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Tejun Heo , Zhang Rui , linux-pm@vger.kernel.org Subject: [PATCH 64/77] thermal: convert to idr_alloc() Date: Wed, 6 Feb 2013 11:40:36 -0800 Message-Id: <1360179649-22465-65-git-send-email-tj@kernel.org> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1360179649-22465-1-git-send-email-tj@kernel.org> References: <1360179649-22465-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 --- 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 0a1bf6b..0767193 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -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; }