const char *ethernet_tunable::toggle_script(void) { int good; good = good_bad(); if (good != TUNE_GOOD) { return toggle_good; } return NULL; }
const char *i2c_tunable::toggle_script(void) { int good; good = good_bad(); if (good == TUNE_GOOD) { return toggle_bad; } return toggle_good; }
void i2c_tunable::toggle(void) { int good; good = good_bad(); if (good == TUNE_GOOD) { write_sysfs(i2c_path, "on"); return; } write_sysfs(i2c_path, "auto"); }
void wifi_tunable::toggle(void) { int good; good = good_bad(); if (good == TUNE_GOOD) { set_wifi_power_saving(iface, 0); return; } set_wifi_power_saving(iface, 1); }
const char *sysfs_tunable::toggle_script(void) { int good; good = good_bad(); if (good == TUNE_GOOD) { if (strlen(bad_value) > 0) return toggle_bad; return NULL; } return toggle_good; }
void sysfs_tunable::toggle(void) { int good; good = good_bad(); if (good == TUNE_GOOD) { if (strlen(bad_value) > 0) write_sysfs(sysfs_path, bad_value); return; } write_sysfs(sysfs_path, target_value); }
const char *cpufreq_tunable::toggle_script(void) { DIR *dir; struct dirent *dirent; char filename[PATH_MAX]; char tmp[4096]; struct stat statbuf; int good; good = good_bad(); strcpy(toggle_good, "/sbin/modprobe cpufreq_ondemand > /dev/null 2>&1\n"); if (good == TUNE_GOOD) { dir = opendir("/sys/devices/system/cpu"); if (!dir) return NULL; while ((dirent = readdir(dir))) { if (strncmp(dirent->d_name, "cpu", 3) != 0 || !isdigit(dirent->d_name[3])) continue; sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_governor", dirent->d_name); if (stat(filename, &statbuf) == -1) continue; sprintf(tmp, "echo '%s' > '%s';\n", original, filename); strcat(toggle_good, tmp); } closedir(dir); return toggle_good; } dir = opendir("/sys/devices/system/cpu"); if (!dir) return NULL; while ((dirent = readdir(dir))) { if (strncmp(dirent->d_name, "cpu", 3) != 0 || !isdigit(dirent->d_name[3])) continue; sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_governor", dirent->d_name); if (stat(filename, &statbuf) == -1) continue; sprintf(tmp, "echo 'ondemand' > '%s';\n", filename); strcat(toggle_good, tmp); } closedir(dir); return toggle_good; }
void cpufreq_tunable::toggle(void) { DIR *dir; struct dirent *dirent; FILE *file; char filename[PATH_MAX]; int good; good = good_bad(); system("/sbin/modprobe cpufreq_ondemand > /dev/null 2>&1"); if (good == TUNE_GOOD) { dir = opendir("/sys/devices/system/cpu"); if (!dir) return; while ((dirent = readdir(dir))) { if (strncmp(dirent->d_name, "cpu", 3) != 0 || !isdigit(dirent->d_name[3])) continue; sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_governor", dirent->d_name); file = fopen(filename, "w"); if (!file) continue; fprintf(file, "%s\n", original); fclose(file); } closedir(dir); return; } dir = opendir("/sys/devices/system/cpu"); if (!dir) return; while ((dirent = readdir(dir))) { if (strncmp(dirent->d_name, "cpu", 3) != 0 || !isdigit(dirent->d_name[3])) continue; sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_governor", dirent->d_name); file = fopen(filename, "w"); if (!file) continue; fprintf(file, "ondemand\n"); fclose(file); } closedir(dir); }
void sysfs_tunable::toggle(void) { int good; good = good_bad(); if (good == TUNE_GOOD) { if (strlen(bad_value) > 0) write_sysfs(sysfs_path, bad_value); return; } if (strncmp(target_value, ">=", 2) == 0) { write_sysfs(sysfs_path, target_value + 2); } else { write_sysfs(sysfs_path, target_value); } }