tangled
alpha
login
or
join now
tjh.dev
/
kernel
1
fork
atom
Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1
fork
atom
overview
issues
pulls
pipelines
Pull thermal into release branch
Len Brown
19 years ago
f697b677
de560374
+2
-102
1 changed file
expand all
collapse all
unified
split
drivers
acpi
thermal.c
+2
-102
drivers/acpi/thermal.c
reviewed
···
59
59
#define ACPI_THERMAL_NOTIFY_CRITICAL 0xF0
60
60
#define ACPI_THERMAL_NOTIFY_HOT 0xF1
61
61
#define ACPI_THERMAL_MODE_ACTIVE 0x00
62
62
-
#define ACPI_THERMAL_MODE_PASSIVE 0x01
63
63
-
#define ACPI_THERMAL_MODE_CRITICAL 0xff
64
62
#define ACPI_THERMAL_PATH_POWEROFF "/sbin/poweroff"
65
63
66
64
#define ACPI_THERMAL_MAX_ACTIVE 10
···
84
86
static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file);
85
87
static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file);
86
88
static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file);
87
87
-
static ssize_t acpi_thermal_write_trip_points(struct file *,
88
88
-
const char __user *, size_t,
89
89
-
loff_t *);
90
89
static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file);
91
90
static ssize_t acpi_thermal_write_cooling_mode(struct file *,
92
91
const char __user *, size_t,
···
162
167
unsigned long temperature;
163
168
unsigned long last_temperature;
164
169
unsigned long polling_frequency;
165
165
-
u8 cooling_mode;
166
170
volatile u8 zombie;
167
171
struct acpi_thermal_flags flags;
168
172
struct acpi_thermal_state state;
···
187
193
static const struct file_operations acpi_thermal_trip_fops = {
188
194
.open = acpi_thermal_trip_open_fs,
189
195
.read = seq_read,
190
190
-
.write = acpi_thermal_write_trip_points,
191
196
.llseek = seq_lseek,
192
197
.release = single_release,
193
198
};
···
289
296
status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
290
297
if (ACPI_FAILURE(status))
291
298
return -ENODEV;
292
292
-
293
293
-
tz->cooling_mode = mode;
294
294
-
295
295
-
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n",
296
296
-
mode ? "passive" : "active"));
297
299
298
300
return 0;
299
301
}
···
877
889
return single_open(file, acpi_thermal_trip_seq_show, PDE(inode)->data);
878
890
}
879
891
880
880
-
static ssize_t
881
881
-
acpi_thermal_write_trip_points(struct file *file,
882
882
-
const char __user * buffer,
883
883
-
size_t count, loff_t * ppos)
884
884
-
{
885
885
-
struct seq_file *m = file->private_data;
886
886
-
struct acpi_thermal *tz = m->private;
887
887
-
888
888
-
char *limit_string;
889
889
-
int num, critical, hot, passive;
890
890
-
int *active;
891
891
-
int i = 0;
892
892
-
893
893
-
894
894
-
limit_string = kzalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL);
895
895
-
if (!limit_string)
896
896
-
return -ENOMEM;
897
897
-
898
898
-
active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL);
899
899
-
if (!active) {
900
900
-
kfree(limit_string);
901
901
-
return -ENOMEM;
902
902
-
}
903
903
-
904
904
-
if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) {
905
905
-
count = -EINVAL;
906
906
-
goto end;
907
907
-
}
908
908
-
909
909
-
if (copy_from_user(limit_string, buffer, count)) {
910
910
-
count = -EFAULT;
911
911
-
goto end;
912
912
-
}
913
913
-
914
914
-
limit_string[count] = '\0';
915
915
-
916
916
-
num = sscanf(limit_string, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d",
917
917
-
&critical, &hot, &passive,
918
918
-
&active[0], &active[1], &active[2], &active[3], &active[4],
919
919
-
&active[5], &active[6], &active[7], &active[8],
920
920
-
&active[9]);
921
921
-
if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) {
922
922
-
count = -EINVAL;
923
923
-
goto end;
924
924
-
}
925
925
-
926
926
-
tz->trips.critical.temperature = CELSIUS_TO_KELVIN(critical);
927
927
-
tz->trips.hot.temperature = CELSIUS_TO_KELVIN(hot);
928
928
-
tz->trips.passive.temperature = CELSIUS_TO_KELVIN(passive);
929
929
-
for (i = 0; i < num - 3; i++) {
930
930
-
if (!(tz->trips.active[i].flags.valid))
931
931
-
break;
932
932
-
tz->trips.active[i].temperature = CELSIUS_TO_KELVIN(active[i]);
933
933
-
}
934
934
-
935
935
-
end:
936
936
-
kfree(active);
937
937
-
kfree(limit_string);
938
938
-
return count;
939
939
-
}
940
940
-
941
892
static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
942
893
{
943
894
struct acpi_thermal *tz = seq->private;
···
885
958
if (!tz)
886
959
goto end;
887
960
888
888
-
if (!tz->flags.cooling_mode) {
961
961
+
if (!tz->flags.cooling_mode)
889
962
seq_puts(seq, "<setting not supported>\n");
890
890
-
}
891
891
-
892
892
-
if (tz->cooling_mode == ACPI_THERMAL_MODE_CRITICAL)
893
893
-
seq_printf(seq, "cooling mode: critical\n");
894
963
else
895
895
-
seq_printf(seq, "cooling mode: %s\n",
896
896
-
tz->cooling_mode ? "passive" : "active");
964
964
+
seq_puts(seq, "0 - Active; 1 - Passive\n");
897
965
898
966
end:
899
967
return 0;
···
1145
1223
result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
1146
1224
if (!result)
1147
1225
tz->flags.cooling_mode = 1;
1148
1148
-
else {
1149
1149
-
/* Oh,we have not _SCP method.
1150
1150
-
Generally show cooling_mode by _ACx, _PSV,spec 12.2 */
1151
1151
-
tz->flags.cooling_mode = 0;
1152
1152
-
if (tz->trips.active[0].flags.valid
1153
1153
-
&& tz->trips.passive.flags.valid) {
1154
1154
-
if (tz->trips.passive.temperature >
1155
1155
-
tz->trips.active[0].temperature)
1156
1156
-
tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE;
1157
1157
-
else
1158
1158
-
tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE;
1159
1159
-
} else if (!tz->trips.active[0].flags.valid
1160
1160
-
&& tz->trips.passive.flags.valid) {
1161
1161
-
tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE;
1162
1162
-
} else if (tz->trips.active[0].flags.valid
1163
1163
-
&& !tz->trips.passive.flags.valid) {
1164
1164
-
tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE;
1165
1165
-
} else {
1166
1166
-
/* _ACx and _PSV are optional, but _CRT is required */
1167
1167
-
tz->cooling_mode = ACPI_THERMAL_MODE_CRITICAL;
1168
1168
-
}
1169
1169
-
}
1170
1226
1171
1227
/* Get default polling frequency [_TZP] (optional) */
1172
1228
if (tzp)