From: Anson Huang Date: Thu, 1 Sep 2011 01:57:55 +0000 (+0800) Subject: ENGR00155627-1 [MX6]Add thermal cooling devie X-Git-Tag: v3.0.35-fsl~2125 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=57f0d8e1f8c0b08b812a3636fb0975dd9b5608b0;p=karo-tx-linux.git ENGR00155627-1 [MX6]Add thermal cooling devie 1.Common code of thermal_sys has some bug,could not set the mode via sysfs using echo enable/disabled command; 2.Since the anatop thermal formula still not accurate, in order to help test and adjust the trip point of anatop thermal zone, we add the set trip point temp value into the sysfs interface. Signed-off-by: Anson Huang --- diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 0b1c82ad6805..04506f67ea45 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -152,9 +152,9 @@ mode_store(struct device *dev, struct device_attribute *attr, if (!tz->ops->set_mode) return -EPERM; - if (!strncmp(buf, "enabled", sizeof("enabled"))) + if (!strncmp(buf, "enabled", sizeof("enabled") - 1)) result = tz->ops->set_mode(tz, THERMAL_DEVICE_ENABLED); - else if (!strncmp(buf, "disabled", sizeof("disabled"))) + else if (!strncmp(buf, "disabled", sizeof("disabled") - 1)) result = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED); else result = -EINVAL; @@ -218,6 +218,29 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%ld\n", temperature); } +static ssize_t +trip_point_temp_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct thermal_zone_device *tz = to_thermal_zone(dev); + int trip, ret; + long temperature; + + if (!tz->ops->set_trip_temp) + return -EPERM; + + if (!sscanf(attr->attr.name, "trip_point_%d_temp", &trip)) + return -EINVAL; + + ret = sscanf(buf, "%lu", &temperature); + + ret = tz->ops->set_trip_temp(tz, trip, &temperature); + if (ret) + return -EINVAL; + + return count; + +} static ssize_t passive_store(struct device *dev, struct device_attribute *attr, @@ -288,11 +311,14 @@ static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, \ static struct device_attribute trip_point_attrs[] = { __ATTR(trip_point_0_type, 0444, trip_point_type_show, NULL), - __ATTR(trip_point_0_temp, 0444, trip_point_temp_show, NULL), + __ATTR(trip_point_0_temp, 0644, trip_point_temp_show, + trip_point_temp_store), __ATTR(trip_point_1_type, 0444, trip_point_type_show, NULL), - __ATTR(trip_point_1_temp, 0444, trip_point_temp_show, NULL), + __ATTR(trip_point_1_temp, 0644, trip_point_temp_show, + trip_point_temp_store), __ATTR(trip_point_2_type, 0444, trip_point_type_show, NULL), - __ATTR(trip_point_2_temp, 0444, trip_point_temp_show, NULL), + __ATTR(trip_point_2_temp, 0644, trip_point_temp_show, + trip_point_temp_store), __ATTR(trip_point_3_type, 0444, trip_point_type_show, NULL), __ATTR(trip_point_3_temp, 0444, trip_point_temp_show, NULL), __ATTR(trip_point_4_type, 0444, trip_point_type_show, NULL), diff --git a/include/linux/thermal.h b/include/linux/thermal.h index d3ec89fb4122..b7c80e19b7b1 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -4,6 +4,7 @@ * Copyright (C) 2008 Intel Corp * Copyright (C) 2008 Zhang Rui * Copyright (C) 2008 Sujith Thomas + * Copyright (C) 2011 Freescale Semiconductor, Inc. * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * This program is free software; you can redistribute it and/or modify @@ -58,6 +59,8 @@ struct thermal_zone_device_ops { enum thermal_trip_type *); int (*get_trip_temp) (struct thermal_zone_device *, int, unsigned long *); + int (*set_trip_temp) (struct thermal_zone_device *, int, + unsigned long *); int (*get_crit_temp) (struct thermal_zone_device *, unsigned long *); int (*notify) (struct thermal_zone_device *, int, enum thermal_trip_type);