diff options
author | Christoph Hellwig <hch@lst.de> | 2018-05-15 09:57:23 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2018-05-16 01:23:35 -0400 |
commit | 3f3942aca6da351a12543aa776467791b63b3a78 (patch) | |
tree | 31030e086ea36920e07078ea2289b9b72c0b2939 /kernel/irq/proc.c | |
parent | 44414d82cfe0f68cb59d0a42f599ccd893ae0032 (diff) |
proc: introduce proc_create_single{,_data}
Variants of proc_create{,_data} that directly take a seq_file show
callback and drastically reduces the boilerplate code in the callers.
All trivial callers converted over.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'kernel/irq/proc.c')
-rw-r--r-- | kernel/irq/proc.c | 82 |
1 files changed, 10 insertions, 72 deletions
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 7cb091d81d91..37eda10f5c36 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c | |||
@@ -185,11 +185,6 @@ static int irq_affinity_list_proc_open(struct inode *inode, struct file *file) | |||
185 | return single_open(file, irq_affinity_list_proc_show, PDE_DATA(inode)); | 185 | return single_open(file, irq_affinity_list_proc_show, PDE_DATA(inode)); |
186 | } | 186 | } |
187 | 187 | ||
188 | static int irq_affinity_hint_proc_open(struct inode *inode, struct file *file) | ||
189 | { | ||
190 | return single_open(file, irq_affinity_hint_proc_show, PDE_DATA(inode)); | ||
191 | } | ||
192 | |||
193 | static const struct file_operations irq_affinity_proc_fops = { | 188 | static const struct file_operations irq_affinity_proc_fops = { |
194 | .open = irq_affinity_proc_open, | 189 | .open = irq_affinity_proc_open, |
195 | .read = seq_read, | 190 | .read = seq_read, |
@@ -198,13 +193,6 @@ static const struct file_operations irq_affinity_proc_fops = { | |||
198 | .write = irq_affinity_proc_write, | 193 | .write = irq_affinity_proc_write, |
199 | }; | 194 | }; |
200 | 195 | ||
201 | static const struct file_operations irq_affinity_hint_proc_fops = { | ||
202 | .open = irq_affinity_hint_proc_open, | ||
203 | .read = seq_read, | ||
204 | .llseek = seq_lseek, | ||
205 | .release = single_release, | ||
206 | }; | ||
207 | |||
208 | static const struct file_operations irq_affinity_list_proc_fops = { | 196 | static const struct file_operations irq_affinity_list_proc_fops = { |
209 | .open = irq_affinity_list_proc_open, | 197 | .open = irq_affinity_list_proc_open, |
210 | .read = seq_read, | 198 | .read = seq_read, |
@@ -223,32 +211,6 @@ static int irq_effective_aff_list_proc_show(struct seq_file *m, void *v) | |||
223 | { | 211 | { |
224 | return show_irq_affinity(EFFECTIVE_LIST, m); | 212 | return show_irq_affinity(EFFECTIVE_LIST, m); |
225 | } | 213 | } |
226 | |||
227 | static int irq_effective_aff_proc_open(struct inode *inode, struct file *file) | ||
228 | { | ||
229 | return single_open(file, irq_effective_aff_proc_show, PDE_DATA(inode)); | ||
230 | } | ||
231 | |||
232 | static int irq_effective_aff_list_proc_open(struct inode *inode, | ||
233 | struct file *file) | ||
234 | { | ||
235 | return single_open(file, irq_effective_aff_list_proc_show, | ||
236 | PDE_DATA(inode)); | ||
237 | } | ||
238 | |||
239 | static const struct file_operations irq_effective_aff_proc_fops = { | ||
240 | .open = irq_effective_aff_proc_open, | ||
241 | .read = seq_read, | ||
242 | .llseek = seq_lseek, | ||
243 | .release = single_release, | ||
244 | }; | ||
245 | |||
246 | static const struct file_operations irq_effective_aff_list_proc_fops = { | ||
247 | .open = irq_effective_aff_list_proc_open, | ||
248 | .read = seq_read, | ||
249 | .llseek = seq_lseek, | ||
250 | .release = single_release, | ||
251 | }; | ||
252 | #endif | 214 | #endif |
253 | 215 | ||
254 | static int default_affinity_show(struct seq_file *m, void *v) | 216 | static int default_affinity_show(struct seq_file *m, void *v) |
@@ -313,18 +275,6 @@ static int irq_node_proc_show(struct seq_file *m, void *v) | |||
313 | seq_printf(m, "%d\n", irq_desc_get_node(desc)); | 275 | seq_printf(m, "%d\n", irq_desc_get_node(desc)); |
314 | return 0; | 276 | return 0; |
315 | } | 277 | } |
316 | |||
317 | static int irq_node_proc_open(struct inode *inode, struct file *file) | ||
318 | { | ||
319 | return single_open(file, irq_node_proc_show, PDE_DATA(inode)); | ||
320 | } | ||
321 | |||
322 | static const struct file_operations irq_node_proc_fops = { | ||
323 | .open = irq_node_proc_open, | ||
324 | .read = seq_read, | ||
325 | .llseek = seq_lseek, | ||
326 | .release = single_release, | ||
327 | }; | ||
328 | #endif | 278 | #endif |
329 | 279 | ||
330 | static int irq_spurious_proc_show(struct seq_file *m, void *v) | 280 | static int irq_spurious_proc_show(struct seq_file *m, void *v) |
@@ -337,18 +287,6 @@ static int irq_spurious_proc_show(struct seq_file *m, void *v) | |||
337 | return 0; | 287 | return 0; |
338 | } | 288 | } |
339 | 289 | ||
340 | static int irq_spurious_proc_open(struct inode *inode, struct file *file) | ||
341 | { | ||
342 | return single_open(file, irq_spurious_proc_show, PDE_DATA(inode)); | ||
343 | } | ||
344 | |||
345 | static const struct file_operations irq_spurious_proc_fops = { | ||
346 | .open = irq_spurious_proc_open, | ||
347 | .read = seq_read, | ||
348 | .llseek = seq_lseek, | ||
349 | .release = single_release, | ||
350 | }; | ||
351 | |||
352 | #define MAX_NAMELEN 128 | 290 | #define MAX_NAMELEN 128 |
353 | 291 | ||
354 | static int name_unique(unsigned int irq, struct irqaction *new_action) | 292 | static int name_unique(unsigned int irq, struct irqaction *new_action) |
@@ -421,24 +359,24 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc) | |||
421 | &irq_affinity_proc_fops, irqp); | 359 | &irq_affinity_proc_fops, irqp); |
422 | 360 | ||
423 | /* create /proc/irq/<irq>/affinity_hint */ | 361 | /* create /proc/irq/<irq>/affinity_hint */ |
424 | proc_create_data("affinity_hint", 0444, desc->dir, | 362 | proc_create_single_data("affinity_hint", 0444, desc->dir, |
425 | &irq_affinity_hint_proc_fops, irqp); | 363 | irq_affinity_hint_proc_show, irqp); |
426 | 364 | ||
427 | /* create /proc/irq/<irq>/smp_affinity_list */ | 365 | /* create /proc/irq/<irq>/smp_affinity_list */ |
428 | proc_create_data("smp_affinity_list", 0644, desc->dir, | 366 | proc_create_data("smp_affinity_list", 0644, desc->dir, |
429 | &irq_affinity_list_proc_fops, irqp); | 367 | &irq_affinity_list_proc_fops, irqp); |
430 | 368 | ||
431 | proc_create_data("node", 0444, desc->dir, | 369 | proc_create_single_data("node", 0444, desc->dir, irq_node_proc_show, |
432 | &irq_node_proc_fops, irqp); | 370 | irqp); |
433 | # ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK | 371 | # ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK |
434 | proc_create_data("effective_affinity", 0444, desc->dir, | 372 | proc_create_single_data("effective_affinity", 0444, desc->dir, |
435 | &irq_effective_aff_proc_fops, irqp); | 373 | irq_effective_aff_proc_show, irqp); |
436 | proc_create_data("effective_affinity_list", 0444, desc->dir, | 374 | proc_create_single_data("effective_affinity_list", 0444, desc->dir, |
437 | &irq_effective_aff_list_proc_fops, irqp); | 375 | irq_effective_aff_list_proc_show, irqp); |
438 | # endif | 376 | # endif |
439 | #endif | 377 | #endif |
440 | proc_create_data("spurious", 0444, desc->dir, | 378 | proc_create_single_data("spurious", 0444, desc->dir, |
441 | &irq_spurious_proc_fops, (void *)(long)irq); | 379 | irq_spurious_proc_show, (void *)(long)irq); |
442 | 380 | ||
443 | out_unlock: | 381 | out_unlock: |
444 | mutex_unlock(®ister_lock); | 382 | mutex_unlock(®ister_lock); |