From patchwork Mon May 30 21:27:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9142529 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 9446860761 for ; Mon, 30 May 2016 21:35:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 863832793B for ; Mon, 30 May 2016 21:35:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B38B2810E; Mon, 30 May 2016 21:35:05 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 DD6EC2793B for ; Mon, 30 May 2016 21:35:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162261AbcE3Veh (ORCPT ); Mon, 30 May 2016 17:34:37 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:35559 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423336AbcE3V2x (ORCPT ); Mon, 30 May 2016 17:28:53 -0400 Received: by mail-pa0-f68.google.com with SMTP id gp3so15668435pac.2; Mon, 30 May 2016 14:28:47 -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=BCyXv4+t9B+hI0i4pTps6nXreCGnN5quXD71crsgso4=; b=W+jO8BXmGfpaDASL0WDiSN+KdfA+daagXfNvczl7d5Cteughp2jh7+GnSz3fPdDw+8 LoZGvBPT6vSY5kBhrO56dpOlU/omKcG2rt/WhUYOL/ZZT+wUysHWdX41i2qGfnwiFCAn TAPC/LcCSYj4dYKP4XXa6r+YXBWKC8PICqswhsGw3HJwyjPgVjD8+8GShtTVYPNIkHJL uB7asDf79VaMSvXCWBaEbY6FhdSrwpPTMS076AGsafH/0BC79YaznH4xQ6AON4TvA+KI CEscI0D6jfMJScb2MRYtKkMEVcgDL8JMPhRtSvc4oB28Dc2HlLueXofTZeT6jigzpPYh T27w== 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=BCyXv4+t9B+hI0i4pTps6nXreCGnN5quXD71crsgso4=; b=k7bYG5zNsg2F9jEDd+eNv49JvIpyCN7Nm4qNou5ud53BQfv7XVe+xADidWibtfgvyT o4WSpFdw+cEkd7NUhFTp2srlGY5zkPn1tnmtz/fIuJGLvFrB+I7GUtF8nPvnzC83Vb1p ocXymBmvpgt2hAnSRyPRyNSPFdxsyDLhgFIvau+hh1LF0iWR1bS90usg2a8xgBpV8u/z WVN2Ikou/8yaTxLfS8eOVG8Njw5VCH77T/NfTpga4e2m8B7MzhTN1zmMQbbfxKbcIUpP 5a4ENOScQaOhUnxtjytQR+UZ21NtVzSxDIJzI8r1DLAXhX+gqPQ1njNundX+vzL3bNSJ O0qQ== X-Gm-Message-State: ALyK8tLYmHyfOpPicAdXF+R9ZuEbr4qECYQjn3WFoTLee2Ou+dsZcoXj2Jzg0kAAHee7rg== X-Received: by 10.66.122.175 with SMTP id lt15mr49498697pab.51.1464643727071; Mon, 30 May 2016 14:28:47 -0700 (PDT) Received: from localhost ([2601:b00:c501:3660:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id 83sm35046951pfl.12.2016.05.30.14.28.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 14:28:46 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCHv2 16/40] thermal: core: split passive_store Date: Mon, 30 May 2016 14:27:35 -0700 Message-Id: <1464643679-2733-17-git-send-email-edubezval@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464643679-2733-1-git-send-email-edubezval@gmail.com> References: <1464643679-2733-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 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 | 62 ++++++++++++++++++++++++++++-------------- drivers/thermal/thermal_core.h | 4 +++ 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 61410c3..5f5a87e 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -663,6 +663,43 @@ int power_actor_set_power(struct thermal_cooling_device *cdev, return 0; } +void thermal_zone_device_rebind_exception(struct thermal_zone_device *tz, + const char *cdev_type, size_t size) +{ + struct thermal_cooling_device *cdev = NULL; + + mutex_lock(&thermal_list_lock); + list_for_each_entry(cdev, &thermal_cdev_list, node) { + /* skip non matching cdevs */ + if (strncmp(cdev_type, cdev->type, size)) + continue; + + /* re binding the exception matching the type pattern */ + thermal_zone_bind_cooling_device(tz, THERMAL_TRIPS_NONE, cdev, + THERMAL_NO_LIMIT, + THERMAL_NO_LIMIT, + THERMAL_WEIGHT_DEFAULT); + } + mutex_unlock(&thermal_list_lock); +} + +void thermal_zone_device_unbind_exception(struct thermal_zone_device *tz, + const char *cdev_type, size_t size) +{ + struct thermal_cooling_device *cdev = NULL; + + mutex_lock(&thermal_list_lock); + list_for_each_entry(cdev, &thermal_cdev_list, node) { + /* skip non matching cdevs */ + if (strncmp(cdev_type, cdev->type, size)) + continue; + /* unbinding the exception matching the type pattern */ + thermal_zone_unbind_cooling_device(tz, THERMAL_TRIPS_NONE, + cdev); + } + mutex_unlock(&thermal_list_lock); +} + /* sys I/F for thermal zone */ #define to_thermal_zone(_dev) \ @@ -862,7 +899,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)) @@ -875,30 +911,14 @@ passive_store(struct device *dev, struct device_attribute *attr, 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; + thermal_zone_device_rebind_exception(tz, "Processor", + sizeof("Processor")); } 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; + thermal_zone_device_unbind_exception(tz, "Processor", + sizeof("Processor")); } tz->forced_passive = state; diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 749d41a..a765c75 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -56,6 +56,10 @@ struct thermal_instance { int thermal_register_governor(struct thermal_governor *); void thermal_unregister_governor(struct thermal_governor *); +void thermal_zone_device_rebind_exception(struct thermal_zone_device *, + const char *, size_t); +void thermal_zone_device_unbind_exception(struct thermal_zone_device *, + const char *, size_t); #ifdef CONFIG_THERMAL_GOV_STEP_WISE int thermal_gov_step_wise_register(void);