diff options
| author | Rafael J. Wysocki <rjw@sisk.pl> | 2012-01-25 00:02:08 +0100 | 
|---|---|---|
| committer | Rafael J. Wysocki <rjw@sisk.pl> | 2012-01-25 00:02:08 +0100 | 
| commit | e4c9d8efe6bdc844071d68960dfa2003c5cf6449 (patch) | |
| tree | 3c3018f75fbfde7a8cc5247e0097b5046f8fa153 /drivers/devfreq/devfreq.c | |
| parent | d2346963bfcbb9a8ee783ca3c3b3bdd7448ec9d5 (diff) | |
| parent | 6530b9dea1b7f33eaf79ba625e3a99f2455f3eb1 (diff) | |
| download | olio-linux-3.10-e4c9d8efe6bdc844071d68960dfa2003c5cf6449.tar.xz olio-linux-3.10-e4c9d8efe6bdc844071d68960dfa2003c5cf6449.zip  | |
Merge branch 'devfreq-for-next' of git://git.infradead.org/users/kmpark/linux-samsung into pm-devfreq
* 'devfreq-for-next' of git://git.infradead.org/users/kmpark/linux-samsung:
  PM / devfreq: add min/max_freq limit requested by users.
  PM / devfreq: fixed syntax errors.
  devfreq: Remove MODULE_ALIAS for exynos4 busfreq driver
  devfreq: exynos4_bus: Use dev_get_drvdata at appropriate places
Diffstat (limited to 'drivers/devfreq/devfreq.c')
| -rw-r--r-- | drivers/devfreq/devfreq.c | 70 | 
1 files changed, 70 insertions, 0 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index c189b82f5ec..a129a7b6bfd 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -501,12 +501,82 @@ static ssize_t show_central_polling(struct device *dev,  		       !to_devfreq(dev)->governor->no_central_polling);  } +static ssize_t store_min_freq(struct device *dev, struct device_attribute *attr, +			      const char *buf, size_t count) +{ +	struct devfreq *df = to_devfreq(dev); +	unsigned long value; +	int ret; +	unsigned long max; + +	ret = sscanf(buf, "%lu", &value); +	if (ret != 1) +		goto out; + +	mutex_lock(&df->lock); +	max = df->max_freq; +	if (value && max && value > max) { +		ret = -EINVAL; +		goto unlock; +	} + +	df->min_freq = value; +	update_devfreq(df); +	ret = count; +unlock: +	mutex_unlock(&df->lock); +out: +	return ret; +} + +static ssize_t show_min_freq(struct device *dev, struct device_attribute *attr, +			     char *buf) +{ +	return sprintf(buf, "%lu\n", to_devfreq(dev)->min_freq); +} + +static ssize_t store_max_freq(struct device *dev, struct device_attribute *attr, +			      const char *buf, size_t count) +{ +	struct devfreq *df = to_devfreq(dev); +	unsigned long value; +	int ret; +	unsigned long min; + +	ret = sscanf(buf, "%lu", &value); +	if (ret != 1) +		goto out; + +	mutex_lock(&df->lock); +	min = df->min_freq; +	if (value && min && value < min) { +		ret = -EINVAL; +		goto unlock; +	} + +	df->max_freq = value; +	update_devfreq(df); +	ret = count; +unlock: +	mutex_unlock(&df->lock); +out: +	return ret; +} + +static ssize_t show_max_freq(struct device *dev, struct device_attribute *attr, +			     char *buf) +{ +	return sprintf(buf, "%lu\n", to_devfreq(dev)->max_freq); +} +  static struct device_attribute devfreq_attrs[] = {  	__ATTR(governor, S_IRUGO, show_governor, NULL),  	__ATTR(cur_freq, S_IRUGO, show_freq, NULL),  	__ATTR(central_polling, S_IRUGO, show_central_polling, NULL),  	__ATTR(polling_interval, S_IRUGO | S_IWUSR, show_polling_interval,  	       store_polling_interval), +	__ATTR(min_freq, S_IRUGO | S_IWUSR, show_min_freq, store_min_freq), +	__ATTR(max_freq, S_IRUGO | S_IWUSR, show_max_freq, store_max_freq),  	{ },  };  |