Skip to content

Commit

Permalink
Fixes issue SkyLandTW#5 (High system load)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cotix committed Apr 22, 2016
1 parent 987593c commit 9cae7aa
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/clevo-indicator.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ static int main_ec_worker(void)
{
setuid(0);
system("modprobe ec_sys");
FILE* io_fd = fopen("/sys/kernel/debug/ec/ec0/io", "r");
if (io_fd <= 0)
{
printf("unable to read EC from sysfs: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
while (share_info->exit == 0)
{
// check parent
Expand All @@ -293,14 +299,9 @@ static int main_ec_worker(void)
share_info->manual_prev_fan_duty = new_fan_duty;
}
// read EC
int io_fd = open("/sys/kernel/debug/ec/ec0/io", O_RDONLY, 0);
if (io_fd < 0)
{
printf("unable to read EC from sysfs: %s\n", strerror(errno));
exit (EXIT_FAILURE);
}
rewind(io_fd);
unsigned char buf[EC_REG_SIZE];
ssize_t len = read(io_fd, buf, EC_REG_SIZE);
ssize_t len = fread(buf, 1, EC_REG_SIZE, io_fd);
switch (len)
{
case -1:
Expand All @@ -320,7 +321,6 @@ static int main_ec_worker(void)
default:
printf("wrong EC size from sysfs: %ld\n", len);
}
close(io_fd);
// auto EC
if (share_info->auto_duty == 1)
{
Expand All @@ -335,9 +335,9 @@ static int main_ec_worker(void)
share_info->auto_duty_val = next_duty;
}
}
//
usleep(500);
usleep(500000);
}
fclose(io_fd);
printf("worker quit\n");
return EXIT_SUCCESS;
}
Expand Down

0 comments on commit 9cae7aa

Please sign in to comment.