From patchwork Wed May 4 06:02:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9010521 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 446F69F1C1 for ; Wed, 4 May 2016 06:08:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65593202EC for ; Wed, 4 May 2016 06:08:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 667492027D for ; Wed, 4 May 2016 06:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750993AbcEDGIY (ORCPT ); Wed, 4 May 2016 02:08:24 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:34984 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757162AbcEDGDM (ORCPT ); Wed, 4 May 2016 02:03:12 -0400 Received: by mail-pf0-f181.google.com with SMTP id 77so20988544pfv.2; Tue, 03 May 2016 23:03:12 -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=it3wpGKxLmrR1saZOqYW6uh5gzyqkNTCyeNzbVNrIcA=; b=NMQr5ugqjCa5wbVAzDnlSTb8oKKiTcTPZov+Ageu/r8reNhmzqJnaZLva0f7ZmgpLd sV1gVaL+QAhSfGBPwOO+/+22JClpIdlnH28vB37momPMhol+9T/Gia/bQlvIOfxFuwfk lln52k53O4G5Lba04N8itDA7J87j1zZeRTxjHCDAiHVZTFRJ0KnX+T24F+b/y7QYu0wb ousOdaBc3LQ9Ozbk61hQ2UkdHYptzMiS/pFaiWS8TUUiKAMn37r3Xw0DkUqL1VEiLZdR LKdK+hMCQuuTztKWfAhKTPmWHvCPnq28YQdCyfvTqYLqx3fMg8FLoWpfAowiiDIVAaEt Uf7A== 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=it3wpGKxLmrR1saZOqYW6uh5gzyqkNTCyeNzbVNrIcA=; b=T+mPvIc5afFJJHkO/FNNf0Riu+Khf3R5vxGTcV7kGDNPOrUc0YWXVlRSXP1LoupKUX yqAUHZ0v403R9rGKqmoC/U8WxUSXDIj+0+9XhyBJI4hwVJNtzZUBVD62MeO1IIqd8XrP Bm6QnsRCR6CeLWV+o0YIq52it7kd4XRtPrdpJYSw2EoA0zP3tV3TBIt47RuyTekVuo7I 3DdV5RfbugEOUxSGxYeoM6YRq33izxIiLLpbaMzd77QDU0T5Y2khfomRwTa4vDZIxtIR W3z8Wbo4514nmfutXBW57tOqKjdZlFMZFV80YaHKkITn2kusoOy+Htgl6xhVwILT45IQ lBRw== X-Gm-Message-State: AOPr4FU61w+U28RSGYTKrz2NELopBwqLea/ZMHEmWkrfE2QWJx6Wd9EmRSd/vSVA9NMj1g== X-Received: by 10.98.55.133 with SMTP id e127mr9356103pfa.81.1462341791924; Tue, 03 May 2016 23:03:11 -0700 (PDT) Received: from localhost ([2601:647:4203:c8e0:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id lg8sm2602852pab.48.2016.05.03.23.03.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 May 2016 23:03:11 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCH 13/31] thermal: core: split passive_store Date: Tue, 3 May 2016 23:02:27 -0700 Message-Id: <1462341765-13268-14-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=unavailable 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 Split passive_store between sysfs handling and thermal core internal data handling. 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 | 69 +++++++++++++++++++++++------------------- drivers/thermal/thermal_core.h | 1 + 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 5c13fa8..6042ea2 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -662,6 +662,43 @@ int power_actor_set_power(struct thermal_cooling_device *cdev, return 0; } +void thermal_zone_device_passive_update(struct thermal_zone_device *tz, + int passive) +{ + struct thermal_cooling_device *cdev = NULL; + + if (passive && !tz->forced_passive) { + mutex_lock(&thermal_list_lock); + list_for_each_entry(cdev, &thermal_cdev_list, node) { + if (!strncmp("Processor", cdev->type, + sizeof("Processor"))) + thermal_zone_bind_cooling_device(tz, + THERMAL_TRIPS_NONE, cdev, + THERMAL_NO_LIMIT, + THERMAL_NO_LIMIT, + THERMAL_WEIGHT_DEFAULT); + } + mutex_unlock(&thermal_list_lock); + if (!tz->passive_delay) + tz->passive_delay = 1000; + } else if (!passive && tz->forced_passive) { + mutex_lock(&thermal_list_lock); + list_for_each_entry(cdev, &thermal_cdev_list, node) { + if (!strncmp("Processor", cdev->type, + sizeof("Processor"))) + thermal_zone_unbind_cooling_device(tz, + THERMAL_TRIPS_NONE, + cdev); + } + mutex_unlock(&thermal_list_lock); + tz->passive_delay = 0; + } + + tz->forced_passive = passive; + + thermal_zone_device_update(tz); +} + /* sys I/F for thermal zone */ #define to_thermal_zone(_dev) \ @@ -861,7 +898,6 @@ passive_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct thermal_zone_device *tz = to_thermal_zone(dev); - struct thermal_cooling_device *cdev = NULL; int state; if (!sscanf(buf, "%d\n", &state)) @@ -873,36 +909,7 @@ passive_store(struct device *dev, struct device_attribute *attr, if (state && state < 1000) return -EINVAL; - if (state && !tz->forced_passive) { - mutex_lock(&thermal_list_lock); - list_for_each_entry(cdev, &thermal_cdev_list, node) { - if (!strncmp("Processor", cdev->type, - sizeof("Processor"))) - thermal_zone_bind_cooling_device(tz, - THERMAL_TRIPS_NONE, cdev, - THERMAL_NO_LIMIT, - THERMAL_NO_LIMIT, - THERMAL_WEIGHT_DEFAULT); - } - mutex_unlock(&thermal_list_lock); - if (!tz->passive_delay) - tz->passive_delay = 1000; - } else if (!state && tz->forced_passive) { - mutex_lock(&thermal_list_lock); - list_for_each_entry(cdev, &thermal_cdev_list, node) { - if (!strncmp("Processor", cdev->type, - sizeof("Processor"))) - thermal_zone_unbind_cooling_device(tz, - THERMAL_TRIPS_NONE, - cdev); - } - mutex_unlock(&thermal_list_lock); - tz->passive_delay = 0; - } - - tz->forced_passive = state; - - thermal_zone_device_update(tz); + thermal_zone_device_passive_update(tz, state); return count; } diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 749d41a..da53693 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -56,6 +56,7 @@ struct thermal_instance { int thermal_register_governor(struct thermal_governor *); void thermal_unregister_governor(struct thermal_governor *); +void thermal_zone_device_passive_update(struct thermal_zone_device *, int); #ifdef CONFIG_THERMAL_GOV_STEP_WISE int thermal_gov_step_wise_register(void);