Commit 583a22e7c154dc0a3938db522696b4bc7f098f59

Authored by Alexey Dobriyan
Committed by Ingo Molnar
1 parent 05bafda856

kernel/profile.c: Switch /proc/irq/prof_cpu_mask to seq_file

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 1 changed file with 24 additions and 21 deletions Side-by-side Diff

... ... @@ -442,48 +442,51 @@
442 442  
443 443 #ifdef CONFIG_PROC_FS
444 444 #include <linux/proc_fs.h>
  445 +#include <linux/seq_file.h>
445 446 #include <asm/uaccess.h>
446 447  
447   -static int prof_cpu_mask_read_proc(char *page, char **start, off_t off,
448   - int count, int *eof, void *data)
  448 +static int prof_cpu_mask_proc_show(struct seq_file *m, void *v)
449 449 {
450   - int len = cpumask_scnprintf(page, count, data);
451   - if (count - len < 2)
452   - return -EINVAL;
453   - len += sprintf(page + len, "\n");
454   - return len;
  450 + seq_cpumask(m, prof_cpu_mask);
  451 + seq_putc(m, '\n');
  452 + return 0;
455 453 }
456 454  
457   -static int prof_cpu_mask_write_proc(struct file *file,
458   - const char __user *buffer, unsigned long count, void *data)
  455 +static int prof_cpu_mask_proc_open(struct inode *inode, struct file *file)
459 456 {
460   - struct cpumask *mask = data;
461   - unsigned long full_count = count, err;
  457 + return single_open(file, prof_cpu_mask_proc_show, NULL);
  458 +}
  459 +
  460 +static ssize_t prof_cpu_mask_proc_write(struct file *file,
  461 + const char __user *buffer, size_t count, loff_t *pos)
  462 +{
462 463 cpumask_var_t new_value;
  464 + int err;
463 465  
464 466 if (!alloc_cpumask_var(&new_value, GFP_KERNEL))
465 467 return -ENOMEM;
466 468  
467 469 err = cpumask_parse_user(buffer, count, new_value);
468 470 if (!err) {
469   - cpumask_copy(mask, new_value);
470   - err = full_count;
  471 + cpumask_copy(prof_cpu_mask, new_value);
  472 + err = count;
471 473 }
472 474 free_cpumask_var(new_value);
473 475 return err;
474 476 }
475 477  
  478 +static const struct file_operations prof_cpu_mask_proc_fops = {
  479 + .open = prof_cpu_mask_proc_open,
  480 + .read = seq_read,
  481 + .llseek = seq_lseek,
  482 + .release = single_release,
  483 + .write = prof_cpu_mask_proc_write,
  484 +};
  485 +
476 486 void create_prof_cpu_mask(struct proc_dir_entry *root_irq_dir)
477 487 {
478   - struct proc_dir_entry *entry;
479   -
480 488 /* create /proc/irq/prof_cpu_mask */
481   - entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
482   - if (!entry)
483   - return;
484   - entry->data = prof_cpu_mask;
485   - entry->read_proc = prof_cpu_mask_read_proc;
486   - entry->write_proc = prof_cpu_mask_write_proc;
  489 + proc_create("prof_cpu_mask", 0600, root_irq_dir, &prof_cpu_mask_proc_fops);
487 490 }
488 491  
489 492 /*