コード例 #1
0
ファイル: ethernet.cpp プロジェクト: RelativePrime/powertop
const char *ethernet_tunable::toggle_script(void)
{
	int good;
	good = good_bad();

	if (good != TUNE_GOOD) {
		return toggle_good;
	}

	return NULL;
}
コード例 #2
0
const char *i2c_tunable::toggle_script(void)
{
	int good;
	good = good_bad();

	if (good == TUNE_GOOD) {
		return toggle_bad;
	}

	return toggle_good;
}
コード例 #3
0
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");
}
コード例 #4
0
ファイル: wifi.cpp プロジェクト: AllenDou/powertop
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);
}
コード例 #5
0
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;
}
コード例 #6
0
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);
}
コード例 #7
0
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;
}
コード例 #8
0
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);
}
コード例 #9
0
ファイル: tuningsysfs.cpp プロジェクト: vincenthz/powertop
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);
	}
}