diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-24 18:05:09 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-20 00:22:34 -0400 |
commit | a93d6b0a879718a1a08553935744b0d5c58354c0 (patch) | |
tree | 45d8666754888538b912a184a7300bda21843862 /drivers/devfreq | |
parent | 567b21e973ccf5b0d13776e408d7c67099749eb8 (diff) |
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>
Diffstat (limited to 'drivers/devfreq')
-rw-r--r-- | drivers/devfreq/devfreq.c | 78 |
1 files changed, 44 insertions, 34 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index e94e619fe050..c99c00d35d34 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c | |||
@@ -703,7 +703,7 @@ err_out: | |||
703 | } | 703 | } |
704 | EXPORT_SYMBOL(devfreq_remove_governor); | 704 | EXPORT_SYMBOL(devfreq_remove_governor); |
705 | 705 | ||
706 | static ssize_t show_governor(struct device *dev, | 706 | static ssize_t governor_show(struct device *dev, |
707 | struct device_attribute *attr, char *buf) | 707 | struct device_attribute *attr, char *buf) |
708 | { | 708 | { |
709 | if (!to_devfreq(dev)->governor) | 709 | if (!to_devfreq(dev)->governor) |
@@ -712,7 +712,7 @@ static ssize_t show_governor(struct device *dev, | |||
712 | return sprintf(buf, "%s\n", to_devfreq(dev)->governor->name); | 712 | return sprintf(buf, "%s\n", to_devfreq(dev)->governor->name); |
713 | } | 713 | } |
714 | 714 | ||
715 | static ssize_t store_governor(struct device *dev, struct device_attribute *attr, | 715 | static ssize_t governor_store(struct device *dev, struct device_attribute *attr, |
716 | const char *buf, size_t count) | 716 | const char *buf, size_t count) |
717 | { | 717 | { |
718 | struct devfreq *df = to_devfreq(dev); | 718 | struct devfreq *df = to_devfreq(dev); |
@@ -754,9 +754,11 @@ out: | |||
754 | ret = count; | 754 | ret = count; |
755 | return ret; | 755 | return ret; |
756 | } | 756 | } |
757 | static ssize_t show_available_governors(struct device *d, | 757 | static DEVICE_ATTR_RW(governor); |
758 | struct device_attribute *attr, | 758 | |
759 | char *buf) | 759 | static ssize_t available_governors_show(struct device *d, |
760 | struct device_attribute *attr, | ||
761 | char *buf) | ||
760 | { | 762 | { |
761 | struct devfreq_governor *tmp_governor; | 763 | struct devfreq_governor *tmp_governor; |
762 | ssize_t count = 0; | 764 | ssize_t count = 0; |
@@ -775,9 +777,10 @@ static ssize_t show_available_governors(struct device *d, | |||
775 | 777 | ||
776 | return count; | 778 | return count; |
777 | } | 779 | } |
780 | static DEVICE_ATTR_RO(available_governors); | ||
778 | 781 | ||
779 | static ssize_t show_freq(struct device *dev, | 782 | static ssize_t cur_freq_show(struct device *dev, struct device_attribute *attr, |
780 | struct device_attribute *attr, char *buf) | 783 | char *buf) |
781 | { | 784 | { |
782 | unsigned long freq; | 785 | unsigned long freq; |
783 | struct devfreq *devfreq = to_devfreq(dev); | 786 | struct devfreq *devfreq = to_devfreq(dev); |
@@ -788,20 +791,22 @@ static ssize_t show_freq(struct device *dev, | |||
788 | 791 | ||
789 | return sprintf(buf, "%lu\n", devfreq->previous_freq); | 792 | return sprintf(buf, "%lu\n", devfreq->previous_freq); |
790 | } | 793 | } |
794 | static DEVICE_ATTR_RO(cur_freq); | ||
791 | 795 | ||
792 | static ssize_t show_target_freq(struct device *dev, | 796 | static ssize_t target_freq_show(struct device *dev, |
793 | struct device_attribute *attr, char *buf) | 797 | struct device_attribute *attr, char *buf) |
794 | { | 798 | { |
795 | return sprintf(buf, "%lu\n", to_devfreq(dev)->previous_freq); | 799 | return sprintf(buf, "%lu\n", to_devfreq(dev)->previous_freq); |
796 | } | 800 | } |
801 | static DEVICE_ATTR_RO(target_freq); | ||
797 | 802 | ||
798 | static ssize_t show_polling_interval(struct device *dev, | 803 | static ssize_t polling_interval_show(struct device *dev, |
799 | struct device_attribute *attr, char *buf) | 804 | struct device_attribute *attr, char *buf) |
800 | { | 805 | { |
801 | return sprintf(buf, "%d\n", to_devfreq(dev)->profile->polling_ms); | 806 | return sprintf(buf, "%d\n", to_devfreq(dev)->profile->polling_ms); |
802 | } | 807 | } |
803 | 808 | ||
804 | static ssize_t store_polling_interval(struct device *dev, | 809 | static ssize_t polling_interval_store(struct device *dev, |
805 | struct device_attribute *attr, | 810 | struct device_attribute *attr, |
806 | const char *buf, size_t count) | 811 | const char *buf, size_t count) |
807 | { | 812 | { |
@@ -821,8 +826,9 @@ static ssize_t store_polling_interval(struct device *dev, | |||
821 | 826 | ||
822 | return ret; | 827 | return ret; |
823 | } | 828 | } |
829 | static DEVICE_ATTR_RW(polling_interval); | ||
824 | 830 | ||
825 | static ssize_t store_min_freq(struct device *dev, struct device_attribute *attr, | 831 | static ssize_t min_freq_store(struct device *dev, struct device_attribute *attr, |
826 | const char *buf, size_t count) | 832 | const char *buf, size_t count) |
827 | { | 833 | { |
828 | struct devfreq *df = to_devfreq(dev); | 834 | struct devfreq *df = to_devfreq(dev); |
@@ -849,13 +855,13 @@ unlock: | |||
849 | return ret; | 855 | return ret; |
850 | } | 856 | } |
851 | 857 | ||
852 | static ssize_t show_min_freq(struct device *dev, struct device_attribute *attr, | 858 | static ssize_t min_freq_show(struct device *dev, struct device_attribute *attr, |
853 | char *buf) | 859 | char *buf) |
854 | { | 860 | { |
855 | return sprintf(buf, "%lu\n", to_devfreq(dev)->min_freq); | 861 | return sprintf(buf, "%lu\n", to_devfreq(dev)->min_freq); |
856 | } | 862 | } |
857 | 863 | ||
858 | static ssize_t store_max_freq(struct device *dev, struct device_attribute *attr, | 864 | static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr, |
859 | const char *buf, size_t count) | 865 | const char *buf, size_t count) |
860 | { | 866 | { |
861 | struct devfreq *df = to_devfreq(dev); | 867 | struct devfreq *df = to_devfreq(dev); |
@@ -881,16 +887,18 @@ unlock: | |||
881 | mutex_unlock(&df->lock); | 887 | mutex_unlock(&df->lock); |
882 | return ret; | 888 | return ret; |
883 | } | 889 | } |
890 | static DEVICE_ATTR_RW(min_freq); | ||
884 | 891 | ||
885 | static ssize_t show_max_freq(struct device *dev, struct device_attribute *attr, | 892 | static ssize_t max_freq_show(struct device *dev, struct device_attribute *attr, |
886 | char *buf) | 893 | char *buf) |
887 | { | 894 | { |
888 | return sprintf(buf, "%lu\n", to_devfreq(dev)->max_freq); | 895 | return sprintf(buf, "%lu\n", to_devfreq(dev)->max_freq); |
889 | } | 896 | } |
897 | static DEVICE_ATTR_RW(max_freq); | ||
890 | 898 | ||
891 | static ssize_t show_available_freqs(struct device *d, | 899 | static ssize_t available_frequencies_show(struct device *d, |
892 | struct device_attribute *attr, | 900 | struct device_attribute *attr, |
893 | char *buf) | 901 | char *buf) |
894 | { | 902 | { |
895 | struct devfreq *df = to_devfreq(d); | 903 | struct devfreq *df = to_devfreq(d); |
896 | struct device *dev = df->dev.parent; | 904 | struct device *dev = df->dev.parent; |
@@ -918,9 +926,10 @@ static ssize_t show_available_freqs(struct device *d, | |||
918 | 926 | ||
919 | return count; | 927 | return count; |
920 | } | 928 | } |
929 | static DEVICE_ATTR_RO(available_frequencies); | ||
921 | 930 | ||
922 | static ssize_t show_trans_table(struct device *dev, struct device_attribute *attr, | 931 | static ssize_t trans_stat_show(struct device *dev, |
923 | char *buf) | 932 | struct device_attribute *attr, char *buf) |
924 | { | 933 | { |
925 | struct devfreq *devfreq = to_devfreq(dev); | 934 | struct devfreq *devfreq = to_devfreq(dev); |
926 | ssize_t len; | 935 | ssize_t len; |
@@ -959,20 +968,21 @@ static ssize_t show_trans_table(struct device *dev, struct device_attribute *att | |||
959 | devfreq->total_trans); | 968 | devfreq->total_trans); |
960 | return len; | 969 | return len; |
961 | } | 970 | } |
962 | 971 | static DEVICE_ATTR_RO(trans_stat); | |
963 | static struct device_attribute devfreq_attrs[] = { | 972 | |
964 | __ATTR(governor, S_IRUGO | S_IWUSR, show_governor, store_governor), | 973 | static struct attribute *devfreq_attrs[] = { |
965 | __ATTR(available_governors, S_IRUGO, show_available_governors, NULL), | 974 | &dev_attr_governor.attr, |
966 | __ATTR(cur_freq, S_IRUGO, show_freq, NULL), | 975 | &dev_attr_available_governors.attr, |
967 | __ATTR(available_frequencies, S_IRUGO, show_available_freqs, NULL), | 976 | &dev_attr_cur_freq.attr, |
968 | __ATTR(target_freq, S_IRUGO, show_target_freq, NULL), | 977 | &dev_attr_available_frequencies.attr, |
969 | __ATTR(polling_interval, S_IRUGO | S_IWUSR, show_polling_interval, | 978 | &dev_attr_target_freq.attr, |
970 | store_polling_interval), | 979 | &dev_attr_polling_interval.attr, |
971 | __ATTR(min_freq, S_IRUGO | S_IWUSR, show_min_freq, store_min_freq), | 980 | &dev_attr_min_freq.attr, |
972 | __ATTR(max_freq, S_IRUGO | S_IWUSR, show_max_freq, store_max_freq), | 981 | &dev_attr_max_freq.attr, |
973 | __ATTR(trans_stat, S_IRUGO, show_trans_table, NULL), | 982 | &dev_attr_trans_stat.attr, |
974 | { }, | 983 | NULL, |
975 | }; | 984 | }; |
985 | ATTRIBUTE_GROUPS(devfreq); | ||
976 | 986 | ||
977 | static int __init devfreq_init(void) | 987 | static int __init devfreq_init(void) |
978 | { | 988 | { |
@@ -988,7 +998,7 @@ static int __init devfreq_init(void) | |||
988 | pr_err("%s: couldn't create workqueue\n", __FILE__); | 998 | pr_err("%s: couldn't create workqueue\n", __FILE__); |
989 | return PTR_ERR(devfreq_wq); | 999 | return PTR_ERR(devfreq_wq); |
990 | } | 1000 | } |
991 | devfreq_class->dev_attrs = devfreq_attrs; | 1001 | devfreq_class->dev_groups = devfreq_groups; |
992 | 1002 | ||
993 | return 0; | 1003 | return 0; |
994 | } | 1004 | } |