diff options
author | Andi Kleen <andi@firstfloor.org> | 2010-01-05 06:47:58 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-07 20:04:47 -0500 |
commit | c9be0a36f9bf392a7984473124a67a12964df11f (patch) | |
tree | 23fcf49f277d9a093b2b29831811219410ad7b05 /drivers | |
parent | 3d03ba4d1dd2246adff5a9ff1194a539b3bc05a7 (diff) |
sysdev: Pass attribute in sysdev_class attributes show/store
Passing the attribute to the low level IO functions allows all kinds
of cleanups, by sharing low level IO code without requiring
an own function for every piece of data.
Also drivers can extend the attributes with own data fields
and use that in the low level function.
Similar to sysdev_attributes and normal attributes.
This is a tree-wide sweep, converting everything in one go.
No functional changes in this patch other than passing the new
argument everywhere.
Tested on x86, the non x86 parts are uncompiled.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/cpu.c | 9 | ||||
-rw-r--r-- | drivers/base/node.c | 17 | ||||
-rw-r--r-- | drivers/base/sys.c | 4 | ||||
-rw-r--r-- | drivers/cpuidle/sysfs.c | 4 |
4 files changed, 24 insertions, 10 deletions
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 958bd1540c30..fd1b2f9b7b8f 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
@@ -151,7 +151,8 @@ static ssize_t print_cpus_map(char *buf, const struct cpumask *map) | |||
151 | } | 151 | } |
152 | 152 | ||
153 | #define print_cpus_func(type) \ | 153 | #define print_cpus_func(type) \ |
154 | static ssize_t print_cpus_##type(struct sysdev_class *class, char *buf) \ | 154 | static ssize_t print_cpus_##type(struct sysdev_class *class, \ |
155 | struct sysdev_class_attribute *attr, char *buf) \ | ||
155 | { \ | 156 | { \ |
156 | return print_cpus_map(buf, cpu_##type##_mask); \ | 157 | return print_cpus_map(buf, cpu_##type##_mask); \ |
157 | } \ | 158 | } \ |
@@ -165,7 +166,8 @@ print_cpus_func(present); | |||
165 | /* | 166 | /* |
166 | * Print values for NR_CPUS and offlined cpus | 167 | * Print values for NR_CPUS and offlined cpus |
167 | */ | 168 | */ |
168 | static ssize_t print_cpus_kernel_max(struct sysdev_class *class, char *buf) | 169 | static ssize_t print_cpus_kernel_max(struct sysdev_class *class, |
170 | struct sysdev_class_attribute *attr, char *buf) | ||
169 | { | 171 | { |
170 | int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1); | 172 | int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1); |
171 | return n; | 173 | return n; |
@@ -175,7 +177,8 @@ static SYSDEV_CLASS_ATTR(kernel_max, 0444, print_cpus_kernel_max, NULL); | |||
175 | /* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ | 177 | /* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ |
176 | unsigned int total_cpus; | 178 | unsigned int total_cpus; |
177 | 179 | ||
178 | static ssize_t print_cpus_offline(struct sysdev_class *class, char *buf) | 180 | static ssize_t print_cpus_offline(struct sysdev_class *class, |
181 | struct sysdev_class_attribute *attr, char *buf) | ||
179 | { | 182 | { |
180 | int n = 0, len = PAGE_SIZE-2; | 183 | int n = 0, len = PAGE_SIZE-2; |
181 | cpumask_var_t offline; | 184 | cpumask_var_t offline; |
diff --git a/drivers/base/node.c b/drivers/base/node.c index 70122791683d..85c9d30d7004 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -544,23 +544,29 @@ static ssize_t print_nodes_state(enum node_states state, char *buf) | |||
544 | return n; | 544 | return n; |
545 | } | 545 | } |
546 | 546 | ||
547 | static ssize_t print_nodes_possible(struct sysdev_class *class, char *buf) | 547 | static ssize_t print_nodes_possible(struct sysdev_class *class, |
548 | struct sysdev_class_attribute *attr, char *buf) | ||
548 | { | 549 | { |
549 | return print_nodes_state(N_POSSIBLE, buf); | 550 | return print_nodes_state(N_POSSIBLE, buf); |
550 | } | 551 | } |
551 | 552 | ||
552 | static ssize_t print_nodes_online(struct sysdev_class *class, char *buf) | 553 | static ssize_t print_nodes_online(struct sysdev_class *class, |
554 | struct sysdev_class_attribute *attr, | ||
555 | char *buf) | ||
553 | { | 556 | { |
554 | return print_nodes_state(N_ONLINE, buf); | 557 | return print_nodes_state(N_ONLINE, buf); |
555 | } | 558 | } |
556 | 559 | ||
557 | static ssize_t print_nodes_has_normal_memory(struct sysdev_class *class, | 560 | static ssize_t print_nodes_has_normal_memory(struct sysdev_class *class, |
558 | char *buf) | 561 | struct sysdev_class_attribute *attr, |
562 | char *buf) | ||
559 | { | 563 | { |
560 | return print_nodes_state(N_NORMAL_MEMORY, buf); | 564 | return print_nodes_state(N_NORMAL_MEMORY, buf); |
561 | } | 565 | } |
562 | 566 | ||
563 | static ssize_t print_nodes_has_cpu(struct sysdev_class *class, char *buf) | 567 | static ssize_t print_nodes_has_cpu(struct sysdev_class *class, |
568 | struct sysdev_class_attribute *attr, | ||
569 | char *buf) | ||
564 | { | 570 | { |
565 | return print_nodes_state(N_CPU, buf); | 571 | return print_nodes_state(N_CPU, buf); |
566 | } | 572 | } |
@@ -573,7 +579,8 @@ static SYSDEV_CLASS_ATTR(has_cpu, 0444, print_nodes_has_cpu, NULL); | |||
573 | 579 | ||
574 | #ifdef CONFIG_HIGHMEM | 580 | #ifdef CONFIG_HIGHMEM |
575 | static ssize_t print_nodes_has_high_memory(struct sysdev_class *class, | 581 | static ssize_t print_nodes_has_high_memory(struct sysdev_class *class, |
576 | char *buf) | 582 | struct sysdev_class_attribute *attr, |
583 | char *buf) | ||
577 | { | 584 | { |
578 | return print_nodes_state(N_HIGH_MEMORY, buf); | 585 | return print_nodes_state(N_HIGH_MEMORY, buf); |
579 | } | 586 | } |
diff --git a/drivers/base/sys.c b/drivers/base/sys.c index 0d903909af7e..a38445c0f8c5 100644 --- a/drivers/base/sys.c +++ b/drivers/base/sys.c | |||
@@ -89,7 +89,7 @@ static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr, | |||
89 | struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); | 89 | struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); |
90 | 90 | ||
91 | if (class_attr->show) | 91 | if (class_attr->show) |
92 | return class_attr->show(class, buffer); | 92 | return class_attr->show(class, class_attr, buffer); |
93 | return -EIO; | 93 | return -EIO; |
94 | } | 94 | } |
95 | 95 | ||
@@ -100,7 +100,7 @@ static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr, | |||
100 | struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); | 100 | struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); |
101 | 101 | ||
102 | if (class_attr->store) | 102 | if (class_attr->store) |
103 | return class_attr->store(class, buffer, count); | 103 | return class_attr->store(class, class_attr, buffer, count); |
104 | return -EIO; | 104 | return -EIO; |
105 | } | 105 | } |
106 | 106 | ||
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 97b003839fb6..c9cefacabf37 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
@@ -22,6 +22,7 @@ static int __init cpuidle_sysfs_setup(char *unused) | |||
22 | __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); | 22 | __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); |
23 | 23 | ||
24 | static ssize_t show_available_governors(struct sysdev_class *class, | 24 | static ssize_t show_available_governors(struct sysdev_class *class, |
25 | struct sysdev_class_attribute *attr, | ||
25 | char *buf) | 26 | char *buf) |
26 | { | 27 | { |
27 | ssize_t i = 0; | 28 | ssize_t i = 0; |
@@ -41,6 +42,7 @@ out: | |||
41 | } | 42 | } |
42 | 43 | ||
43 | static ssize_t show_current_driver(struct sysdev_class *class, | 44 | static ssize_t show_current_driver(struct sysdev_class *class, |
45 | struct sysdev_class_attribute *attr, | ||
44 | char *buf) | 46 | char *buf) |
45 | { | 47 | { |
46 | ssize_t ret; | 48 | ssize_t ret; |
@@ -56,6 +58,7 @@ static ssize_t show_current_driver(struct sysdev_class *class, | |||
56 | } | 58 | } |
57 | 59 | ||
58 | static ssize_t show_current_governor(struct sysdev_class *class, | 60 | static ssize_t show_current_governor(struct sysdev_class *class, |
61 | struct sysdev_class_attribute *attr, | ||
59 | char *buf) | 62 | char *buf) |
60 | { | 63 | { |
61 | ssize_t ret; | 64 | ssize_t ret; |
@@ -71,6 +74,7 @@ static ssize_t show_current_governor(struct sysdev_class *class, | |||
71 | } | 74 | } |
72 | 75 | ||
73 | static ssize_t store_current_governor(struct sysdev_class *class, | 76 | static ssize_t store_current_governor(struct sysdev_class *class, |
77 | struct sysdev_class_attribute *attr, | ||
74 | const char *buf, size_t count) | 78 | const char *buf, size_t count) |
75 | { | 79 | { |
76 | char gov_name[CPUIDLE_NAME_LEN]; | 80 | char gov_name[CPUIDLE_NAME_LEN]; |