From patchwork Fri Sep 21 06:57:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 1489911 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 2E8A140113 for ; Fri, 21 Sep 2012 06:58:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753544Ab2IUG6B (ORCPT ); Fri, 21 Sep 2012 02:58:01 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:43451 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755286Ab2IUG6A (ORCPT ); Fri, 21 Sep 2012 02:58:00 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr4so1971467pbb.19 for ; Thu, 20 Sep 2012 23:58:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=ftHDmuHR/l9bxdWstnksxXlS2A3z84siB9kssBEJhws=; b=e4lEqRB2uplOyMS2XwPrgpciC4mbkIO06umpaakPPzQJmzwRPrnSNqI3sQzVa12Y5T 0raJa7bOO5W7pXwy9GIrk8E/UCaaIwc5/4r640ohhn1D7dX96XKp0XlkHPA7BKGnoiLV IxNxpXJFrm+uFqFy6MWIwMANpqC5JWTyFPz9f3+tKCvNgVKUvNEap4nSfPRCMOCEntVO vlFgQF/3mqsxKho5WORBBG6vGpeKAUknvVgSsysxSatxR5N2t4AZgHKkzFAyCSKis3Sg 4b9wJAsOLKkambv0WG+00RfbFsdxQiVlz05bnUlwYZi1Ofi6ZtFiOadeLdUIYX4USPsk EriQ== Received: by 10.68.242.10 with SMTP id wm10mr12988943pbc.61.1348210680240; Thu, 20 Sep 2012 23:58:00 -0700 (PDT) Received: from stebjsxu0064.bjs.st.com ([117.136.0.224]) by mx.google.com with ESMTPS id c5sm3687340pay.5.2012.09.20.23.57.54 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Sep 2012 23:57:59 -0700 (PDT) From: zhanghongbo To: linux-pm@vger.kernel.org, len.brown@intel.com, rui.zhang@intel.com Cc: patches@linaro.org, linaro-dev@lists.linaro.org, "hongbo.zhang" Subject: [PATCH 1/2] Thermal: Add interface to deactive cooling devices. Date: Fri, 21 Sep 2012 14:57:17 +0800 Message-Id: <1348210638-4746-2-git-send-email-hongbo.zhang@linaro.org> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1348210638-4746-1-git-send-email-hongbo.zhang@linaro.org> References: <1348210638-4746-1-git-send-email-hongbo.zhang@linaro.org> X-Gm-Message-State: ALoCoQmvt5/mSvbvaj5PqFSi8EokL8bn6hY+SIs9RC9Z42LyTxg3KNfQKQtDEdl3UdhLYiIQP5zo Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: "hongbo.zhang" If the thermal zone mode is disabled, all the referenced cooling devices should be put into state zero. Without this patch the thermal driver cannot deactive all its cooling devices in .set_mode callback, because the cooling device list is maintained in the generic thermal layer. This interface is introduced to fix it. Signed-off-by: hongbo.zhang --- drivers/thermal/thermal_sys.c | 22 ++++++++++++++++++++++ include/linux/thermal.h | 1 + 2 files changed, 23 insertions(+) diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 2ab31e4..2c28c85 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -1130,6 +1130,28 @@ leave: EXPORT_SYMBOL(thermal_zone_device_update); /** + * thermal_zone_device_deactive - deactive cooling devices of thermal zone + * @tz: thermal zone device + * + * This function should be called in the thermal zone device .set_mode + * callback when the thermal zone is disabled. + */ +void thermal_zone_device_deactive(struct thermal_zone_device *tz) +{ + struct thermal_cooling_device_instance *instance; + struct thermal_cooling_device *cdev; + + mutex_lock(&tz->lock); + list_for_each_entry(instance, &tz->cooling_devices, node) { + cdev = instance->cdev; + if (cdev->ops->set_cur_state) + cdev->ops->set_cur_state(cdev, 0); + } + mutex_unlock(&tz->lock); +} +EXPORT_SYMBOL(thermal_zone_device_deactive); + +/** * create_trip_attrs - create attributes for trip points * @tz: the thermal zone device * @mask: Writeable trip point bitmap. diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 4b94a61..5e915a3 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -161,6 +161,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int, struct thermal_cooling_device *); void thermal_zone_device_update(struct thermal_zone_device *); +void thermal_zone_device_deactive(struct thermal_zone_device *); struct thermal_cooling_device *thermal_cooling_device_register(char *, void *, const struct thermal_cooling_device_ops *); void thermal_cooling_device_unregister(struct thermal_cooling_device *);