crypto: hisilicon/qm - fix the call trace when unbind device
[linux-2.6-microblaze.git] / drivers / thermal / thermal_sysfs.c
index aa99edb..8c23121 100644 (file)
@@ -49,18 +49,9 @@ static ssize_t
 mode_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct thermal_zone_device *tz = to_thermal_zone(dev);
-       enum thermal_device_mode mode;
-       int result;
-
-       if (!tz->ops->get_mode)
-               return -EPERM;
+       int enabled = thermal_zone_device_is_enabled(tz);
 
-       result = tz->ops->get_mode(tz, &mode);
-       if (result)
-               return result;
-
-       return sprintf(buf, "%s\n", mode == THERMAL_DEVICE_ENABLED ? "enabled"
-                      : "disabled");
+       return sprintf(buf, "%s\n", enabled ? "enabled" : "disabled");
 }
 
 static ssize_t
@@ -70,13 +61,10 @@ mode_store(struct device *dev, struct device_attribute *attr,
        struct thermal_zone_device *tz = to_thermal_zone(dev);
        int result;
 
-       if (!tz->ops->set_mode)
-               return -EPERM;
-
        if (!strncmp(buf, "enabled", sizeof("enabled") - 1))
-               result = tz->ops->set_mode(tz, THERMAL_DEVICE_ENABLED);
+               result = thermal_zone_device_enable(tz);
        else if (!strncmp(buf, "disabled", sizeof("disabled") - 1))
-               result = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED);
+               result = thermal_zone_device_disable(tz);
        else
                result = -EINVAL;
 
@@ -124,7 +112,8 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
 {
        struct thermal_zone_device *tz = to_thermal_zone(dev);
        int trip, ret;
-       int temperature;
+       int temperature, hyst = 0;
+       enum thermal_trip_type type;
 
        if (!tz->ops->set_trip_temp)
                return -EPERM;
@@ -139,6 +128,18 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
        if (ret)
                return ret;
 
+       if (tz->ops->get_trip_hyst) {
+               ret = tz->ops->get_trip_hyst(tz, trip, &hyst);
+               if (ret)
+                       return ret;
+       }
+
+       ret = tz->ops->get_trip_type(tz, trip, &type);
+       if (ret)
+               return ret;
+
+       thermal_notify_tz_trip_change(tz->id, trip, type, temperature, hyst);
+
        thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
 
        return count;
@@ -428,30 +429,13 @@ static struct attribute_group thermal_zone_attribute_group = {
        .attrs = thermal_zone_dev_attrs,
 };
 
-/* We expose mode only if .get_mode is present */
 static struct attribute *thermal_zone_mode_attrs[] = {
        &dev_attr_mode.attr,
        NULL,
 };
 
-static umode_t thermal_zone_mode_is_visible(struct kobject *kobj,
-                                           struct attribute *attr,
-                                           int attrno)
-{
-       struct device *dev = container_of(kobj, struct device, kobj);
-       struct thermal_zone_device *tz;
-
-       tz = container_of(dev, struct thermal_zone_device, device);
-
-       if (tz->ops->get_mode)
-               return attr->mode;
-
-       return 0;
-}
-
 static struct attribute_group thermal_zone_mode_attribute_group = {
        .attrs = thermal_zone_mode_attrs,
-       .is_visible = thermal_zone_mode_is_visible,
 };
 
 /* We expose passive only if passive trips are present */