]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00155627-1 [MX6]Add thermal cooling devie
authorAnson Huang <b20788@freescale.com>
Thu, 1 Sep 2011 01:57:55 +0000 (09:57 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:33:10 +0000 (08:33 +0200)
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 <b20788@freescale.com>
drivers/thermal/thermal_sys.c
include/linux/thermal.h

index 0b1c82ad6805d2e0088840c4d2d17cff7e5dd109..04506f67ea453f321f8529786ce0c3c9ef04190f 100644 (file)
@@ -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),
index d3ec89fb4122610c26dfe0d86f499d50539280ff..b7c80e19b7b17cd640135792f66da99e7739b88e 100644 (file)
@@ -4,6 +4,7 @@
  *  Copyright (C) 2008  Intel Corp
  *  Copyright (C) 2008  Zhang Rui <rui.zhang@intel.com>
  *  Copyright (C) 2008  Sujith Thomas <sujith.thomas@intel.com>
+ *  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);