From patchwork Wed May 4 06:02:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9010371 X-Patchwork-Delegate: rui.zhang@intel.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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EA011BF29F for ; Wed, 4 May 2016 06:06:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1AD1B202EC for ; Wed, 4 May 2016 06:06:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 426E72027D for ; Wed, 4 May 2016 06:06:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757262AbcEDGGE (ORCPT ); Wed, 4 May 2016 02:06:04 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:32770 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757266AbcEDGD1 (ORCPT ); Wed, 4 May 2016 02:03:27 -0400 Received: by mail-pf0-f178.google.com with SMTP id 206so21190069pfu.0; Tue, 03 May 2016 23:03:27 -0700 (PDT) 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=rOFyAQ+pMh7AcGPfd2pOadCJ37qolLLMcIh5H2eECVs=; b=pqWEzKifucOe8TQ92FDYaxNwBzLY1StycTYzD7ucvtnUhG/oFrZw83vQsfeo2p0GPE kpjI+SwG2KWEijFPdoPJWmg4yuCcQky2JPgYt5QLJEZDUapXkiZ6i0dmqfINiAaJx78G pj3gQFLDrZp68APB45SHpS/udEcL0tENMrfEVZBfjTuFvyUt6fG1kvY7UO6s3UUDVpm2 ctA801eBv5KvwGU3BqAVJ+BPblQokgfDqALynAvVDWWu7Watv9Pdd91Nk9z38ciif2tR dduz4WL1fWbi7hwQZ9E2ihHiGIbZTwOEVRsiTK2LUNGj7P8j7v1hUhcdc7BQl+v85fN/ JXLw== 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=rOFyAQ+pMh7AcGPfd2pOadCJ37qolLLMcIh5H2eECVs=; b=J+Vfpn1jzvkvpvlDq/z27ttbjU6Ec5DZwttnOZgHQNI5yym2ErzLJMRaT47mS2z/Vq UD1zixAlxoS2iEaJ2eBy50sclHj1JrAAEbUZzhhgD5fkF8TCzOM3JTlXP0Cr+FmkQ+Yu zWlAwqW9y9AOW6DYUHQfXyZqc5Al0RP6mejWJ2cfCw075PI2ZcCtrqYnCschKz6TX6Iv ZzYp4uhOuQONskYL8r/mu3gi2R5EWv1aqmvdyrx4gIDNaMe7toqgCMaroRflP7mVDIqY jgR0gdA52wFHvcDVgG8gCXtsQxI4hwx51ZLjnN9nUPp4WNbox9xycTvOF7UJwuZIzMOD rJBQ== X-Gm-Message-State: AOPr4FVCslVi0q8FW+QFgp+oIqiBnlFDP8BLpFZkTHtogUMIFQLwM7IWqLW1nJsrMMxqTA== X-Received: by 10.98.82.19 with SMTP id g19mr9445921pfb.157.1462341806674; Tue, 03 May 2016 23:03:26 -0700 (PDT) Received: from localhost ([2601:647:4203:c8e0:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id 87sm2612705pfq.93.2016.05.03.23.03.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 May 2016 23:03:25 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCH 22/31] thermal: core: move idr handling to device management section Date: Tue, 3 May 2016 23:02:36 -0700 Message-Id: <1462341765-13268-23-git-send-email-edubezval@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1462341765-13268-1-git-send-email-edubezval@gmail.com> References: <1462341765-13268-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-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 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 09b4b42..480db91 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) { @@ -691,6 +667,30 @@ void thermal_zone_device_passive_update(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