From patchwork Tue Nov 8 05:09:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9416571 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E793760459 for ; Tue, 8 Nov 2016 05:24:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D893428B9B for ; Tue, 8 Nov 2016 05:24:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD93728B9D; Tue, 8 Nov 2016 05:24:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35E0428B9B for ; Tue, 8 Nov 2016 05:24:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752242AbcKHFY2 (ORCPT ); Tue, 8 Nov 2016 00:24:28 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34505 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752869AbcKHFY2 (ORCPT ); Tue, 8 Nov 2016 00:24:28 -0500 Received: by mail-pf0-f195.google.com with SMTP id y68so18122729pfb.1; Mon, 07 Nov 2016 21:24:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0vdOG0cRfiYYOLdZDJGuvHef9NW7kVld6jb+In8EXoM=; b=Uytb683qZg/oru2xydWNhs1h3Fcql2q1Li36LmxhwF7CkL0niBHHhVPdhX4vxmZOUy Eii0M9D1/I5AvhDAYKxpR2SZTzTNDiZGNtK47yf1mRLww6mi7ulM2bW3LxFmrFQEm9CH zx8y3YYPnIw4btIGGiP+ZlqzJ41rdpeoE59bkJEtC1P9mxE9obXhbJ1XISxLC6YjAuJh nA5VrS6otB/PDo2Tjmnf80r0t/UKaLErax1BkDagg1/q/kIV/hh/cCQ2FzqC6BbjXUti vDhwnQoQsr+WWLJ/ulX10wapMPCxMs+9t1Gh5pkbz4XvhWCC1TK95vv/2I0MikBYjrbl m+wA== 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; bh=0vdOG0cRfiYYOLdZDJGuvHef9NW7kVld6jb+In8EXoM=; b=N/mV/7C6eIVzl8axf35VGwumyzUxXRTivlhOaqSArNckmcP2vhr6GItNwP9basS1K8 LkqxtXMahhq+eMLk5RVWh7wIk12QRsDSYgmRRZNOWBuKu9FWkiXGrVWVIOoZeovVhlN6 AphlmXpl1wqlpy5aGtw8VH9IQ0DbrxFL5r8ia9lXt7zCnTLgblAVBZi5vf7Jj89w6VM2 tZiIoc1Ip6i9OSBFg6Kf5tiBayIH+DHyWBLN52Ypw+IEfd5E2C7UhcPt5F83vIImaRl1 SGnBEAO9ECaK/sRaRPTZdGrJeRvm/6x7jRV530FeE+XWrgqR6XYP5OPG+qmxVupNUVms O00g== X-Gm-Message-State: ABUngvey5rYfs802Ljy2VSo4DLFn5R5HATY2lNj/JLRdS7CkHzMfPxMZuUq3KxlGVH2j6g== X-Received: by 10.98.220.157 with SMTP id c29mr20027275pfl.29.1478581843416; Mon, 07 Nov 2016 21:10:43 -0800 (PST) Received: from localhost ([2601:647:4401:a2f0:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id f23sm44375087pff.59.2016.11.07.21.10.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Nov 2016 21:10:42 -0800 (PST) From: Eduardo Valentin To: Rui Zhang Cc: LKML , Linux PM , Eduardo Valentin Subject: [PATCHv2 28/49] thermal: core: move idr handling to device management section Date: Mon, 7 Nov 2016 21:09:06 -0800 Message-Id: <1478581767-7009-29-git-send-email-edubezval@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1478581767-7009-1-git-send-email-edubezval@gmail.com> References: <1478581767-7009-1-git-send-email-edubezval@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Given that idr is only used to get id for thermal devices (zones and cooling), makes sense to move the code closer. Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin --- drivers/thermal/thermal_core.c | 48 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index e36a6a6..f6e24ef 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -286,30 +286,6 @@ static void thermal_unregister_governors(void) thermal_gov_power_allocator_unregister(); } -static int get_idr(struct idr *idr, struct mutex *lock, int *id) -{ - int ret; - - if (lock) - mutex_lock(lock); - ret = idr_alloc(idr, NULL, 0, 0, GFP_KERNEL); - if (lock) - mutex_unlock(lock); - if (unlikely(ret < 0)) - return ret; - *id = ret; - return 0; -} - -static void release_idr(struct idr *idr, struct mutex *lock, int id) -{ - if (lock) - mutex_lock(lock); - idr_remove(idr, id); - if (lock) - mutex_unlock(lock); -} - static void print_bind_err_msg(struct thermal_zone_device *tz, struct thermal_cooling_device *cdev, int ret) { @@ -699,6 +675,30 @@ void thermal_zone_device_unbind_exception(struct thermal_zone_device *tz, /* Device management */ +static int get_idr(struct idr *idr, struct mutex *lock, int *id) +{ + int ret; + + if (lock) + mutex_lock(lock); + ret = idr_alloc(idr, NULL, 0, 0, GFP_KERNEL); + if (lock) + mutex_unlock(lock); + if (unlikely(ret < 0)) + return ret; + *id = ret; + return 0; +} + +static void release_idr(struct idr *idr, struct mutex *lock, int id) +{ + if (lock) + mutex_lock(lock); + idr_remove(idr, id); + if (lock) + mutex_unlock(lock); +} + /** * thermal_zone_bind_cooling_device() - bind a cooling device to a thermal zone * @tz: pointer to struct thermal_zone_device