devfreq: convert devfreq_class to use dev_groups

The dev_attrs field of struct class is going away soon, dev_groups
should be used instead.  This converts the devfreq_class code to use the
correct field.

Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Greg Kroah-Hartman 2013-07-24 15:05:09 -07:00
parent 567b21e973
commit a93d6b0a87
1 changed files with 43 additions and 33 deletions

View File

@ -703,7 +703,7 @@ err_out:
} }
EXPORT_SYMBOL(devfreq_remove_governor); EXPORT_SYMBOL(devfreq_remove_governor);
static ssize_t show_governor(struct device *dev, static ssize_t governor_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
if (!to_devfreq(dev)->governor) if (!to_devfreq(dev)->governor)
@ -712,7 +712,7 @@ static ssize_t show_governor(struct device *dev,
return sprintf(buf, "%s\n", to_devfreq(dev)->governor->name); return sprintf(buf, "%s\n", to_devfreq(dev)->governor->name);
} }
static ssize_t store_governor(struct device *dev, struct device_attribute *attr, static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct devfreq *df = to_devfreq(dev); struct devfreq *df = to_devfreq(dev);
@ -754,7 +754,9 @@ out:
ret = count; ret = count;
return ret; return ret;
} }
static ssize_t show_available_governors(struct device *d, static DEVICE_ATTR_RW(governor);
static ssize_t available_governors_show(struct device *d,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
@ -775,9 +777,10 @@ static ssize_t show_available_governors(struct device *d,
return count; return count;
} }
static DEVICE_ATTR_RO(available_governors);
static ssize_t show_freq(struct device *dev, static ssize_t cur_freq_show(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr, char *buf) char *buf)
{ {
unsigned long freq; unsigned long freq;
struct devfreq *devfreq = to_devfreq(dev); struct devfreq *devfreq = to_devfreq(dev);
@ -788,20 +791,22 @@ static ssize_t show_freq(struct device *dev,
return sprintf(buf, "%lu\n", devfreq->previous_freq); return sprintf(buf, "%lu\n", devfreq->previous_freq);
} }
static DEVICE_ATTR_RO(cur_freq);
static ssize_t show_target_freq(struct device *dev, static ssize_t target_freq_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
return sprintf(buf, "%lu\n", to_devfreq(dev)->previous_freq); return sprintf(buf, "%lu\n", to_devfreq(dev)->previous_freq);
} }
static DEVICE_ATTR_RO(target_freq);
static ssize_t show_polling_interval(struct device *dev, static ssize_t polling_interval_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
return sprintf(buf, "%d\n", to_devfreq(dev)->profile->polling_ms); return sprintf(buf, "%d\n", to_devfreq(dev)->profile->polling_ms);
} }
static ssize_t store_polling_interval(struct device *dev, static ssize_t polling_interval_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
@ -821,8 +826,9 @@ static ssize_t store_polling_interval(struct device *dev,
return ret; return ret;
} }
static DEVICE_ATTR_RW(polling_interval);
static ssize_t store_min_freq(struct device *dev, struct device_attribute *attr, static ssize_t min_freq_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct devfreq *df = to_devfreq(dev); struct devfreq *df = to_devfreq(dev);
@ -849,13 +855,13 @@ unlock:
return ret; return ret;
} }
static ssize_t show_min_freq(struct device *dev, struct device_attribute *attr, static ssize_t min_freq_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%lu\n", to_devfreq(dev)->min_freq); return sprintf(buf, "%lu\n", to_devfreq(dev)->min_freq);
} }
static ssize_t store_max_freq(struct device *dev, struct device_attribute *attr, static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct devfreq *df = to_devfreq(dev); struct devfreq *df = to_devfreq(dev);
@ -881,14 +887,16 @@ unlock:
mutex_unlock(&df->lock); mutex_unlock(&df->lock);
return ret; return ret;
} }
static DEVICE_ATTR_RW(min_freq);
static ssize_t show_max_freq(struct device *dev, struct device_attribute *attr, static ssize_t max_freq_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%lu\n", to_devfreq(dev)->max_freq); return sprintf(buf, "%lu\n", to_devfreq(dev)->max_freq);
} }
static DEVICE_ATTR_RW(max_freq);
static ssize_t show_available_freqs(struct device *d, static ssize_t available_frequencies_show(struct device *d,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
@ -918,9 +926,10 @@ static ssize_t show_available_freqs(struct device *d,
return count; return count;
} }
static DEVICE_ATTR_RO(available_frequencies);
static ssize_t show_trans_table(struct device *dev, struct device_attribute *attr, static ssize_t trans_stat_show(struct device *dev,
char *buf) struct device_attribute *attr, char *buf)
{ {
struct devfreq *devfreq = to_devfreq(dev); struct devfreq *devfreq = to_devfreq(dev);
ssize_t len; ssize_t len;
@ -959,20 +968,21 @@ static ssize_t show_trans_table(struct device *dev, struct device_attribute *att
devfreq->total_trans); devfreq->total_trans);
return len; return len;
} }
static DEVICE_ATTR_RO(trans_stat);
static struct device_attribute devfreq_attrs[] = { static struct attribute *devfreq_attrs[] = {
__ATTR(governor, S_IRUGO | S_IWUSR, show_governor, store_governor), &dev_attr_governor.attr,
__ATTR(available_governors, S_IRUGO, show_available_governors, NULL), &dev_attr_available_governors.attr,
__ATTR(cur_freq, S_IRUGO, show_freq, NULL), &dev_attr_cur_freq.attr,
__ATTR(available_frequencies, S_IRUGO, show_available_freqs, NULL), &dev_attr_available_frequencies.attr,
__ATTR(target_freq, S_IRUGO, show_target_freq, NULL), &dev_attr_target_freq.attr,
__ATTR(polling_interval, S_IRUGO | S_IWUSR, show_polling_interval, &dev_attr_polling_interval.attr,
store_polling_interval), &dev_attr_min_freq.attr,
__ATTR(min_freq, S_IRUGO | S_IWUSR, show_min_freq, store_min_freq), &dev_attr_max_freq.attr,
__ATTR(max_freq, S_IRUGO | S_IWUSR, show_max_freq, store_max_freq), &dev_attr_trans_stat.attr,
__ATTR(trans_stat, S_IRUGO, show_trans_table, NULL), NULL,
{ },
}; };
ATTRIBUTE_GROUPS(devfreq);
static int __init devfreq_init(void) static int __init devfreq_init(void)
{ {
@ -988,7 +998,7 @@ static int __init devfreq_init(void)
pr_err("%s: couldn't create workqueue\n", __FILE__); pr_err("%s: couldn't create workqueue\n", __FILE__);
return PTR_ERR(devfreq_wq); return PTR_ERR(devfreq_wq);
} }
devfreq_class->dev_attrs = devfreq_attrs; devfreq_class->dev_groups = devfreq_groups;
return 0; return 0;
} }