aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/devfreq/devfreq.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-03 14:37:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-03 14:37:15 -0400
commit542a086ac72fb193cbc1b996963a572269e57743 (patch)
treeb137c08037cca4ffc8a156a891a01113b3b8edce /drivers/devfreq/devfreq.c
parent1d1fdd95df681f0c065d90ffaafa215a0e8825e2 (diff)
parent1eeeef153c02f5856ec109fa532eb5f31c39f85c (diff)
Merge tag 'driver-core-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core patches from Greg KH: "Here's the big driver core pull request for 3.12-rc1. Lots of tiny changes here fixing up the way sysfs attributes are created, to try to make drivers simpler, and fix a whole class race conditions with creations of device attributes after the device was announced to userspace. All the various pieces are acked by the different subsystem maintainers" * tag 'driver-core-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (119 commits) firmware loader: fix pending_fw_head list corruption drivers/base/memory.c: introduce help macro to_memory_block dynamic debug: line queries failing due to uninitialized local variable sysfs: sysfs_create_groups returns a value. debugfs: provide debugfs_create_x64() when disabled rbd: convert bus code to use bus_groups firmware: dcdbas: use binary attribute groups sysfs: add sysfs_create/remove_groups for when SYSFS is not enabled driver core: add #include <linux/sysfs.h> to core files. HID: convert bus code to use dev_groups Input: serio: convert bus code to use drv_groups Input: gameport: convert bus code to use drv_groups driver core: firmware: use __ATTR_RW() driver core: core: use DEVICE_ATTR_RO driver core: bus: use DRIVER_ATTR_WO() driver core: create write-only attribute macros for devices and drivers sysfs: create __ATTR_WO() driver-core: platform: convert bus code to use dev_groups workqueue: convert bus code to use dev_groups MEI: convert bus code to use dev_groups ...
Diffstat (limited to 'drivers/devfreq/devfreq.c')
-rw-r--r--drivers/devfreq/devfreq.c78
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}
704EXPORT_SYMBOL(devfreq_remove_governor); 704EXPORT_SYMBOL(devfreq_remove_governor);
705 705
706static ssize_t show_governor(struct device *dev, 706static 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
715static ssize_t store_governor(struct device *dev, struct device_attribute *attr, 715static 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}
757static ssize_t show_available_governors(struct device *d, 757static DEVICE_ATTR_RW(governor);
758 struct device_attribute *attr, 758
759 char *buf) 759static 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}
780static DEVICE_ATTR_RO(available_governors);
778 781
779static ssize_t show_freq(struct device *dev, 782static 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}
794static DEVICE_ATTR_RO(cur_freq);
791 795
792static ssize_t show_target_freq(struct device *dev, 796static 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}
801static DEVICE_ATTR_RO(target_freq);
797 802
798static ssize_t show_polling_interval(struct device *dev, 803static 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
804static ssize_t store_polling_interval(struct device *dev, 809static 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}
829static DEVICE_ATTR_RW(polling_interval);
824 830
825static ssize_t store_min_freq(struct device *dev, struct device_attribute *attr, 831static 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
852static ssize_t show_min_freq(struct device *dev, struct device_attribute *attr, 858static 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
858static ssize_t store_max_freq(struct device *dev, struct device_attribute *attr, 864static 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}
890static DEVICE_ATTR_RW(min_freq);
884 891
885static ssize_t show_max_freq(struct device *dev, struct device_attribute *attr, 892static 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}
897static DEVICE_ATTR_RW(max_freq);
890 898
891static ssize_t show_available_freqs(struct device *d, 899static 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}
929static DEVICE_ATTR_RO(available_frequencies);
921 930
922static ssize_t show_trans_table(struct device *dev, struct device_attribute *attr, 931static 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 971static DEVICE_ATTR_RO(trans_stat);
963static struct device_attribute devfreq_attrs[] = { 972
964 __ATTR(governor, S_IRUGO | S_IWUSR, show_governor, store_governor), 973static 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};
985ATTRIBUTE_GROUPS(devfreq);
976 986
977static int __init devfreq_init(void) 987static 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}