1 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3 #include <linux/module.h>
4 #include <linux/thermal.h>
6 #include "thermal_core.h"
9 * backward_compatible_throttle
10 * @tz - thermal_zone_device
12 * This function update the cooler state by monitoring the current temperature and trip points
14 static int backward_compatible_throttle(struct thermal_zone_device
*tz
, int trip
)
17 struct thermal_instance
*instance
;
19 if (trip
== THERMAL_TRIPS_NONE
) {
20 trip_temp
= tz
->forced_passive
;
22 tz
->ops
->get_trip_temp(tz
, trip
, &trip_temp
);
25 /* mutex_lock(&tz->lock); */
27 list_for_each_entry(instance
, &tz
->thermal_instances
, tz_node
) {
28 if (instance
->trip
!= trip
)
31 if (tz
->temperature
>= trip_temp
)
35 instance
->cdev
->updated
= false;
36 thermal_cdev_update(instance
->cdev
);
39 /* mutex_unlock(&tz->lock); */
44 static struct thermal_governor thermal_gov_backward_compatible
= {
45 .name
= "backward_compatible",
46 .throttle
= backward_compatible_throttle
,
47 /* .owner = THIS_MODULE, */
50 static int __init
thermal_gov_backward_compatible_init(void)
52 return thermal_register_governor(&thermal_gov_backward_compatible
);
55 static void __exit
thermal_gov_backward_compatible_exit(void)
57 thermal_unregister_governor(&thermal_gov_backward_compatible
);
60 /* This should load after thermal framework */
61 fs_initcall(thermal_gov_backward_compatible_init
);
62 module_exit(thermal_gov_backward_compatible_exit
);
64 MODULE_AUTHOR("Weiyi Lu");
65 MODULE_DESCRIPTION("A backward compatible Thermal governor");
66 MODULE_LICENSE("GPL");