diff options
-rw-r--r-- | Documentation/hwmon/hpfall.c | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/Documentation/hwmon/hpfall.c b/Documentation/hwmon/hpfall.c index bbea1ccfd46a..d2f6711b468b 100644 --- a/Documentation/hwmon/hpfall.c +++ b/Documentation/hwmon/hpfall.c | |||
@@ -57,45 +57,43 @@ void ignore_me(void) | |||
57 | { | 57 | { |
58 | protect(0); | 58 | protect(0); |
59 | set_led(0); | 59 | set_led(0); |
60 | |||
61 | } | 60 | } |
62 | 61 | ||
63 | int main(int argc, char* argv[]) | 62 | int main(int argc, char *argv[]) |
64 | { | 63 | { |
65 | int fd, ret; | 64 | int fd, ret; |
66 | 65 | ||
67 | fd = open("/dev/freefall", O_RDONLY); | 66 | fd = open("/dev/freefall", O_RDONLY); |
68 | if (fd < 0) { | 67 | if (fd < 0) { |
69 | perror("open"); | 68 | perror("open"); |
70 | return EXIT_FAILURE; | 69 | return EXIT_FAILURE; |
71 | } | 70 | } |
72 | 71 | ||
73 | signal(SIGALRM, ignore_me); | 72 | signal(SIGALRM, ignore_me); |
74 | 73 | ||
75 | for (;;) { | 74 | for (;;) { |
76 | unsigned char count; | 75 | unsigned char count; |
77 | 76 | ||
78 | ret = read(fd, &count, sizeof(count)); | 77 | ret = read(fd, &count, sizeof(count)); |
79 | alarm(0); | 78 | alarm(0); |
80 | if ((ret == -1) && (errno == EINTR)) { | 79 | if ((ret == -1) && (errno == EINTR)) { |
81 | /* Alarm expired, time to unpark the heads */ | 80 | /* Alarm expired, time to unpark the heads */ |
82 | continue; | 81 | continue; |
83 | } | 82 | } |
84 | 83 | ||
85 | if (ret != sizeof(count)) { | 84 | if (ret != sizeof(count)) { |
86 | perror("read"); | 85 | perror("read"); |
87 | break; | 86 | break; |
88 | } | 87 | } |
89 | 88 | ||
90 | protect(21); | 89 | protect(21); |
91 | set_led(1); | 90 | set_led(1); |
92 | if (1 || on_ac() || lid_open()) { | 91 | if (1 || on_ac() || lid_open()) |
93 | alarm(2); | 92 | alarm(2); |
94 | } else { | 93 | else |
95 | alarm(20); | 94 | alarm(20); |
96 | } | 95 | } |
97 | } | ||
98 | 96 | ||
99 | close(fd); | 97 | close(fd); |
100 | return EXIT_SUCCESS; | 98 | return EXIT_SUCCESS; |
101 | } | 99 | } |