From 0f59d9af056f0344e9acd941c1ab5a1a54a3a3d9 Mon Sep 17 00:00:00 2001 From: Nishanth Menon Date: Thu, 25 Oct 2012 19:48:59 -0500 Subject: [PATCH] --- yaml --- r: 336775 b: refs/heads/master c: d287de855f97c56ca7146ff627e652bd7cd64f3f h: refs/heads/master i: 336773: 57db09e75b4324a46d0f3b92165fb4f0e617d7ff 336771: 26bf6f3f0404aecc693f3057fe0197f20b0e42f1 336767: 2bedc832e08c4d723644e56a424ddf68d410d97f v: v3 --- [refs] | 2 +- .../ABI/testing/sysfs-class-devfreq | 9 ++++++ trunk/drivers/devfreq/devfreq.c | 32 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index cb13caa275ed..becd1a7bc545 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: e09651fcc295a7dc802f38d9494f5b860dd90bca +refs/heads/master: d287de855f97c56ca7146ff627e652bd7cd64f3f diff --git a/trunk/Documentation/ABI/testing/sysfs-class-devfreq b/trunk/Documentation/ABI/testing/sysfs-class-devfreq index e6cf08e6734d..e672ccb02e7f 100644 --- a/trunk/Documentation/ABI/testing/sysfs-class-devfreq +++ b/trunk/Documentation/ABI/testing/sysfs-class-devfreq @@ -51,3 +51,12 @@ Description: The /sys/class/devfreq/.../userspace/set_freq shows and sets the requested frequency for the devfreq object if userspace governor is in effect. + +What: /sys/class/devfreq/.../available_frequencies +Date: October 2012 +Contact: Nishanth Menon +Description: + The /sys/class/devfreq/.../available_frequencies shows + the available frequencies of the corresponding devfreq object. + This is a snapshot of available frequencies and not limited + by the min/max frequency restrictions. diff --git a/trunk/drivers/devfreq/devfreq.c b/trunk/drivers/devfreq/devfreq.c index 789af4ff5c9c..c44e562bdfe0 100644 --- a/trunk/drivers/devfreq/devfreq.c +++ b/trunk/drivers/devfreq/devfreq.c @@ -570,9 +570,41 @@ static ssize_t show_max_freq(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%lu\n", to_devfreq(dev)->max_freq); } +static ssize_t show_available_freqs(struct device *d, + struct device_attribute *attr, + char *buf) +{ + struct devfreq *df = to_devfreq(d); + struct device *dev = df->dev.parent; + struct opp *opp; + ssize_t count = 0; + unsigned long freq = 0; + + rcu_read_lock(); + do { + opp = opp_find_freq_ceil(dev, &freq); + if (IS_ERR(opp)) + break; + + count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), + "%lu ", freq); + freq++; + } while (1); + rcu_read_unlock(); + + /* Truncate the trailing space */ + if (count) + count--; + + count += sprintf(&buf[count], "\n"); + + return count; +} + static struct device_attribute devfreq_attrs[] = { __ATTR(governor, S_IRUGO, show_governor, NULL), __ATTR(cur_freq, S_IRUGO, show_freq, NULL), + __ATTR(available_frequencies, S_IRUGO, show_available_freqs, NULL), __ATTR(target_freq, S_IRUGO, show_target_freq, NULL), __ATTR(polling_interval, S_IRUGO | S_IWUSR, show_polling_interval, store_polling_interval),