Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sysdev: Pass the attribute to the low level sysdev show/store function

This allow to dynamically generate attributes and share show/store
functions between attributes. Right now most attributes are generated
by special macros and lots of duplicated code. With the attribute
passed it's instead possible to attach some data to the attribute
and then use that in shared low level functions to do different things.

I need this for the dynamically generated bank attributes in the x86
machine check code, but it'll allow some further cleanups.

I converted all users in tree to the new show/store prototype. It's a single
huge patch to avoid unbisectable sections.

Runtime tested: x86-32, x86-64
Compiled only: ia64, powerpc
Not compile tested/only grep converted: sh, arm, avr32

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Andi Kleen and committed by
Greg Kroah-Hartman
4a0b2b4d 36ce6dad

+239 -112
+3 -1
arch/arm/kernel/time.c
··· 130 130 { "red", led_red_on, led_red_off }, 131 131 }; 132 132 133 - static ssize_t leds_store(struct sys_device *dev, const char *buf, size_t size) 133 + static ssize_t leds_store(struct sys_device *dev, 134 + struct sysdev_attribute *attr, 135 + const char *buf, size_t size) 134 136 { 135 137 int ret = -EINVAL, len = strcspn(buf, " "); 136 138
+25 -13
arch/avr32/kernel/cpu.c
··· 26 26 * XXX: If/when a SMP-capable implementation of AVR32 will ever be 27 27 * made, we must make sure that the code executes on the correct CPU. 28 28 */ 29 - static ssize_t show_pc0event(struct sys_device *dev, char *buf) 29 + static ssize_t show_pc0event(struct sys_device *dev, 30 + struct sysdev_attribute *attr, char *buf) 30 31 { 31 32 unsigned long pccr; 32 33 33 34 pccr = sysreg_read(PCCR); 34 35 return sprintf(buf, "0x%lx\n", (pccr >> 12) & 0x3f); 35 36 } 36 - static ssize_t store_pc0event(struct sys_device *dev, const char *buf, 37 + static ssize_t store_pc0event(struct sys_device *dev, 38 + struct sysdev_attribute *attr, const char *buf, 37 39 size_t count) 38 40 { 39 41 unsigned long val; ··· 48 46 sysreg_write(PCCR, val); 49 47 return count; 50 48 } 51 - static ssize_t show_pc0count(struct sys_device *dev, char *buf) 49 + static ssize_t show_pc0count(struct sys_device *dev, 50 + struct sysdev_attribute *attr, char *buf) 52 51 { 53 52 unsigned long pcnt0; 54 53 55 54 pcnt0 = sysreg_read(PCNT0); 56 55 return sprintf(buf, "%lu\n", pcnt0); 57 56 } 58 - static ssize_t store_pc0count(struct sys_device *dev, const char *buf, 59 - size_t count) 57 + static ssize_t store_pc0count(struct sys_device *dev, 58 + struct sysdev_attribute *attr, 59 + const char *buf, size_t count) 60 60 { 61 61 unsigned long val; 62 62 char *endp; ··· 71 67 return count; 72 68 } 73 69 74 - static ssize_t show_pc1event(struct sys_device *dev, char *buf) 70 + static ssize_t show_pc1event(struct sys_device *dev, 71 + struct sysdev_attribute *attr, char *buf) 75 72 { 76 73 unsigned long pccr; 77 74 78 75 pccr = sysreg_read(PCCR); 79 76 return sprintf(buf, "0x%lx\n", (pccr >> 18) & 0x3f); 80 77 } 81 - static ssize_t store_pc1event(struct sys_device *dev, const char *buf, 78 + static ssize_t store_pc1event(struct sys_device *dev, 79 + struct sysdev_attribute *attr, const char *buf, 82 80 size_t count) 83 81 { 84 82 unsigned long val; ··· 93 87 sysreg_write(PCCR, val); 94 88 return count; 95 89 } 96 - static ssize_t show_pc1count(struct sys_device *dev, char *buf) 90 + static ssize_t show_pc1count(struct sys_device *dev, 91 + struct sysdev_attribute *attr, char *buf) 97 92 { 98 93 unsigned long pcnt1; 99 94 100 95 pcnt1 = sysreg_read(PCNT1); 101 96 return sprintf(buf, "%lu\n", pcnt1); 102 97 } 103 - static ssize_t store_pc1count(struct sys_device *dev, const char *buf, 98 + static ssize_t store_pc1count(struct sys_device *dev, 99 + struct sysdev_attribute *attr, const char *buf, 104 100 size_t count) 105 101 { 106 102 unsigned long val; ··· 116 108 return count; 117 109 } 118 110 119 - static ssize_t show_pccycles(struct sys_device *dev, char *buf) 111 + static ssize_t show_pccycles(struct sys_device *dev, 112 + struct sysdev_attribute *attr, char *buf) 120 113 { 121 114 unsigned long pccnt; 122 115 123 116 pccnt = sysreg_read(PCCNT); 124 117 return sprintf(buf, "%lu\n", pccnt); 125 118 } 126 - static ssize_t store_pccycles(struct sys_device *dev, const char *buf, 119 + static ssize_t store_pccycles(struct sys_device *dev, 120 + struct sysdev_attribute *attr, const char *buf, 127 121 size_t count) 128 122 { 129 123 unsigned long val; ··· 139 129 return count; 140 130 } 141 131 142 - static ssize_t show_pcenable(struct sys_device *dev, char *buf) 132 + static ssize_t show_pcenable(struct sys_device *dev, 133 + struct sysdev_attribute *attr, char *buf) 143 134 { 144 135 unsigned long pccr; 145 136 146 137 pccr = sysreg_read(PCCR); 147 138 return sprintf(buf, "%c\n", (pccr & 1)?'1':'0'); 148 139 } 149 - static ssize_t store_pcenable(struct sys_device *dev, const char *buf, 140 + static ssize_t store_pcenable(struct sys_device *dev, 141 + struct sysdev_attribute *attr, const char *buf, 150 142 size_t count) 151 143 { 152 144 unsigned long pccr, val;
+15 -7
arch/ia64/kernel/err_inject.c
··· 55 55 56 56 #define show(name) \ 57 57 static ssize_t \ 58 - show_##name(struct sys_device *dev, char *buf) \ 58 + show_##name(struct sys_device *dev, struct sysdev_attribute *attr, \ 59 + char *buf) \ 59 60 { \ 60 61 u32 cpu=dev->id; \ 61 62 return sprintf(buf, "%lx\n", name[cpu]); \ ··· 64 63 65 64 #define store(name) \ 66 65 static ssize_t \ 67 - store_##name(struct sys_device *dev, const char *buf, size_t size) \ 66 + store_##name(struct sys_device *dev, struct sysdev_attribute *attr, \ 67 + const char *buf, size_t size) \ 68 68 { \ 69 69 unsigned int cpu=dev->id; \ 70 70 name[cpu] = simple_strtoull(buf, NULL, 16); \ ··· 78 76 * processor. The cpu number in driver is only used for storing data. 79 77 */ 80 78 static ssize_t 81 - store_call_start(struct sys_device *dev, const char *buf, size_t size) 79 + store_call_start(struct sys_device *dev, struct sysdev_attribute *attr, 80 + const char *buf, size_t size) 82 81 { 83 82 unsigned int cpu=dev->id; 84 83 unsigned long call_start = simple_strtoull(buf, NULL, 16); ··· 127 124 store(err_type_info) 128 125 129 126 static ssize_t 130 - show_virtual_to_phys(struct sys_device *dev, char *buf) 127 + show_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr, 128 + char *buf) 131 129 { 132 130 unsigned int cpu=dev->id; 133 131 return sprintf(buf, "%lx\n", phys_addr[cpu]); 134 132 } 135 133 136 134 static ssize_t 137 - store_virtual_to_phys(struct sys_device *dev, const char *buf, size_t size) 135 + store_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr, 136 + const char *buf, size_t size) 138 137 { 139 138 unsigned int cpu=dev->id; 140 139 u64 virt_addr=simple_strtoull(buf, NULL, 16); ··· 159 154 store(err_struct_info) 160 155 161 156 static ssize_t 162 - show_err_data_buffer(struct sys_device *dev, char *buf) 157 + show_err_data_buffer(struct sys_device *dev, 158 + struct sysdev_attribute *attr, char *buf) 163 159 { 164 160 unsigned int cpu=dev->id; 165 161 ··· 171 165 } 172 166 173 167 static ssize_t 174 - store_err_data_buffer(struct sys_device *dev, const char *buf, size_t size) 168 + store_err_data_buffer(struct sys_device *dev, 169 + struct sysdev_attribute *attr, 170 + const char *buf, size_t size) 175 171 { 176 172 unsigned int cpu=dev->id; 177 173 int ret;
+11 -4
arch/powerpc/kernel/sysfs.c
··· 28 28 /* Time in microseconds we delay before sleeping in the idle loop */ 29 29 DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 }; 30 30 31 - static ssize_t store_smt_snooze_delay(struct sys_device *dev, const char *buf, 31 + static ssize_t store_smt_snooze_delay(struct sys_device *dev, 32 + struct sysdev_attribute *attr, 33 + const char *buf, 32 34 size_t count) 33 35 { 34 36 struct cpu *cpu = container_of(dev, struct cpu, sysdev); ··· 46 44 return count; 47 45 } 48 46 49 - static ssize_t show_smt_snooze_delay(struct sys_device *dev, char *buf) 47 + static ssize_t show_smt_snooze_delay(struct sys_device *dev, 48 + struct sysdev_attribute *attr, 49 + char *buf) 50 50 { 51 51 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 52 52 ··· 156 152 mtspr(ADDRESS, val); \ 157 153 return 0; \ 158 154 } \ 159 - static ssize_t show_##NAME(struct sys_device *dev, char *buf) \ 155 + static ssize_t show_##NAME(struct sys_device *dev, \ 156 + struct sysdev_attribute *attr, \ 157 + char *buf) \ 160 158 { \ 161 159 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \ 162 160 unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \ 163 161 return sprintf(buf, "%lx\n", val); \ 164 162 } \ 165 163 static ssize_t __used \ 166 - store_##NAME(struct sys_device *dev, const char *buf, size_t count) \ 164 + store_##NAME(struct sys_device *dev, struct sysdev_attribute *attr, \ 165 + const char *buf, size_t count) \ 167 166 { \ 168 167 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \ 169 168 unsigned long val; \
+30 -15
arch/powerpc/platforms/cell/cbe_thermal.c
··· 97 97 return value.spe[spu->spe_id]; 98 98 } 99 99 100 - static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf) 100 + static ssize_t spu_show_temp(struct sys_device *sysdev, struct sysdev_attribute *attr, 101 + char *buf) 101 102 { 102 103 u8 value; 103 104 struct cbe_pmd_regs __iomem *pmd_regs; ··· 147 146 return size; 148 147 } 149 148 150 - static ssize_t spu_show_throttle_end(struct sys_device *sysdev, char *buf) 149 + static ssize_t spu_show_throttle_end(struct sys_device *sysdev, 150 + struct sysdev_attribute *attr, char *buf) 151 151 { 152 152 return show_throttle(get_pmd_regs(sysdev), buf, 0); 153 153 } 154 154 155 - static ssize_t spu_show_throttle_begin(struct sys_device *sysdev, char *buf) 155 + static ssize_t spu_show_throttle_begin(struct sys_device *sysdev, 156 + struct sysdev_attribute *attr, char *buf) 156 157 { 157 158 return show_throttle(get_pmd_regs(sysdev), buf, 8); 158 159 } 159 160 160 - static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev, char *buf) 161 + static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev, 162 + struct sysdev_attribute *attr, char *buf) 161 163 { 162 164 return show_throttle(get_pmd_regs(sysdev), buf, 16); 163 165 } 164 166 165 - static ssize_t spu_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size) 167 + static ssize_t spu_store_throttle_end(struct sys_device *sysdev, 168 + struct sysdev_attribute *attr, const char *buf, size_t size) 166 169 { 167 170 return store_throttle(get_pmd_regs(sysdev), buf, size, 0); 168 171 } 169 172 170 - static ssize_t spu_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size) 173 + static ssize_t spu_store_throttle_begin(struct sys_device *sysdev, 174 + struct sysdev_attribute *attr, const char *buf, size_t size) 171 175 { 172 176 return store_throttle(get_pmd_regs(sysdev), buf, size, 8); 173 177 } 174 178 175 - static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size) 179 + static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev, 180 + struct sysdev_attribute *attr, const char *buf, size_t size) 176 181 { 177 182 return store_throttle(get_pmd_regs(sysdev), buf, size, 16); 178 183 } ··· 199 192 200 193 /* shows the temperature of the DTS on the PPE, 201 194 * located near the linear thermal sensor */ 202 - static ssize_t ppe_show_temp0(struct sys_device *sysdev, char *buf) 195 + static ssize_t ppe_show_temp0(struct sys_device *sysdev, 196 + struct sysdev_attribute *attr, char *buf) 203 197 { 204 198 return ppe_show_temp(sysdev, buf, 32); 205 199 } 206 200 207 201 /* shows the temperature of the second DTS on the PPE */ 208 - static ssize_t ppe_show_temp1(struct sys_device *sysdev, char *buf) 202 + static ssize_t ppe_show_temp1(struct sys_device *sysdev, 203 + struct sysdev_attribute *attr, char *buf) 209 204 { 210 205 return ppe_show_temp(sysdev, buf, 0); 211 206 } 212 207 213 - static ssize_t ppe_show_throttle_end(struct sys_device *sysdev, char *buf) 208 + static ssize_t ppe_show_throttle_end(struct sys_device *sysdev, 209 + struct sysdev_attribute *attr, char *buf) 214 210 { 215 211 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 32); 216 212 } 217 213 218 - static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev, char *buf) 214 + static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev, 215 + struct sysdev_attribute *attr, char *buf) 219 216 { 220 217 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 40); 221 218 } 222 219 223 - static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev, char *buf) 220 + static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev, 221 + struct sysdev_attribute *attr, char *buf) 224 222 { 225 223 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 48); 226 224 } 227 225 228 - static ssize_t ppe_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size) 226 + static ssize_t ppe_store_throttle_end(struct sys_device *sysdev, 227 + struct sysdev_attribute *attr, const char *buf, size_t size) 229 228 { 230 229 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 32); 231 230 } 232 231 233 - static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size) 232 + static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev, 233 + struct sysdev_attribute *attr, const char *buf, size_t size) 234 234 { 235 235 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 40); 236 236 } 237 237 238 - static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size) 238 + static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev, 239 + struct sysdev_attribute *attr, const char *buf, size_t size) 239 240 { 240 241 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 48); 241 242 }
+2 -1
arch/powerpc/platforms/cell/spu_base.c
··· 703 703 } 704 704 705 705 706 - static ssize_t spu_stat_show(struct sys_device *sysdev, char *buf) 706 + static ssize_t spu_stat_show(struct sys_device *sysdev, 707 + struct sysdev_attribute *attr, char *buf) 707 708 { 708 709 struct spu *spu = container_of(sysdev, struct spu, sysdev); 709 710
+24 -12
arch/s390/kernel/smp.c
··· 864 864 } 865 865 866 866 #ifdef CONFIG_HOTPLUG_CPU 867 - static ssize_t cpu_configure_show(struct sys_device *dev, char *buf) 867 + static ssize_t cpu_configure_show(struct sys_device *dev, 868 + struct sysdev_attribute *attr, char *buf) 868 869 { 869 870 ssize_t count; 870 871 ··· 875 874 return count; 876 875 } 877 876 878 - static ssize_t cpu_configure_store(struct sys_device *dev, const char *buf, 879 - size_t count) 877 + static ssize_t cpu_configure_store(struct sys_device *dev, 878 + struct sysdev_attribute *attr, 879 + const char *buf, size_t count) 880 880 { 881 881 int cpu = dev->id; 882 882 int val, rc; ··· 924 922 static SYSDEV_ATTR(configure, 0644, cpu_configure_show, cpu_configure_store); 925 923 #endif /* CONFIG_HOTPLUG_CPU */ 926 924 927 - static ssize_t cpu_polarization_show(struct sys_device *dev, char *buf) 925 + static ssize_t cpu_polarization_show(struct sys_device *dev, 926 + struct sysdev_attribute *attr, char *buf) 928 927 { 929 928 int cpu = dev->id; 930 929 ssize_t count; ··· 953 950 } 954 951 static SYSDEV_ATTR(polarization, 0444, cpu_polarization_show, NULL); 955 952 956 - static ssize_t show_cpu_address(struct sys_device *dev, char *buf) 953 + static ssize_t show_cpu_address(struct sys_device *dev, 954 + struct sysdev_attribute *attr, char *buf) 957 955 { 958 956 return sprintf(buf, "%d\n", __cpu_logical_map[dev->id]); 959 957 } ··· 974 970 .attrs = cpu_common_attrs, 975 971 }; 976 972 977 - static ssize_t show_capability(struct sys_device *dev, char *buf) 973 + static ssize_t show_capability(struct sys_device *dev, 974 + struct sysdev_attribute *attr, char *buf) 978 975 { 979 976 unsigned int capability; 980 977 int rc; ··· 987 982 } 988 983 static SYSDEV_ATTR(capability, 0444, show_capability, NULL); 989 984 990 - static ssize_t show_idle_count(struct sys_device *dev, char *buf) 985 + static ssize_t show_idle_count(struct sys_device *dev, 986 + struct sysdev_attribute *attr, char *buf) 991 987 { 992 988 struct s390_idle_data *idle; 993 989 unsigned long long idle_count; ··· 1001 995 } 1002 996 static SYSDEV_ATTR(idle_count, 0444, show_idle_count, NULL); 1003 997 1004 - static ssize_t show_idle_time(struct sys_device *dev, char *buf) 998 + static ssize_t show_idle_time(struct sys_device *dev, 999 + struct sysdev_attribute *attr, char *buf) 1005 1000 { 1006 1001 struct s390_idle_data *idle; 1007 1002 unsigned long long new_time; ··· 1119 1112 return rc; 1120 1113 } 1121 1114 1122 - static ssize_t __ref rescan_store(struct sys_device *dev, const char *buf, 1115 + static ssize_t __ref rescan_store(struct sys_device *dev, 1116 + struct sysdev_attribute *attr, 1117 + const char *buf, 1123 1118 size_t count) 1124 1119 { 1125 1120 int rc; ··· 1132 1123 static SYSDEV_ATTR(rescan, 0200, NULL, rescan_store); 1133 1124 #endif /* CONFIG_HOTPLUG_CPU */ 1134 1125 1135 - static ssize_t dispatching_show(struct sys_device *dev, char *buf) 1126 + static ssize_t dispatching_show(struct sys_device *dev, 1127 + struct sysdev_attribute *attr, 1128 + char *buf) 1136 1129 { 1137 1130 ssize_t count; 1138 1131 ··· 1144 1133 return count; 1145 1134 } 1146 1135 1147 - static ssize_t dispatching_store(struct sys_device *dev, const char *buf, 1148 - size_t count) 1136 + static ssize_t dispatching_store(struct sys_device *dev, 1137 + struct sysdev_attribute *attr, 1138 + const char *buf, size_t count) 1149 1139 { 1150 1140 int val, rc; 1151 1141 char delim;
+24 -11
arch/s390/kernel/time.c
··· 1100 1100 return etr_port1_online ? &etr_port1 : NULL; 1101 1101 } 1102 1102 1103 - static ssize_t etr_online_show(struct sys_device *dev, char *buf) 1103 + static ssize_t etr_online_show(struct sys_device *dev, 1104 + struct sysdev_attribute *attr, 1105 + char *buf) 1104 1106 { 1105 1107 unsigned int online; 1106 1108 ··· 1111 1109 } 1112 1110 1113 1111 static ssize_t etr_online_store(struct sys_device *dev, 1114 - const char *buf, size_t count) 1112 + struct sysdev_attribute *attr, 1113 + const char *buf, size_t count) 1115 1114 { 1116 1115 unsigned int value; 1117 1116 ··· 1139 1136 1140 1137 static SYSDEV_ATTR(online, 0600, etr_online_show, etr_online_store); 1141 1138 1142 - static ssize_t etr_stepping_control_show(struct sys_device *dev, char *buf) 1139 + static ssize_t etr_stepping_control_show(struct sys_device *dev, 1140 + struct sysdev_attribute *attr, 1141 + char *buf) 1143 1142 { 1144 1143 return sprintf(buf, "%i\n", (dev == &etr_port0_dev) ? 1145 1144 etr_eacr.e0 : etr_eacr.e1); ··· 1149 1144 1150 1145 static SYSDEV_ATTR(stepping_control, 0400, etr_stepping_control_show, NULL); 1151 1146 1152 - static ssize_t etr_mode_code_show(struct sys_device *dev, char *buf) 1147 + static ssize_t etr_mode_code_show(struct sys_device *dev, 1148 + struct sysdev_attribute *attr, char *buf) 1153 1149 { 1154 1150 if (!etr_port0_online && !etr_port1_online) 1155 1151 /* Status word is not uptodate if both ports are offline. */ ··· 1161 1155 1162 1156 static SYSDEV_ATTR(state_code, 0400, etr_mode_code_show, NULL); 1163 1157 1164 - static ssize_t etr_untuned_show(struct sys_device *dev, char *buf) 1158 + static ssize_t etr_untuned_show(struct sys_device *dev, 1159 + struct sysdev_attribute *attr, char *buf) 1165 1160 { 1166 1161 struct etr_aib *aib = etr_aib_from_dev(dev); 1167 1162 ··· 1173 1166 1174 1167 static SYSDEV_ATTR(untuned, 0400, etr_untuned_show, NULL); 1175 1168 1176 - static ssize_t etr_network_id_show(struct sys_device *dev, char *buf) 1169 + static ssize_t etr_network_id_show(struct sys_device *dev, 1170 + struct sysdev_attribute *attr, char *buf) 1177 1171 { 1178 1172 struct etr_aib *aib = etr_aib_from_dev(dev); 1179 1173 ··· 1185 1177 1186 1178 static SYSDEV_ATTR(network, 0400, etr_network_id_show, NULL); 1187 1179 1188 - static ssize_t etr_id_show(struct sys_device *dev, char *buf) 1180 + static ssize_t etr_id_show(struct sys_device *dev, 1181 + struct sysdev_attribute *attr, char *buf) 1189 1182 { 1190 1183 struct etr_aib *aib = etr_aib_from_dev(dev); 1191 1184 ··· 1197 1188 1198 1189 static SYSDEV_ATTR(id, 0400, etr_id_show, NULL); 1199 1190 1200 - static ssize_t etr_port_number_show(struct sys_device *dev, char *buf) 1191 + static ssize_t etr_port_number_show(struct sys_device *dev, 1192 + struct sysdev_attribute *attr, char *buf) 1201 1193 { 1202 1194 struct etr_aib *aib = etr_aib_from_dev(dev); 1203 1195 ··· 1209 1199 1210 1200 static SYSDEV_ATTR(port, 0400, etr_port_number_show, NULL); 1211 1201 1212 - static ssize_t etr_coupled_show(struct sys_device *dev, char *buf) 1202 + static ssize_t etr_coupled_show(struct sys_device *dev, 1203 + struct sysdev_attribute *attr, char *buf) 1213 1204 { 1214 1205 struct etr_aib *aib = etr_aib_from_dev(dev); 1215 1206 ··· 1221 1210 1222 1211 static SYSDEV_ATTR(coupled, 0400, etr_coupled_show, NULL); 1223 1212 1224 - static ssize_t etr_local_time_show(struct sys_device *dev, char *buf) 1213 + static ssize_t etr_local_time_show(struct sys_device *dev, 1214 + struct sysdev_attribute *attr, char *buf) 1225 1215 { 1226 1216 struct etr_aib *aib = etr_aib_from_dev(dev); 1227 1217 ··· 1233 1221 1234 1222 static SYSDEV_ATTR(local_time, 0400, etr_local_time_show, NULL); 1235 1223 1236 - static ssize_t etr_utc_offset_show(struct sys_device *dev, char *buf) 1224 + static ssize_t etr_utc_offset_show(struct sys_device *dev, 1225 + struct sysdev_attribute *attr, char *buf) 1237 1226 { 1238 1227 struct etr_aib *aib = etr_aib_from_dev(dev); 1239 1228
+11 -4
arch/sh/drivers/dma/dma-sysfs.c
··· 23 23 }; 24 24 EXPORT_SYMBOL(dma_sysclass); 25 25 26 - static ssize_t dma_show_devices(struct sys_device *dev, char *buf) 26 + static ssize_t dma_show_devices(struct sys_device *dev, 27 + struct sysdev_attribute *attr, char *buf) 27 28 { 28 29 ssize_t len = 0; 29 30 int i; ··· 58 57 } 59 58 postcore_initcall(dma_sysclass_init); 60 59 61 - static ssize_t dma_show_dev_id(struct sys_device *dev, char *buf) 60 + static ssize_t dma_show_dev_id(struct sys_device *dev, 61 + struct sysdev_attribute *attr, char *buf) 62 62 { 63 63 struct dma_channel *channel = to_dma_channel(dev); 64 64 return sprintf(buf, "%s\n", channel->dev_id); 65 65 } 66 66 67 67 static ssize_t dma_store_dev_id(struct sys_device *dev, 68 + struct sysdev_attribute *attr, 68 69 const char *buf, size_t count) 69 70 { 70 71 struct dma_channel *channel = to_dma_channel(dev); ··· 77 74 static SYSDEV_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id); 78 75 79 76 static ssize_t dma_store_config(struct sys_device *dev, 77 + struct sysdev_attribute *attr, 80 78 const char *buf, size_t count) 81 79 { 82 80 struct dma_channel *channel = to_dma_channel(dev); ··· 91 87 92 88 static SYSDEV_ATTR(config, S_IWUSR, NULL, dma_store_config); 93 89 94 - static ssize_t dma_show_mode(struct sys_device *dev, char *buf) 90 + static ssize_t dma_show_mode(struct sys_device *dev, 91 + struct sysdev_attribute *attr, char *buf) 95 92 { 96 93 struct dma_channel *channel = to_dma_channel(dev); 97 94 return sprintf(buf, "0x%08x\n", channel->mode); 98 95 } 99 96 100 97 static ssize_t dma_store_mode(struct sys_device *dev, 98 + struct sysdev_attribute *attr, 101 99 const char *buf, size_t count) 102 100 { 103 101 struct dma_channel *channel = to_dma_channel(dev); ··· 110 104 static SYSDEV_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode); 111 105 112 106 #define dma_ro_attr(field, fmt) \ 113 - static ssize_t dma_show_##field(struct sys_device *dev, char *buf) \ 107 + static ssize_t dma_show_##field(struct sys_device *dev, \ 108 + struct sysdev_attribute *attr, char *buf)\ 114 109 { \ 115 110 struct dma_channel *channel = to_dma_channel(dev); \ 116 111 return sprintf(buf, fmt, channel->field); \
+11 -5
arch/sparc64/kernel/sysfs.c
··· 14 14 static DEFINE_PER_CPU(struct hv_mmu_statistics, mmu_stats) __attribute__((aligned(64))); 15 15 16 16 #define SHOW_MMUSTAT_ULONG(NAME) \ 17 - static ssize_t show_##NAME(struct sys_device *dev, char *buf) \ 17 + static ssize_t show_##NAME(struct sys_device *dev, \ 18 + struct sysdev_attribute *attr, char *buf) \ 18 19 { \ 19 20 struct hv_mmu_statistics *p = &per_cpu(mmu_stats, dev->id); \ 20 21 return sprintf(buf, "%lu\n", p->NAME); \ ··· 136 135 return sun4v_mmustat_conf(ra, &orig_ra); 137 136 } 138 137 139 - static ssize_t show_mmustat_enable(struct sys_device *s, char *buf) 138 + static ssize_t show_mmustat_enable(struct sys_device *s, 139 + struct sysdev_attribute *attr, char *buf) 140 140 { 141 141 unsigned long val = run_on_cpu(s->id, read_mmustat_enable, 0); 142 142 return sprintf(buf, "%lx\n", val); 143 143 } 144 144 145 - static ssize_t store_mmustat_enable(struct sys_device *s, const char *buf, size_t count) 145 + static ssize_t store_mmustat_enable(struct sys_device *s, 146 + struct sysdev_attribute *attr, const char *buf, 147 + size_t count) 146 148 { 147 149 unsigned long val, err; 148 150 int ret = sscanf(buf, "%ld", &val); ··· 183 179 #endif 184 180 185 181 #define SHOW_CPUDATA_ULONG_NAME(NAME, MEMBER) \ 186 - static ssize_t show_##NAME(struct sys_device *dev, char *buf) \ 182 + static ssize_t show_##NAME(struct sys_device *dev, \ 183 + struct sysdev_attribute *attr, char *buf) \ 187 184 { \ 188 185 cpuinfo_sparc *c = &cpu_data(dev->id); \ 189 186 return sprintf(buf, "%lu\n", c->MEMBER); \ 190 187 } 191 188 192 189 #define SHOW_CPUDATA_UINT_NAME(NAME, MEMBER) \ 193 - static ssize_t show_##NAME(struct sys_device *dev, char *buf) \ 190 + static ssize_t show_##NAME(struct sys_device *dev, \ 191 + struct sysdev_attribute *attr, char *buf) \ 194 192 { \ 195 193 cpuinfo_sparc *c = &cpu_data(dev->id); \ 196 194 return sprintf(buf, "%u\n", c->MEMBER); \
+10 -4
arch/x86/kernel/cpu/mcheck/mce_64.c
··· 762 762 763 763 /* Why are there no generic functions for this? */ 764 764 #define ACCESSOR(name, var, start) \ 765 - static ssize_t show_ ## name(struct sys_device *s, char *buf) { \ 765 + static ssize_t show_ ## name(struct sys_device *s, \ 766 + struct sysdev_attribute *attr, \ 767 + char *buf) { \ 766 768 return sprintf(buf, "%lx\n", (unsigned long)var); \ 767 769 } \ 768 - static ssize_t set_ ## name(struct sys_device *s,const char *buf,size_t siz) { \ 770 + static ssize_t set_ ## name(struct sys_device *s, \ 771 + struct sysdev_attribute *attr, \ 772 + const char *buf, size_t siz) { \ 769 773 char *end; \ 770 774 unsigned long new = simple_strtoul(buf, &end, 0); \ 771 775 if (end == buf) return -EINVAL; \ ··· 790 786 ACCESSOR(bank4ctl,bank[4],mce_restart()) 791 787 ACCESSOR(bank5ctl,bank[5],mce_restart()) 792 788 793 - static ssize_t show_trigger(struct sys_device *s, char *buf) 789 + static ssize_t show_trigger(struct sys_device *s, struct sysdev_attribute *attr, 790 + char *buf) 794 791 { 795 792 strcpy(buf, trigger); 796 793 strcat(buf, "\n"); 797 794 return strlen(trigger) + 1; 798 795 } 799 796 800 - static ssize_t set_trigger(struct sys_device *s,const char *buf,size_t siz) 797 + static ssize_t set_trigger(struct sys_device *s, struct sysdev_attribute *attr, 798 + const char *buf,size_t siz) 801 799 { 802 800 char *p; 803 801 int len;
+1
arch/x86/kernel/cpu/mcheck/therm_throt.c
··· 35 35 36 36 #define define_therm_throt_sysdev_show_func(name) \ 37 37 static ssize_t therm_throt_sysdev_show_##name(struct sys_device *dev, \ 38 + struct sysdev_attribute *attr, \ 38 39 char *buf) \ 39 40 { \ 40 41 unsigned int cpu = dev->id; \
+7 -3
arch/x86/kernel/microcode.c
··· 644 644 mutex_unlock(&microcode_mutex); 645 645 } 646 646 647 - static ssize_t reload_store(struct sys_device *dev, const char *buf, size_t sz) 647 + static ssize_t reload_store(struct sys_device *dev, 648 + struct sysdev_attribute *attr, 649 + const char *buf, size_t sz) 648 650 { 649 651 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id; 650 652 char *end; ··· 676 674 return sz; 677 675 } 678 676 679 - static ssize_t version_show(struct sys_device *dev, char *buf) 677 + static ssize_t version_show(struct sys_device *dev, 678 + struct sysdev_attribute *attr, char *buf) 680 679 { 681 680 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id; 682 681 683 682 return sprintf(buf, "0x%x\n", uci->rev); 684 683 } 685 684 686 - static ssize_t pf_show(struct sys_device *dev, char *buf) 685 + static ssize_t pf_show(struct sys_device *dev, 686 + struct sysdev_attribute *attr, char *buf) 687 687 { 688 688 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id; 689 689
+6 -4
drivers/base/cpu.c
··· 21 21 static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices); 22 22 23 23 #ifdef CONFIG_HOTPLUG_CPU 24 - static ssize_t show_online(struct sys_device *dev, char *buf) 24 + static ssize_t show_online(struct sys_device *dev, struct sysdev_attribute *attr, 25 + char *buf) 25 26 { 26 27 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 27 28 28 29 return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id)); 29 30 } 30 31 31 - static ssize_t __ref store_online(struct sys_device *dev, const char *buf, 32 - size_t count) 32 + static ssize_t __ref store_online(struct sys_device *dev, struct sysdev_attribute *attr, 33 + const char *buf, size_t count) 33 34 { 34 35 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 35 36 ssize_t ret; ··· 81 80 #ifdef CONFIG_KEXEC 82 81 #include <linux/kexec.h> 83 82 84 - static ssize_t show_crash_notes(struct sys_device *dev, char *buf) 83 + static ssize_t show_crash_notes(struct sys_device *dev, struct sysdev_attribute *attr, 84 + char *buf) 85 85 { 86 86 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 87 87 ssize_t rc;
+8 -4
drivers/base/memory.c
··· 92 92 * uses. 93 93 */ 94 94 95 - static ssize_t show_mem_phys_index(struct sys_device *dev, char *buf) 95 + static ssize_t show_mem_phys_index(struct sys_device *dev, 96 + struct sysdev_attribute *attr, char *buf) 96 97 { 97 98 struct memory_block *mem = 98 99 container_of(dev, struct memory_block, sysdev); ··· 103 102 /* 104 103 * online, offline, going offline, etc. 105 104 */ 106 - static ssize_t show_mem_state(struct sys_device *dev, char *buf) 105 + static ssize_t show_mem_state(struct sys_device *dev, 106 + struct sysdev_attribute *attr, char *buf) 107 107 { 108 108 struct memory_block *mem = 109 109 container_of(dev, struct memory_block, sysdev); ··· 219 217 } 220 218 221 219 static ssize_t 222 - store_mem_state(struct sys_device *dev, const char *buf, size_t count) 220 + store_mem_state(struct sys_device *dev, 221 + struct sysdev_attribute *attr, const char *buf, size_t count) 223 222 { 224 223 struct memory_block *mem; 225 224 unsigned int phys_section_nr; ··· 251 248 * s.t. if I offline all of these sections I can then 252 249 * remove the physical device? 253 250 */ 254 - static ssize_t show_phys_device(struct sys_device *dev, char *buf) 251 + static ssize_t show_phys_device(struct sys_device *dev, 252 + struct sysdev_attribute *attr, char *buf) 255 253 { 256 254 struct memory_block *mem = 257 255 container_of(dev, struct memory_block, sysdev);
+10 -5
drivers/base/node.c
··· 36 36 return len; 37 37 } 38 38 39 - static inline ssize_t node_read_cpumask(struct sys_device *dev, char *buf) 39 + static inline ssize_t node_read_cpumask(struct sys_device *dev, 40 + struct sysdev_attribute *attr, char *buf) 40 41 { 41 42 return node_read_cpumap(dev, 0, buf); 42 43 } 43 - static inline ssize_t node_read_cpulist(struct sys_device *dev, char *buf) 44 + static inline ssize_t node_read_cpulist(struct sys_device *dev, 45 + struct sysdev_attribute *attr, char *buf) 44 46 { 45 47 return node_read_cpumap(dev, 1, buf); 46 48 } ··· 51 49 static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL); 52 50 53 51 #define K(x) ((x) << (PAGE_SHIFT - 10)) 54 - static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) 52 + static ssize_t node_read_meminfo(struct sys_device * dev, 53 + struct sysdev_attribute *attr, char * buf) 55 54 { 56 55 int n; 57 56 int nid = dev->id; ··· 115 112 #undef K 116 113 static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL); 117 114 118 - static ssize_t node_read_numastat(struct sys_device * dev, char * buf) 115 + static ssize_t node_read_numastat(struct sys_device * dev, 116 + struct sysdev_attribute *attr, char * buf) 119 117 { 120 118 return sprintf(buf, 121 119 "numa_hit %lu\n" ··· 134 130 } 135 131 static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL); 136 132 137 - static ssize_t node_read_distance(struct sys_device * dev, char * buf) 133 + static ssize_t node_read_distance(struct sys_device * dev, 134 + struct sysdev_attribute *attr, char * buf) 138 135 { 139 136 int nid = dev->id; 140 137 int len = 0;
+2 -2
drivers/base/sys.c
··· 36 36 struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr); 37 37 38 38 if (sysdev_attr->show) 39 - return sysdev_attr->show(sysdev, buffer); 39 + return sysdev_attr->show(sysdev, sysdev_attr, buffer); 40 40 return -EIO; 41 41 } 42 42 ··· 49 49 struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr); 50 50 51 51 if (sysdev_attr->store) 52 - return sysdev_attr->store(sysdev, buffer, count); 52 + return sysdev_attr->store(sysdev, sysdev_attr, buffer, count); 53 53 return -EIO; 54 54 } 55 55
+12 -5
drivers/base/topology.c
··· 34 34 static SYSDEV_ATTR(_name, 0444, show_##_name, NULL) 35 35 36 36 #define define_id_show_func(name) \ 37 - static ssize_t show_##name(struct sys_device *dev, char *buf) \ 37 + static ssize_t show_##name(struct sys_device *dev, \ 38 + struct sysdev_attribute *attr, char *buf) \ 38 39 { \ 39 40 unsigned int cpu = dev->id; \ 40 41 return sprintf(buf, "%d\n", topology_##name(cpu)); \ ··· 60 59 61 60 #ifdef arch_provides_topology_pointers 62 61 #define define_siblings_show_map(name) \ 63 - static ssize_t show_##name(struct sys_device *dev, char *buf) \ 62 + static ssize_t show_##name(struct sys_device *dev, \ 63 + struct sysdev_attribute *attr, char *buf) \ 64 64 { \ 65 65 unsigned int cpu = dev->id; \ 66 66 return show_cpumap(0, &(topology_##name(cpu)), buf); \ 67 67 } 68 68 69 69 #define define_siblings_show_list(name) \ 70 - static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ 70 + static ssize_t show_##name##_list(struct sys_device *dev, \ 71 + struct sysdev_attribute *attr, \ 72 + char *buf) \ 71 73 { \ 72 74 unsigned int cpu = dev->id; \ 73 75 return show_cpumap(1, &(topology_##name(cpu)), buf); \ ··· 78 74 79 75 #else 80 76 #define define_siblings_show_map(name) \ 81 - static ssize_t show_##name(struct sys_device *dev, char *buf) \ 77 + static ssize_t show_##name(struct sys_device *dev, \ 78 + struct sysdev_attribute *attr, char *buf) \ 82 79 { \ 83 80 unsigned int cpu = dev->id; \ 84 81 cpumask_t mask = topology_##name(cpu); \ ··· 87 82 } 88 83 89 84 #define define_siblings_show_list(name) \ 90 - static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ 85 + static ssize_t show_##name##_list(struct sys_device *dev, \ 86 + struct sysdev_attribute *attr, \ 87 + char *buf) \ 91 88 { \ 92 89 unsigned int cpu = dev->id; \ 93 90 cpumask_t mask = topology_##name(cpu); \
+7 -3
drivers/cpuidle/sysfs.c
··· 21 21 } 22 22 __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); 23 23 24 - static ssize_t show_available_governors(struct sys_device *dev, char *buf) 24 + static ssize_t show_available_governors(struct sys_device *dev, 25 + struct sysdev_attribute *attr, char *buf) 25 26 { 26 27 ssize_t i = 0; 27 28 struct cpuidle_governor *tmp; ··· 40 39 return i; 41 40 } 42 41 43 - static ssize_t show_current_driver(struct sys_device *dev, char *buf) 42 + static ssize_t show_current_driver(struct sys_device *dev, 43 + struct sysdev_attribute *attr, char *buf) 44 44 { 45 45 ssize_t ret; 46 46 ··· 55 53 return ret; 56 54 } 57 55 58 - static ssize_t show_current_governor(struct sys_device *dev, char *buf) 56 + static ssize_t show_current_governor(struct sys_device *dev, 57 + struct sysdev_attribute *attr, char *buf) 59 58 { 60 59 ssize_t ret; 61 60 ··· 71 68 } 72 69 73 70 static ssize_t store_current_governor(struct sys_device *dev, 71 + struct sysdev_attribute *attr, 74 72 const char *buf, size_t count) 75 73 { 76 74 char gov_name[CPUIDLE_NAME_LEN];
+1
drivers/xen/balloon.c
··· 610 610 } 611 611 612 612 static ssize_t store_target_kb(struct sys_device *dev, 613 + struct sysdev_attribute *attr, 613 614 const char *buf, 614 615 size_t count) 615 616 {
+3 -2
include/linux/sysdev.h
··· 99 99 100 100 struct sysdev_attribute { 101 101 struct attribute attr; 102 - ssize_t (*show)(struct sys_device *, char *); 103 - ssize_t (*store)(struct sys_device *, const char *, size_t); 102 + ssize_t (*show)(struct sys_device *, struct sysdev_attribute *, char *); 103 + ssize_t (*store)(struct sys_device *, struct sysdev_attribute *, 104 + const char *, size_t); 104 105 }; 105 106 106 107
+4 -3
kernel/rtmutex-tester.c
··· 297 297 * 298 298 * opcode:data 299 299 */ 300 - static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf, 301 - size_t count) 300 + static ssize_t sysfs_test_command(struct sys_device *dev, struct sysdev_attribute *attr, 301 + const char *buf, size_t count) 302 302 { 303 303 struct sched_param schedpar; 304 304 struct test_thread_data *td; ··· 360 360 * @dev: thread to query 361 361 * @buf: char buffer to be filled with thread status info 362 362 */ 363 - static ssize_t sysfs_test_status(struct sys_device *dev, char *buf) 363 + static ssize_t sysfs_test_status(struct sys_device *dev, struct sysdev_attribute *attr, 364 + char *buf) 364 365 { 365 366 struct test_thread_data *td; 366 367 struct task_struct *tsk;
+6 -2
kernel/sched.c
··· 7737 7737 } 7738 7738 7739 7739 #ifdef CONFIG_SCHED_MC 7740 - static ssize_t sched_mc_power_savings_show(struct sys_device *dev, char *page) 7740 + static ssize_t sched_mc_power_savings_show(struct sys_device *dev, 7741 + struct sysdev_attribute *attr, char *page) 7741 7742 { 7742 7743 return sprintf(page, "%u\n", sched_mc_power_savings); 7743 7744 } 7744 7745 static ssize_t sched_mc_power_savings_store(struct sys_device *dev, 7746 + struct sysdev_attribute *attr, 7745 7747 const char *buf, size_t count) 7746 7748 { 7747 7749 return sched_power_savings_store(buf, count, 0); ··· 7753 7751 #endif 7754 7752 7755 7753 #ifdef CONFIG_SCHED_SMT 7756 - static ssize_t sched_smt_power_savings_show(struct sys_device *dev, char *page) 7754 + static ssize_t sched_smt_power_savings_show(struct sys_device *dev, 7755 + struct sysdev_attribute *attr, char *page) 7757 7756 { 7758 7757 return sprintf(page, "%u\n", sched_smt_power_savings); 7759 7758 } 7760 7759 static ssize_t sched_smt_power_savings_store(struct sys_device *dev, 7760 + struct sysdev_attribute *attr, 7761 7761 const char *buf, size_t count) 7762 7762 { 7763 7763 return sched_power_savings_store(buf, count, 1);
+6 -2
kernel/time/clocksource.c
··· 376 376 * Provides sysfs interface for listing current clocksource. 377 377 */ 378 378 static ssize_t 379 - sysfs_show_current_clocksources(struct sys_device *dev, char *buf) 379 + sysfs_show_current_clocksources(struct sys_device *dev, 380 + struct sysdev_attribute *attr, char *buf) 380 381 { 381 382 ssize_t count = 0; 382 383 ··· 398 397 * clocksource selction. 399 398 */ 400 399 static ssize_t sysfs_override_clocksource(struct sys_device *dev, 400 + struct sysdev_attribute *attr, 401 401 const char *buf, size_t count) 402 402 { 403 403 struct clocksource *ovr = NULL; ··· 451 449 * Provides sysfs interface for listing registered clocksources 452 450 */ 453 451 static ssize_t 454 - sysfs_show_available_clocksources(struct sys_device *dev, char *buf) 452 + sysfs_show_available_clocksources(struct sys_device *dev, 453 + struct sysdev_attribute *attr, 454 + char *buf) 455 455 { 456 456 struct clocksource *src; 457 457 ssize_t count = 0;