From 217bfb5190813d97e6003f7692f8014655ffc02a Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Fri, 27 Nov 2009 06:51:12 +0000 Subject: parisc: convert /proc/pdc/{lcd,led} to seq_file Convert code away from ->read_proc/->write_proc interfaces. Switch to proc_create()/proc_create_data() which make addition of proc entries reliable wrt NULL ->proc_fops, NULL ->data and so on. Problem with ->read_proc et al is described here commit 786d7e1612f0b0adb6046f19b906609e4fe8b1ba "Fix rmmod/read/write races in /proc entries" Signed-off-by: Alexey Dobriyan Reviewed-by: Grant Grundler Signed-off-by: Kyle McMartin --- drivers/parisc/led.c | 59 ++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) (limited to 'drivers') diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index 79caf1ca4a2..188bc8496a2 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -147,41 +148,34 @@ device_initcall(start_task); static void (*led_func_ptr) (unsigned char) __read_mostly; #ifdef CONFIG_PROC_FS -static int led_proc_read(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int led_proc_show(struct seq_file *m, void *v) { - char *out = page; - int len; - - switch ((long)data) + switch ((long)m->private) { case LED_NOLCD: - out += sprintf(out, "Heartbeat: %d\n", led_heartbeat); - out += sprintf(out, "Disk IO: %d\n", led_diskio); - out += sprintf(out, "LAN Rx/Tx: %d\n", led_lanrxtx); + seq_printf(m, "Heartbeat: %d\n", led_heartbeat); + seq_printf(m, "Disk IO: %d\n", led_diskio); + seq_printf(m, "LAN Rx/Tx: %d\n", led_lanrxtx); break; case LED_HASLCD: - out += sprintf(out, "%s\n", lcd_text); + seq_printf(m, "%s\n", lcd_text); break; default: - *eof = 1; return 0; } + return 0; +} - len = out - page - off; - if (len < count) { - *eof = 1; - if (len <= 0) return 0; - } else { - len = count; - } - *start = page + off; - return len; +static int led_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, led_proc_show, PDE(inode)->data); } -static int led_proc_write(struct file *file, const char *buf, - unsigned long count, void *data) + +static ssize_t led_proc_write(struct file *file, const char *buf, + size_t count, loff_t *pos) { + void *data = PDE(file->f_path.dentry->d_inode)->data; char *cur, lbuf[count + 1]; int d; @@ -234,6 +228,15 @@ parse_error: return -EINVAL; } +static const struct file_operations led_proc_fops = { + .owner = THIS_MODULE, + .open = led_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = led_proc_write, +}; + static int __init led_create_procfs(void) { struct proc_dir_entry *proc_pdc_root = NULL; @@ -243,19 +246,15 @@ static int __init led_create_procfs(void) proc_pdc_root = proc_mkdir("pdc", 0); if (!proc_pdc_root) return -1; - ent = create_proc_entry("led", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root); + ent = proc_create_data("led", S_IRUGO|S_IWUSR, proc_pdc_root, + &led_proc_fops, (void *)LED_NOLCD); /* LED */ if (!ent) return -1; - ent->data = (void *)LED_NOLCD; /* LED */ - ent->read_proc = led_proc_read; - ent->write_proc = led_proc_write; if (led_type == LED_HASLCD) { - ent = create_proc_entry("lcd", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root); + ent = proc_create_data("lcd", S_IRUGO|S_IWUSR, proc_pdc_root, + &led_proc_fops, (void *)LED_HASLCD); /* LCD */ if (!ent) return -1; - ent->data = (void *)LED_HASLCD; /* LCD */ - ent->read_proc = led_proc_read; - ent->write_proc = led_proc_write; } return 0; -- cgit v1.2.3 From d0608b54740c82b08056b7611e38a3fd73be3564 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Tue, 17 Nov 2009 22:50:59 +0000 Subject: parisc: Fixup last users of irq_chip->typename The typename member of struct irq_chip was kept for migration purposes and is obsolete since more than 2 years. Fix up the leftovers. Signed-off-by: Thomas Gleixner Signed-off-by: Kyle McMartin --- arch/parisc/kernel/irq.c | 4 ++-- drivers/parisc/dino.c | 2 +- drivers/parisc/eisa.c | 2 +- drivers/parisc/gsc.c | 2 +- drivers/parisc/iosapic.c | 2 +- drivers/parisc/superio.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/arch/parisc/kernel/irq.c b/arch/parisc/kernel/irq.c index f47465e8d04..efbcee5d222 100644 --- a/arch/parisc/kernel/irq.c +++ b/arch/parisc/kernel/irq.c @@ -145,7 +145,7 @@ static int cpu_set_affinity_irq(unsigned int irq, const struct cpumask *dest) #endif static struct irq_chip cpu_interrupt_type = { - .typename = "CPU", + .name = "CPU", .startup = cpu_startup_irq, .shutdown = cpu_disable_irq, .enable = cpu_enable_irq, @@ -192,7 +192,7 @@ int show_interrupts(struct seq_file *p, void *v) seq_printf(p, "%10u ", kstat_irqs(i)); #endif - seq_printf(p, " %14s", irq_desc[i].chip->typename); + seq_printf(p, " %14s", irq_desc[i].chip->name); #ifndef PARISC_IRQ_CR16_COUNTS seq_printf(p, " %s", action->name); diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c index d69bde6a234..c542c7bb745 100644 --- a/drivers/parisc/dino.c +++ b/drivers/parisc/dino.c @@ -354,7 +354,7 @@ static unsigned int dino_startup_irq(unsigned int irq) } static struct irq_chip dino_interrupt_type = { - .typename = "GSC-PCI", + .name = "GSC-PCI", .startup = dino_startup_irq, .shutdown = dino_disable_irq, .enable = dino_enable_irq, diff --git a/drivers/parisc/eisa.c b/drivers/parisc/eisa.c index 51220749cb6..46f503fb7fc 100644 --- a/drivers/parisc/eisa.c +++ b/drivers/parisc/eisa.c @@ -189,7 +189,7 @@ static unsigned int eisa_startup_irq(unsigned int irq) } static struct irq_chip eisa_interrupt_type = { - .typename = "EISA", + .name = "EISA", .startup = eisa_startup_irq, .shutdown = eisa_disable_irq, .enable = eisa_enable_irq, diff --git a/drivers/parisc/gsc.c b/drivers/parisc/gsc.c index 647adc9f85a..c4e1f3c3c2f 100644 --- a/drivers/parisc/gsc.c +++ b/drivers/parisc/gsc.c @@ -149,7 +149,7 @@ static unsigned int gsc_asic_startup_irq(unsigned int irq) } static struct irq_chip gsc_asic_interrupt_type = { - .typename = "GSC-ASIC", + .name = "GSC-ASIC", .startup = gsc_asic_startup_irq, .shutdown = gsc_asic_disable_irq, .enable = gsc_asic_enable_irq, diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c index 88e33355321..c76836727ca 100644 --- a/drivers/parisc/iosapic.c +++ b/drivers/parisc/iosapic.c @@ -730,7 +730,7 @@ static int iosapic_set_affinity_irq(unsigned int irq, #endif static struct irq_chip iosapic_interrupt_type = { - .typename = "IO-SAPIC-level", + .name = "IO-SAPIC-level", .startup = iosapic_startup_irq, .shutdown = iosapic_disable_irq, .enable = iosapic_enable_irq, diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c index 675f04e6597..a35c9c5b89e 100644 --- a/drivers/parisc/superio.c +++ b/drivers/parisc/superio.c @@ -326,7 +326,7 @@ static unsigned int superio_startup_irq(unsigned int irq) } static struct irq_chip superio_interrupt_type = { - .typename = SUPERIO, + .name = SUPERIO, .startup = superio_startup_irq, .shutdown = superio_disable_irq, .enable = superio_enable_irq, -- cgit v1.2.3