3131#include <linux/uaccess.h>
3232#include <linux/units.h>
3333
34+ #include "internal.h"
35+
3436#define ACPI_THERMAL_CLASS "thermal_zone"
3537#define ACPI_THERMAL_DEVICE_NAME "Thermal Zone"
3638#define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80
@@ -90,7 +92,7 @@ struct acpi_thermal_passive {
9092 struct acpi_thermal_trip trip ;
9193 unsigned long tc1 ;
9294 unsigned long tc2 ;
93- unsigned long tsp ;
95+ unsigned long delay ;
9496};
9597
9698struct acpi_thermal_active {
@@ -188,24 +190,19 @@ static int active_trip_index(struct acpi_thermal *tz,
188190
189191static long get_passive_temp (struct acpi_thermal * tz )
190192{
191- unsigned long long tmp ;
192- acpi_status status ;
193+ int temp ;
193194
194- status = acpi_evaluate_integer (tz -> device -> handle , "_PSV" , NULL , & tmp );
195- if (ACPI_FAILURE (status ))
195+ if (acpi_passive_trip_temp (tz -> device , & temp ))
196196 return THERMAL_TEMP_INVALID ;
197197
198- return tmp ;
198+ return temp ;
199199}
200200
201201static long get_active_temp (struct acpi_thermal * tz , int index )
202202{
203- char method [] = { '_' , 'A' , 'C' , '0' + index , '\0' };
204- unsigned long long tmp ;
205- acpi_status status ;
203+ int temp ;
206204
207- status = acpi_evaluate_integer (tz -> device -> handle , method , NULL , & tmp );
208- if (ACPI_FAILURE (status ))
205+ if (acpi_active_trip_temp (tz -> device , index , & temp ))
209206 return THERMAL_TEMP_INVALID ;
210207
211208 /*
@@ -215,10 +212,10 @@ static long get_active_temp(struct acpi_thermal *tz, int index)
215212 if (act > 0 ) {
216213 unsigned long long override = celsius_to_deci_kelvin (act );
217214
218- if (tmp > override )
219- tmp = override ;
215+ if (temp > override )
216+ return override ;
220217 }
221- return tmp ;
218+ return temp ;
222219}
223220
224221static void acpi_thermal_update_trip (struct acpi_thermal * tz ,
@@ -337,52 +334,47 @@ static void acpi_thermal_trips_update(struct acpi_thermal *tz, u32 event)
337334 dev_name (& adev -> dev ), event , 0 );
338335}
339336
340- static long acpi_thermal_get_critical_trip (struct acpi_thermal * tz )
337+ static int acpi_thermal_get_critical_trip (struct acpi_thermal * tz )
341338{
342- unsigned long long tmp ;
343- acpi_status status ;
339+ int temp ;
344340
345341 if (crt > 0 ) {
346- tmp = celsius_to_deci_kelvin (crt );
342+ temp = celsius_to_deci_kelvin (crt );
347343 goto set ;
348344 }
349345 if (crt == -1 ) {
350346 acpi_handle_debug (tz -> device -> handle , "Critical threshold disabled\n" );
351347 return THERMAL_TEMP_INVALID ;
352348 }
353349
354- status = acpi_evaluate_integer (tz -> device -> handle , "_CRT" , NULL , & tmp );
355- if (ACPI_FAILURE (status )) {
356- acpi_handle_debug (tz -> device -> handle , "No critical threshold\n" );
350+ if (acpi_critical_trip_temp (tz -> device , & temp ))
357351 return THERMAL_TEMP_INVALID ;
358- }
359- if (tmp <= 2732 ) {
352+
353+ if (temp <= 2732 ) {
360354 /*
361355 * Below zero (Celsius) values clearly aren't right for sure,
362356 * so discard them as invalid.
363357 */
364- pr_info (FW_BUG "Invalid critical threshold (%llu )\n" , tmp );
358+ pr_info (FW_BUG "Invalid critical threshold (%d )\n" , temp );
365359 return THERMAL_TEMP_INVALID ;
366360 }
367361
368362set :
369- acpi_handle_debug (tz -> device -> handle , "Critical threshold [%llu ]\n" , tmp );
370- return tmp ;
363+ acpi_handle_debug (tz -> device -> handle , "Critical threshold [%d ]\n" , temp );
364+ return temp ;
371365}
372366
373- static long acpi_thermal_get_hot_trip (struct acpi_thermal * tz )
367+ static int acpi_thermal_get_hot_trip (struct acpi_thermal * tz )
374368{
375- unsigned long long tmp ;
376- acpi_status status ;
369+ int temp ;
377370
378- status = acpi_evaluate_integer (tz -> device -> handle , "_HOT" , NULL , & tmp );
379- if (ACPI_FAILURE (status )) {
371+ if (acpi_hot_trip_temp (tz -> device , & temp ) || temp == THERMAL_TEMP_INVALID ) {
380372 acpi_handle_debug (tz -> device -> handle , "No hot threshold\n" );
381373 return THERMAL_TEMP_INVALID ;
382374 }
383375
384- acpi_handle_debug (tz -> device -> handle , "Hot threshold [%llu ]\n" , tmp );
385- return tmp ;
376+ acpi_handle_debug (tz -> device -> handle , "Hot threshold [%d ]\n" , temp );
377+ return temp ;
386378}
387379
388380static bool passive_trip_params_init (struct acpi_thermal * tz )
@@ -402,11 +394,17 @@ static bool passive_trip_params_init(struct acpi_thermal *tz)
402394
403395 tz -> trips .passive .tc2 = tmp ;
404396
397+ status = acpi_evaluate_integer (tz -> device -> handle , "_TFP" , NULL , & tmp );
398+ if (ACPI_SUCCESS (status )) {
399+ tz -> trips .passive .delay = tmp ;
400+ return true;
401+ }
402+
405403 status = acpi_evaluate_integer (tz -> device -> handle , "_TSP" , NULL , & tmp );
406404 if (ACPI_FAILURE (status ))
407405 return false;
408406
409- tz -> trips .passive .tsp = tmp ;
407+ tz -> trips .passive .delay = tmp * 100 ;
410408
411409 return true;
412410}
@@ -902,7 +900,7 @@ static int acpi_thermal_add(struct acpi_device *device)
902900
903901 acpi_trip = & tz -> trips .passive .trip ;
904902 if (acpi_thermal_trip_valid (acpi_trip )) {
905- passive_delay = tz -> trips .passive .tsp * 100 ;
903+ passive_delay = tz -> trips .passive .delay ;
906904
907905 trip -> type = THERMAL_TRIP_PASSIVE ;
908906 trip -> temperature = acpi_thermal_temp (tz , acpi_trip -> temp_dk );
@@ -1140,6 +1138,7 @@ static void __exit acpi_thermal_exit(void)
11401138module_init (acpi_thermal_init );
11411139module_exit (acpi_thermal_exit );
11421140
1141+ MODULE_IMPORT_NS (ACPI_THERMAL );
11431142MODULE_AUTHOR ("Paul Diefenbaugh" );
11441143MODULE_DESCRIPTION ("ACPI Thermal Zone Driver" );
11451144MODULE_LICENSE ("GPL" );
0 commit comments