Lines 91-98
static int psv;
Link Here
|
91 |
module_param(psv, int, 0644); |
91 |
module_param(psv, int, 0644); |
92 |
MODULE_PARM_DESC(psv, "Disable or override all passive trip points."); |
92 |
MODULE_PARM_DESC(psv, "Disable or override all passive trip points."); |
93 |
|
93 |
|
94 |
static struct workqueue_struct *acpi_thermal_pm_queue; |
|
|
95 |
|
96 |
static int acpi_thermal_add(struct acpi_device *device); |
94 |
static int acpi_thermal_add(struct acpi_device *device); |
97 |
static int acpi_thermal_remove(struct acpi_device *device); |
95 |
static int acpi_thermal_remove(struct acpi_device *device); |
98 |
static void acpi_thermal_notify(struct acpi_device *device, u32 event); |
96 |
static void acpi_thermal_notify(struct acpi_device *device, u32 event); |
Lines 103-117
static const struct acpi_device_id thermal_device_ids[] = {
Link Here
|
103 |
}; |
101 |
}; |
104 |
MODULE_DEVICE_TABLE(acpi, thermal_device_ids); |
102 |
MODULE_DEVICE_TABLE(acpi, thermal_device_ids); |
105 |
|
103 |
|
106 |
#ifdef CONFIG_PM_SLEEP |
|
|
107 |
static int acpi_thermal_suspend(struct device *dev); |
108 |
static int acpi_thermal_resume(struct device *dev); |
109 |
#else |
110 |
#define acpi_thermal_suspend NULL |
111 |
#define acpi_thermal_resume NULL |
112 |
#endif |
113 |
static SIMPLE_DEV_PM_OPS(acpi_thermal_pm, acpi_thermal_suspend, acpi_thermal_resume); |
114 |
|
115 |
static struct acpi_driver acpi_thermal_driver = { |
104 |
static struct acpi_driver acpi_thermal_driver = { |
116 |
.name = "thermal", |
105 |
.name = "thermal", |
117 |
.class = ACPI_THERMAL_CLASS, |
106 |
.class = ACPI_THERMAL_CLASS, |
Lines 121-127
static struct acpi_driver acpi_thermal_driver = {
Link Here
|
121 |
.remove = acpi_thermal_remove, |
110 |
.remove = acpi_thermal_remove, |
122 |
.notify = acpi_thermal_notify, |
111 |
.notify = acpi_thermal_notify, |
123 |
}, |
112 |
}, |
124 |
.drv.pm = &acpi_thermal_pm, |
|
|
125 |
}; |
113 |
}; |
126 |
|
114 |
|
127 |
struct acpi_thermal_state { |
115 |
struct acpi_thermal_state { |
Lines 191-197
struct acpi_thermal {
Link Here
|
191 |
struct thermal_zone_device *thermal_zone; |
179 |
struct thermal_zone_device *thermal_zone; |
192 |
int tz_enabled; |
180 |
int tz_enabled; |
193 |
int kelvin_offset; |
181 |
int kelvin_offset; |
194 |
struct work_struct thermal_check_work; |
|
|
195 |
}; |
182 |
}; |
196 |
|
183 |
|
197 |
/* -------------------------------------------------------------------------- |
184 |
/* -------------------------------------------------------------------------- |
Lines 1067-1079
static void acpi_thermal_guess_offset(struct acpi_thermal *tz)
Link Here
|
1067 |
tz->kelvin_offset = 2732; |
1054 |
tz->kelvin_offset = 2732; |
1068 |
} |
1055 |
} |
1069 |
|
1056 |
|
1070 |
static void acpi_thermal_check_fn(struct work_struct *work) |
|
|
1071 |
{ |
1072 |
struct acpi_thermal *tz = container_of(work, struct acpi_thermal, |
1073 |
thermal_check_work); |
1074 |
acpi_thermal_check(tz); |
1075 |
} |
1076 |
|
1077 |
static int acpi_thermal_add(struct acpi_device *device) |
1057 |
static int acpi_thermal_add(struct acpi_device *device) |
1078 |
{ |
1058 |
{ |
1079 |
int result = 0; |
1059 |
int result = 0; |
Lines 1103-1110
static int acpi_thermal_add(struct acpi_device *device)
Link Here
|
1103 |
if (result) |
1083 |
if (result) |
1104 |
goto free_memory; |
1084 |
goto free_memory; |
1105 |
|
1085 |
|
1106 |
INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); |
|
|
1107 |
|
1108 |
pr_info(PREFIX "%s [%s] (%ld C)\n", acpi_device_name(device), |
1086 |
pr_info(PREFIX "%s [%s] (%ld C)\n", acpi_device_name(device), |
1109 |
acpi_device_bid(device), KELVIN_TO_CELSIUS(tz->temperature)); |
1087 |
acpi_device_bid(device), KELVIN_TO_CELSIUS(tz->temperature)); |
1110 |
goto end; |
1088 |
goto end; |
Lines 1122-1128
static int acpi_thermal_remove(struct acpi_device *device)
Link Here
|
1122 |
if (!device || !acpi_driver_data(device)) |
1100 |
if (!device || !acpi_driver_data(device)) |
1123 |
return -EINVAL; |
1101 |
return -EINVAL; |
1124 |
|
1102 |
|
1125 |
flush_workqueue(acpi_thermal_pm_queue); |
|
|
1126 |
tz = acpi_driver_data(device); |
1103 |
tz = acpi_driver_data(device); |
1127 |
|
1104 |
|
1128 |
acpi_thermal_unregister_thermal_zone(tz); |
1105 |
acpi_thermal_unregister_thermal_zone(tz); |
Lines 1130-1179
static int acpi_thermal_remove(struct acpi_device *device)
Link Here
|
1130 |
return 0; |
1107 |
return 0; |
1131 |
} |
1108 |
} |
1132 |
|
1109 |
|
1133 |
#ifdef CONFIG_PM_SLEEP |
|
|
1134 |
static int acpi_thermal_suspend(struct device *dev) |
1135 |
{ |
1136 |
/* Make sure the previously queued thermal check work has been done */ |
1137 |
flush_workqueue(acpi_thermal_pm_queue); |
1138 |
return 0; |
1139 |
} |
1140 |
|
1141 |
static int acpi_thermal_resume(struct device *dev) |
1142 |
{ |
1143 |
struct acpi_thermal *tz; |
1144 |
int i, j, power_state, result; |
1145 |
|
1146 |
if (!dev) |
1147 |
return -EINVAL; |
1148 |
|
1149 |
tz = acpi_driver_data(to_acpi_device(dev)); |
1150 |
if (!tz) |
1151 |
return -EINVAL; |
1152 |
|
1153 |
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { |
1154 |
if (!(&tz->trips.active[i])) |
1155 |
break; |
1156 |
if (!tz->trips.active[i].flags.valid) |
1157 |
break; |
1158 |
tz->trips.active[i].flags.enabled = 1; |
1159 |
for (j = 0; j < tz->trips.active[i].devices.count; j++) { |
1160 |
result = acpi_bus_update_power( |
1161 |
tz->trips.active[i].devices.handles[j], |
1162 |
&power_state); |
1163 |
if (result || (power_state != ACPI_STATE_D0)) { |
1164 |
tz->trips.active[i].flags.enabled = 0; |
1165 |
break; |
1166 |
} |
1167 |
} |
1168 |
tz->state.active |= tz->trips.active[i].flags.enabled; |
1169 |
} |
1170 |
|
1171 |
queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); |
1172 |
|
1173 |
return AE_OK; |
1174 |
} |
1175 |
#endif |
1176 |
|
1177 |
static int thermal_act(const struct dmi_system_id *d) { |
1110 |
static int thermal_act(const struct dmi_system_id *d) { |
1178 |
|
1111 |
|
1179 |
if (act == 0) { |
1112 |
if (act == 0) { |
Lines 1260-1274
static int __init acpi_thermal_init(void)
Link Here
|
1260 |
return -ENODEV; |
1193 |
return -ENODEV; |
1261 |
} |
1194 |
} |
1262 |
|
1195 |
|
1263 |
acpi_thermal_pm_queue = create_workqueue("acpi_thermal_pm"); |
|
|
1264 |
if (!acpi_thermal_pm_queue) |
1265 |
return -ENODEV; |
1266 |
|
1267 |
result = acpi_bus_register_driver(&acpi_thermal_driver); |
1196 |
result = acpi_bus_register_driver(&acpi_thermal_driver); |
1268 |
if (result < 0) { |
1197 |
if (result < 0) |
1269 |
destroy_workqueue(acpi_thermal_pm_queue); |
|
|
1270 |
return -ENODEV; |
1198 |
return -ENODEV; |
1271 |
} |
|
|
1272 |
|
1199 |
|
1273 |
return 0; |
1200 |
return 0; |
1274 |
} |
1201 |
} |
Lines 1276-1284
static int __init acpi_thermal_init(void)
Link Here
|
1276 |
static void __exit acpi_thermal_exit(void) |
1203 |
static void __exit acpi_thermal_exit(void) |
1277 |
{ |
1204 |
{ |
1278 |
acpi_bus_unregister_driver(&acpi_thermal_driver); |
1205 |
acpi_bus_unregister_driver(&acpi_thermal_driver); |
1279 |
destroy_workqueue(acpi_thermal_pm_queue); |
|
|
1280 |
|
1281 |
return; |
1282 |
} |
1206 |
} |
1283 |
|
1207 |
|
1284 |
module_init(acpi_thermal_init); |
1208 |
module_init(acpi_thermal_init); |
1285 |
- |
|
|