From patchwork Fri Nov 28 09:44:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 5402471 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 09C2EBEEA8 for ; Fri, 28 Nov 2014 09:45:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1EC0F20142 for ; Fri, 28 Nov 2014 09:45:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 417FE2013D for ; Fri, 28 Nov 2014 09:45:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751252AbaK1Jpi (ORCPT ); Fri, 28 Nov 2014 04:45:38 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:62401 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751761AbaK1Jph (ORCPT ); Fri, 28 Nov 2014 04:45:37 -0500 Received: by mail-pa0-f53.google.com with SMTP id kq14so6438545pab.26 for ; Fri, 28 Nov 2014 01:45:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=vS+9ol7Yjs2S8GtuSy3ehsLvwDd9bSNBJVsIi/SKy9o=; b=ZC1YDtewXceWmBH6ItheNeaHZ6/PQHYZFyZsgnd5Yd7d9S7k3/ZfKCmmbo9sAnCdLU Eix6wr3T1HUgTMneV7hN7YGQiPMjGyouPSdwXV/iCBAVCaT34SU1UDGX5eZKW2wLieaO j52IIQYI1cX+i3lt03Gc2hYKXkysIfi49h8i8EXQQsFPqTRUWHlK/ywZG3MEqnob0fvm 7kXG8qIFteFekqYCDEaaFJKsoE6eU/skr5hY4l4Qel6SDX6dd0oYZ4NjbFUEzQ2e0Gta ST+SanD2VDUSNdnwg6WtkKutR2Ja8xagmgst0WbKGd/Zd8vmRtjTYxc6Y+EI0mSpAuTP wIMQ== X-Gm-Message-State: ALoCoQlkmN9SmvWHUFgDtlO6S7Qg8HD8+hKyOEGhm5SkjlQ9xZd8dL7drXkszdKReBXa+iaGWa/M X-Received: by 10.70.140.229 with SMTP id rj5mr3787378pdb.60.1417167937494; Fri, 28 Nov 2014 01:45:37 -0800 (PST) Received: from localhost ([122.167.111.40]) by mx.google.com with ESMTPSA id oz10sm9353623pdb.95.2014.11.28.01.45.36 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 28 Nov 2014 01:45:36 -0800 (PST) From: Viresh Kumar To: linux-pm@vger.kernel.org, edubezval@gmail.com Cc: linaro-kernel@lists.linaro.org, rui.zhang@intel.com, Viresh Kumar Subject: [PATCH 16/26] cpu_cooling: Drop useless locking around idr_alloc/idr_remove Date: Fri, 28 Nov 2014 15:14:10 +0530 Message-Id: X-Mailer: git-send-email 2.0.3.693.g996b0fd In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Locking around idr_alloc/idr_remove looks rather pointless as there is no race it is trying to fix. Remove it. get_idr() and release_idr() aren't much useful now, so get rid of them as well. Signed-off-by: Viresh Kumar --- @Eduardo: Same is true for thermal-core as well ? --- drivers/thermal/cpu_cooling.c | 45 ++++--------------------------------------- 1 file changed, 4 insertions(+), 41 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 032cba3..ca8f1bb 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -73,42 +73,6 @@ static unsigned int cpufreq_dev_count; #define NOTIFY_INVALID NULL static struct cpufreq_cooling_device *notify_device; -/** - * get_idr - function to get a unique id. - * @idr: struct idr * handle used to create a id. - * @id: int * value generated by this function. - * - * This function will populate @id with an unique - * id, using the idr API. - * - * Return: 0 on success, an error code on failure. - */ -static int get_idr(struct idr *idr, int *id) -{ - int ret; - - mutex_lock(&cooling_cpufreq_lock); - ret = idr_alloc(idr, NULL, 0, 0, GFP_KERNEL); - mutex_unlock(&cooling_cpufreq_lock); - if (unlikely(ret < 0)) - return ret; - *id = ret; - - return 0; -} - -/** - * release_idr - function to free the unique id. - * @idr: struct idr * handle used for creating the id. - * @id: int value representing the unique id. - */ -static void release_idr(struct idr *idr, int id) -{ - mutex_lock(&cooling_cpufreq_lock); - idr_remove(idr, id); - mutex_unlock(&cooling_cpufreq_lock); -} - /* Below code defines functions to be used for cpufreq as cooling device */ enum cpufreq_cooling_property { @@ -430,7 +394,6 @@ __cpufreq_cooling_register(struct device_node *np, struct thermal_cooling_device *cool_dev; struct cpufreq_cooling_device *cpufreq_dev; char dev_name[THERMAL_NAME_LENGTH]; - int ret = 0; cpufreq_dev = kzalloc(sizeof(*cool_dev), GFP_KERNEL); if (!cpufreq_dev) @@ -438,8 +401,8 @@ __cpufreq_cooling_register(struct device_node *np, cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus); - ret = get_idr(&cpufreq_idr, &cpufreq_dev->id); - if (ret) { + cpufreq_dev->id = idr_alloc(&cpufreq_idr, NULL, 0, 0, GFP_KERNEL); + if (unlikely(cpufreq_dev->id < 0)) { cool_dev = ERR_PTR(cpufreq_dev->id); goto free_cdev; } @@ -467,7 +430,7 @@ __cpufreq_cooling_register(struct device_node *np, return cool_dev; remove_idr: - release_idr(&cpufreq_idr, cpufreq_dev->id); + idr_remove(&cpufreq_idr, cpufreq_dev->id); free_cdev: kfree(cpufreq_dev); @@ -540,7 +503,7 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) mutex_unlock(&cooling_cpufreq_lock); thermal_cooling_device_unregister(cpufreq_dev->cool_dev); - release_idr(&cpufreq_idr, cpufreq_dev->id); + idr_remove(&cpufreq_idr, cpufreq_dev->id); kfree(cpufreq_dev); } EXPORT_SYMBOL_GPL(cpufreq_cooling_unregister);