Merge branch 'pm-cpuidle'
[firefly-linux-kernel-4.4.55.git] / drivers / acpi / thermal.c
index dc1ba6c9ef5da07b510c909d7779cd37091c95c3..6a0329340b42ad188add760db66ebcc17ba9ab22 100644 (file)
 
 #define ACPI_THERMAL_CLASS             "thermal_zone"
 #define ACPI_THERMAL_DEVICE_NAME       "Thermal Zone"
-#define ACPI_THERMAL_FILE_STATE                "state"
-#define ACPI_THERMAL_FILE_TEMPERATURE  "temperature"
-#define ACPI_THERMAL_FILE_TRIP_POINTS  "trip_points"
-#define ACPI_THERMAL_FILE_COOLING_MODE "cooling_mode"
-#define ACPI_THERMAL_FILE_POLLING_FREQ "polling_frequency"
 #define ACPI_THERMAL_NOTIFY_TEMPERATURE        0x80
 #define ACPI_THERMAL_NOTIFY_THRESHOLDS 0x81
 #define ACPI_THERMAL_NOTIFY_DEVICES    0x82
@@ -238,26 +233,16 @@ static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
 
 static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
 {
-       acpi_status status = AE_OK;
-       union acpi_object arg0 = { ACPI_TYPE_INTEGER };
-       struct acpi_object_list arg_list = { 1, &arg0 };
-       acpi_handle handle = NULL;
-
-
        if (!tz)
                return -EINVAL;
 
-       status = acpi_get_handle(tz->device->handle, "_SCP", &handle);
-       if (ACPI_FAILURE(status)) {
+       if (!acpi_has_method(tz->device->handle, "_SCP")) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n"));
                return -ENODEV;
-       }
-
-       arg0.integer.value = mode;
-
-       status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
-       if (ACPI_FAILURE(status))
+       } else if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle,
+                                                          "_SCP", mode))) {
                return -ENODEV;
+       }
 
        return 0;
 }
@@ -490,14 +475,14 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
                        break;
        }
 
-       if (flag & ACPI_TRIPS_DEVICES) {
-               memset(&devices, 0, sizeof(struct acpi_handle_list));
+       if ((flag & ACPI_TRIPS_DEVICES)
+           && acpi_has_method(tz->device->handle, "_TZD")) {
+               memset(&devices, 0, sizeof(devices));
                status = acpi_evaluate_reference(tz->device->handle, "_TZD",
                                                NULL, &devices);
-               if (memcmp(&tz->devices, &devices,
-                               sizeof(struct acpi_handle_list))) {
-                       memcpy(&tz->devices, &devices,
-                               sizeof(struct acpi_handle_list));
+               if (ACPI_SUCCESS(status)
+                   && memcmp(&tz->devices, &devices, sizeof(devices))) {
+                       tz->devices = devices;
                        ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device");
                }
        }
@@ -848,12 +833,13 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
                if (ACPI_SUCCESS(status) && (dev == device)) {
                        if (bind)
                                result = thermal_zone_bind_cooling_device
-                                               (thermal, -1, cdev,
-                                                THERMAL_NO_LIMIT,
+                                               (thermal, THERMAL_TRIPS_NONE,
+                                                cdev, THERMAL_NO_LIMIT,
                                                 THERMAL_NO_LIMIT);
                        else
                                result = thermal_zone_unbind_cooling_device
-                                               (thermal, -1, cdev);
+                                               (thermal, THERMAL_TRIPS_NONE,
+                                                cdev);
                        if (result)
                                goto failed;
                }