drivers: power: report battery voltage in AOSP compatible format
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / thermal / backward_compatible.c
1 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2
3 #include <linux/module.h>
4 #include <linux/thermal.h>
5
6 #include "thermal_core.h"
7
8 /**
9 * backward_compatible_throttle
10 * @tz - thermal_zone_device
11 *
12 * This function update the cooler state by monitoring the current temperature and trip points
13 */
14 static int backward_compatible_throttle(struct thermal_zone_device *tz, int trip)
15 {
16 long trip_temp;
17 struct thermal_instance *instance;
18
19 if (trip == THERMAL_TRIPS_NONE) {
20 trip_temp = tz->forced_passive;
21 } else {
22 tz->ops->get_trip_temp(tz, trip, &trip_temp);
23 }
24
25 /* mutex_lock(&tz->lock); */
26
27 list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
28 if (instance->trip != trip)
29 continue;
30
31 if (tz->temperature >= trip_temp)
32 instance->target = 1;
33 else
34 instance->target = 0;
35 instance->cdev->updated = false;
36 thermal_cdev_update(instance->cdev);
37 }
38
39 /* mutex_unlock(&tz->lock); */
40
41 return 0;
42 }
43
44 static struct thermal_governor thermal_gov_backward_compatible = {
45 .name = "backward_compatible",
46 .throttle = backward_compatible_throttle,
47 /* .owner = THIS_MODULE, */
48 };
49
50 static int __init thermal_gov_backward_compatible_init(void)
51 {
52 return thermal_register_governor(&thermal_gov_backward_compatible);
53 }
54
55 static void __exit thermal_gov_backward_compatible_exit(void)
56 {
57 thermal_unregister_governor(&thermal_gov_backward_compatible);
58 }
59
60 /* This should load after thermal framework */
61 fs_initcall(thermal_gov_backward_compatible_init);
62 module_exit(thermal_gov_backward_compatible_exit);
63
64 MODULE_AUTHOR("Weiyi Lu");
65 MODULE_DESCRIPTION("A backward compatible Thermal governor");
66 MODULE_LICENSE("GPL");