static ssize_t store_current_governor()

in sysfs.c [76:99]


static ssize_t store_current_governor(struct device *dev,
				      struct device_attribute *attr,
				      const char *buf, size_t count)
{
	char gov_name[CPUIDLE_NAME_LEN + 1];
	int ret;
	struct cpuidle_governor *gov;

	ret = sscanf(buf, "%" __stringify(CPUIDLE_NAME_LEN) "s", gov_name);
	if (ret != 1)
		return -EINVAL;

	mutex_lock(&cpuidle_lock);
	ret = -EINVAL;
	list_for_each_entry(gov, &cpuidle_governors, governor_list) {
		if (!strncmp(gov->name, gov_name, CPUIDLE_NAME_LEN)) {
			ret = cpuidle_switch_governor(gov);
			break;
		}
	}
	mutex_unlock(&cpuidle_lock);

	return ret ? ret : count;
}