ACPI / Thermal / video: fix max_level incorrect value
[deliverable/linux.git] / drivers / thermal / thermal_core.c
index a0a8fd1235e2a21cbe5553c440b26eafecf8042e..5133cd1e10b7ae99d838823af2eef272aa00ab76 100644 (file)
@@ -454,6 +454,10 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
 {
        enum thermal_trip_type type;
 
+       /* Ignore disabled trip points */
+       if (test_bit(trip, &tz->trips_disabled))
+               return;
+
        tz->ops->get_trip_type(tz, trip, &type);
 
        if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT)
@@ -684,7 +688,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
 {
        struct thermal_zone_device *tz = to_thermal_zone(dev);
        int trip, ret;
-       unsigned long temperature;
+       int temperature;
 
        if (!tz->ops->set_trip_temp)
                return -EPERM;
@@ -692,7 +696,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
        if (!sscanf(attr->attr.name, "trip_point_%d_temp", &trip))
                return -EINVAL;
 
-       if (kstrtoul(buf, 10, &temperature))
+       if (kstrtoint(buf, 10, &temperature))
                return -EINVAL;
 
        ret = tz->ops->set_trip_temp(tz, trip, temperature);
@@ -895,9 +899,9 @@ emul_temp_store(struct device *dev, struct device_attribute *attr,
 {
        struct thermal_zone_device *tz = to_thermal_zone(dev);
        int ret = 0;
-       unsigned long temperature;
+       int temperature;
 
-       if (kstrtoul(buf, 10, &temperature))
+       if (kstrtoint(buf, 10, &temperature))
                return -EINVAL;
 
        if (!tz->ops->set_emul_temp) {
@@ -955,7 +959,7 @@ static DEVICE_ATTR(sustainable_power, S_IWUSR | S_IRUGO, sustainable_power_show,
        struct thermal_zone_device *tz = to_thermal_zone(dev);          \
                                                                        \
        if (tz->tzp)                                                    \
-               return sprintf(buf, "%u\n", tz->tzp->name);             \
+               return sprintf(buf, "%d\n", tz->tzp->name);             \
        else                                                            \
                return -EIO;                                            \
        }                                                               \
@@ -1800,6 +1804,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
 {
        struct thermal_zone_device *tz;
        enum thermal_trip_type trip_type;
+       int trip_temp;
        int result;
        int count;
        int passive = 0;
@@ -1871,9 +1876,15 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
                goto unregister;
 
        for (count = 0; count < trips; count++) {
-               tz->ops->get_trip_type(tz, count, &trip_type);
+               if (tz->ops->get_trip_type(tz, count, &trip_type))
+                       set_bit(count, &tz->trips_disabled);
                if (trip_type == THERMAL_TRIP_PASSIVE)
                        passive = 1;
+               if (tz->ops->get_trip_temp(tz, count, &trip_temp))
+                       set_bit(count, &tz->trips_disabled);
+               /* Check for bogus trip points */
+               if (trip_temp == 0)
+                       set_bit(count, &tz->trips_disabled);
        }
 
        if (!passive) {
This page took 0.029957 seconds and 5 git commands to generate.