From patchwork Tue May 31 06:18:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9143509 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 15C3A60761 for ; Tue, 31 May 2016 06:31:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A2C527D17 for ; Tue, 31 May 2016 06:31:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F32AB281C1; Tue, 31 May 2016 06:31:44 +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 69D9527D17 for ; Tue, 31 May 2016 06:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755443AbcEaG3t (ORCPT ); Tue, 31 May 2016 02:29:49 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:33454 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755438AbcEaGTZ (ORCPT ); Tue, 31 May 2016 02:19:25 -0400 Received: by mail-pa0-f65.google.com with SMTP id f8so23990747pag.0; Mon, 30 May 2016 23:19:25 -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=V+9FD0cvHxAXE9YAgD1fm5wCMoDirqvB0IvT7bx5U+s=; b=cOD+zgfIJ5kbGuSwfoskhgDO7HoFcCnS59m0rbkqWZXi40DGIR/Dnk1UciV3z/zZ2p dZBxAPBE8xCk5OTueu+Ehv8vtXTEBK1EciJ95X1lRzhixdPMQNjGFjQ+ohN/iqoSHgF/ tJzoaMYCqTr6JwnRYA7C9g2tAHkqe5BvG//tkX9iSn7ZG4kZEI/ps8lCjdhowfflJqRE f8C0uJUj3pp18GGiTJ6elS2ToM5QSQSInG3I/RBBcNtR8FSP6Ry+Fvj45SMd8QQvieYO CMICevWqi3XSohcvev2SsqPpILv2jyG8euGIkQh5kb5TnCHzTcrpqSwzOq1lYeKKMxpI eqdw== 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=V+9FD0cvHxAXE9YAgD1fm5wCMoDirqvB0IvT7bx5U+s=; b=YV4ZdE+AYTDTaf2xfu4jpZSeUaSt87jp0Sydxs8Ef8wLG7sR3lh2+6vYFw9Mpl1jEn OAMkns6e5sriLN30NDfjDb5PL0BH92QPzY2Pw0mVrpxx2XvSnIztV6+LQ4+ujH8zgump UdwpexPJ5pJz8POZ/TKpas3l31H1QeJ/iMbFhxdI7HJ/agYQGIFYQad7B0g0NhjBcqZ6 kiF0H++W3Vk1Vjjb//AZs/5B9QHqHvMKj++5t2MBylHEiH88bzNMkdsxwlD69mUR1+K9 Zdj/hkahuFvLcDDzc5TwyWLpE1GDn2FuP84+GutNc9lrZic6uc4LfDQ9unPjB+ilFMMv jWCg== X-Gm-Message-State: ALyK8tJp53Pygjig+f9qC8eziWEwHc90GFMLI4e0ywL7x2iHA09Ga/eeFb0AFEGsc4KQRw== X-Received: by 10.66.251.2 with SMTP id zg2mr52919407pac.32.1464675564513; Mon, 30 May 2016 23:19:24 -0700 (PDT) Received: from localhost ([2601:b00:c501:3660:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id w23sm37133782pfa.38.2016.05.30.23.19.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 23:19:23 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Keerthy , Eduardo Valentin Subject: [PATCHv4 16/48] thermal: core: split passive_store Date: Mon, 30 May 2016 23:18:23 -0700 Message-Id: <1464675535-2433-17-git-send-email-edubezval@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464675535-2433-1-git-send-email-edubezval@gmail.com> References: <1464675535-2433-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 c8a05a5..59ebe4e 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);