Skip to content

Commit 583a22e

Browse files
Alexey DobriyanIngo Molnar
authored andcommitted
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>
1 parent 05bafda commit 583a22e

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

‎kernel/profile.c‎

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -442,48 +442,51 @@ void profile_tick(int type)
442442

443443
#ifdef CONFIG_PROC_FS
444444
#include <linux/proc_fs.h>
445+
#include <linux/seq_file.h>
445446
#include <asm/uaccess.h>
446447

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)
449449
{
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;
455453
}
456454

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)
456+
{
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)
459462
{
460-
struct cpumask *mask = data;
461-
unsigned long full_count = count, err;
462463
cpumask_var_t new_value;
464+
int err;
463465

464466
if (!alloc_cpumask_var(&new_value, GFP_KERNEL))
465467
return -ENOMEM;
466468

467469
err = cpumask_parse_user(buffer, count, new_value);
468470
if (!err) {
469-
cpumask_copy(mask, new_value);
470-
err = full_count;
471+
cpumask_copy(prof_cpu_mask, new_value);
472+
err = count;
471473
}
472474
free_cpumask_var(new_value);
473475
return err;
474476
}
475477

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+
476486
void create_prof_cpu_mask(struct proc_dir_entry *root_irq_dir)
477487
{
478-
struct proc_dir_entry *entry;
479-
480488
/* 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);
487490
}
488491

489492
/*

0 commit comments

Comments
 (0)