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

proc: switch /proc/bus/zorro/devices to seq_file interface

Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
Cc: Josef Sipek <jsipek@fsl.cs.sunysb.edu>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
8331438b c74c120a

+47 -25
+47 -25
drivers/zorro/proc.c
··· 13 13 #include <linux/types.h> 14 14 #include <linux/zorro.h> 15 15 #include <linux/proc_fs.h> 16 + #include <linux/seq_file.h> 16 17 #include <linux/init.h> 17 18 #include <linux/smp_lock.h> 18 19 #include <asm/uaccess.h> ··· 81 80 .read = proc_bus_zorro_read, 82 81 }; 83 82 84 - static int 85 - get_zorro_dev_info(char *buf, char **start, off_t pos, int count) 83 + static void * zorro_seq_start(struct seq_file *m, loff_t *pos) 86 84 { 87 - u_int slot; 88 - off_t at = 0; 89 - int len, cnt; 90 - 91 - for (slot = cnt = 0; slot < zorro_num_autocon && count > cnt; slot++) { 92 - struct zorro_dev *z = &zorro_autocon[slot]; 93 - len = sprintf(buf, "%02x\t%08x\t%08lx\t%08lx\t%02x\n", slot, 94 - z->id, (unsigned long)zorro_resource_start(z), 95 - (unsigned long)zorro_resource_len(z), 96 - z->rom.er_Type); 97 - at += len; 98 - if (at >= pos) { 99 - if (!*start) { 100 - *start = buf + (pos - (at - len)); 101 - cnt = at - pos; 102 - } else 103 - cnt += len; 104 - buf += len; 105 - } 106 - } 107 - return (count > cnt) ? cnt : count; 85 + return (*pos < zorro_num_autocon) ? pos : NULL; 108 86 } 87 + 88 + static void * zorro_seq_next(struct seq_file *m, void *v, loff_t *pos) 89 + { 90 + (*pos)++; 91 + return (*pos < zorro_num_autocon) ? pos : NULL; 92 + } 93 + 94 + static void zorro_seq_stop(struct seq_file *m, void *v) 95 + { 96 + } 97 + 98 + static int zorro_seq_show(struct seq_file *m, void *v) 99 + { 100 + u_int slot = *(loff_t *)v; 101 + struct zorro_dev *z = &zorro_autocon[slot]; 102 + 103 + seq_printf(m, "%02x\t%08x\t%08lx\t%08lx\t%02x\n", slot, z->id, 104 + (unsigned long)zorro_resource_start(z), 105 + (unsigned long)zorro_resource_len(z), 106 + z->rom.er_Type); 107 + return 0; 108 + } 109 + 110 + static const struct seq_operations zorro_devices_seq_ops = { 111 + .start = zorro_seq_start, 112 + .next = zorro_seq_next, 113 + .stop = zorro_seq_stop, 114 + .show = zorro_seq_show, 115 + }; 116 + 117 + static int zorro_devices_proc_open(struct inode *inode, struct file *file) 118 + { 119 + return seq_open(file, &zorro_devices_seq_ops); 120 + } 121 + 122 + static const struct file_operations zorro_devices_proc_fops = { 123 + .owner = THIS_MODULE, 124 + .open = zorro_devices_proc_open, 125 + .read = seq_read, 126 + .llseek = seq_lseek, 127 + .release = seq_release, 128 + }; 109 129 110 130 static struct proc_dir_entry *proc_bus_zorro_dir; 111 131 ··· 151 129 152 130 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(ZORRO)) { 153 131 proc_bus_zorro_dir = proc_mkdir("bus/zorro", NULL); 154 - create_proc_info_entry("devices", 0, proc_bus_zorro_dir, 155 - get_zorro_dev_info); 132 + proc_create("devices", 0, proc_bus_zorro_dir, 133 + &zorro_devices_proc_fops); 156 134 for (slot = 0; slot < zorro_num_autocon; slot++) 157 135 zorro_proc_attach_device(slot); 158 136 }