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: 41683 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A03CE244C2 for ; Fri, 28 Nov 2014 09:45:42 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e53sf4041482eek.3 for ; Fri, 28 Nov 2014 01:45:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=m1uD5Tmc0IzIyPNWu80SGrbsAFPvAD61pXuANrY3Qhg=; b=Ev40kSz3BrYCtOllOH3/5O9bkb3EkhGdWYmcseWc/1AGUYe1v9GnAQgZAqNENuqgRC w4gwRqyeu67g76gJQZ2d5Jzs4rgKVCtpGscfBGgdHZQ7jJgDF8WnXGu8YkCMk3B6Mv0C qVJetrGNNTbR1I5aaYdbged7rs2gQh4Z884uqqokbg2sUQDNHZ1AVlfT4ykPF4nf6s9/ W9MLnjFmtCWkxnP+XTwDHtozOXJXtRTTIqnySN/yCbo3lMeWtrG1CF7gDgy/K71HXSiw TJ38XZD6f7QdrFt96ngseoK5a6TQgmhP4YJIcvPgwM4m1mBcQgsrZp3CqMgIq/zMagl8 oEhg== X-Gm-Message-State: ALoCoQm8jWhhgdAEfWgMks/kv5hU5MwnHiSkNnCX1hGZn6E3i9KZaLEVxohPBAUskna9MTbyXZAm X-Received: by 10.194.178.163 with SMTP id cz3mr11118027wjc.1.1417167941936; Fri, 28 Nov 2014 01:45:41 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.166 with SMTP id f6ls927585lam.8.gmail; Fri, 28 Nov 2014 01:45:41 -0800 (PST) X-Received: by 10.112.142.197 with SMTP id ry5mr43599785lbb.26.1417167941778; Fri, 28 Nov 2014 01:45:41 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id m2si1151396lbs.81.2014.11.28.01.45.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Nov 2014 01:45:41 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id n15so5301435lbi.2 for ; Fri, 28 Nov 2014 01:45:41 -0800 (PST) X-Received: by 10.112.38.4 with SMTP id c4mr27283821lbk.46.1417167941654; Fri, 28 Nov 2014 01:45:41 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp60477lbc; Fri, 28 Nov 2014 01:45:40 -0800 (PST) X-Received: by 10.67.14.231 with SMTP id fj7mr23123554pad.80.1417167939999; Fri, 28 Nov 2014 01:45:39 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vj10si15336419pbc.138.2014.11.28.01.45.39 for ; Fri, 28 Nov 2014 01:45:39 -0800 (PST) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751252AbaK1Jpi (ORCPT + 12 others); 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-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: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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);