Skip to content

Commit 92a9907

Browse files
committed
Sync the vendored helper with dell-bios-fan-control
Picks up the red zone fix, the x86-64 guard and the reordered status line from the upstream repo the helper is copied from.
1 parent 0d2d364 commit 92a9907

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

helper/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/make -f
22

3-
CFLAGS ?= -O2 -Wall -Wextra
3+
# -mno-red-zone: the inline SMM asm pushes to the stack, which would
4+
# otherwise land in the 128-byte red zone the ABI lets gcc use
5+
CFLAGS ?= -O2 -Wall -Wextra -mno-red-zone
46

57
all: dell-bios-fan-control
68

helper/dell-bios-fan-control.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* dell-bios-fan-control
3-
* user space utility to set control of fans by bios on Dell 9560 Laptops.
3+
* user space utility to enable or disable BIOS fan control on Dell machines.
44
*
55
* SMM Management code from i8k. See file drivers/char/i8k.c at Linux kernel.
66
*
@@ -28,6 +28,10 @@
2828
#include <unistd.h>
2929
#include <sys/io.h>
3030

31+
#if !defined(__x86_64__)
32+
#error "x86-64 only: the SMM call goes out through ports 0xb2 and 0x84"
33+
#endif
34+
3135
/*
3236
*
3337
* Most of the code was taken from https://github.com/clopez/dellfan
@@ -131,18 +135,16 @@ int main(int argc, char **argv) {
131135

132136
init_ioperm();
133137

134-
if (enable) {
138+
if (enable)
135139
rc = send(ENABLE_BIOS_METHOD2, 0);
136-
printf ("BIOS CONTROL ENABLED\n");
137-
}
138-
else {
140+
else
139141
rc = send(DISABLE_BIOS_METHOD2, 0);
140-
printf ("BIOS CONTROL DISABLED\n");
141-
}
142142

143143
/* The error heuristic can misfire on some BIOSes, so warn only */
144144
if (rc != 0)
145145
fprintf(stderr, "warning: SMM call may have failed\n");
146146

147+
printf ("BIOS CONTROL %s\n", enable ? "ENABLED" : "DISABLED");
148+
147149
return 0;
148150
}

0 commit comments

Comments
 (0)