diff mbox

[1/2] Thermal: Add interface to deactive cooling devices.

Message ID 1348210638-4746-2-git-send-email-hongbo.zhang@linaro.org
State New
Headers show

Commit Message

Hongbo Zhang Sept. 21, 2012, 6:57 a.m. UTC
From: "hongbo.zhang" <hongbo.zhang@linaro.com>

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 <hongbo.zhang@linaro.com>
---
 drivers/thermal/thermal_sys.c | 22 ++++++++++++++++++++++
 include/linux/thermal.h       |  1 +
 2 files changed, 23 insertions(+)
diff mbox

Patch

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 *);