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

cpqarray: switch to seq_file

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Chirag Kantharia <chirag.kantharia@hp.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

authored by

Alexey Dobriyan and committed by
Jens Axboe
ff2c3de3 17d857be

+30 -33
+30 -33
drivers/block/cpqarray.c
··· 32 32 #include <linux/blkpg.h> 33 33 #include <linux/timer.h> 34 34 #include <linux/proc_fs.h> 35 + #include <linux/seq_file.h> 35 36 #include <linux/init.h> 36 37 #include <linux/hdreg.h> 37 38 #include <linux/spinlock.h> ··· 178 177 179 178 #ifdef CONFIG_PROC_FS 180 179 static void ida_procinit(int i); 181 - static int ida_proc_get_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data); 182 180 #else 183 181 static void ida_procinit(int i) {} 184 182 #endif ··· 206 206 #ifdef CONFIG_PROC_FS 207 207 208 208 static struct proc_dir_entry *proc_array; 209 + static const struct file_operations ida_proc_fops; 209 210 210 211 /* 211 212 * Get us a file in /proc/array that says something about each controller. ··· 219 218 if (!proc_array) return; 220 219 } 221 220 222 - create_proc_read_entry(hba[i]->devname, 0, proc_array, 223 - ida_proc_get_info, hba[i]); 221 + proc_create_data(hba[i]->devname, 0, proc_array, &ida_proc_fops, hba[i]); 224 222 } 225 223 226 224 /* 227 225 * Report information about this controller. 228 226 */ 229 - static int ida_proc_get_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data) 227 + static int ida_proc_show(struct seq_file *m, void *v) 230 228 { 231 - off_t pos = 0; 232 - off_t len = 0; 233 - int size, i, ctlr; 234 - ctlr_info_t *h = (ctlr_info_t*)data; 229 + int i, ctlr; 230 + ctlr_info_t *h = (ctlr_info_t*)m->private; 235 231 drv_info_t *drv; 236 232 #ifdef CPQ_PROC_PRINT_QUEUES 237 233 cmdlist_t *c; ··· 236 238 #endif 237 239 238 240 ctlr = h->ctlr; 239 - size = sprintf(buffer, "%s: Compaq %s Controller\n" 241 + seq_printf(m, "%s: Compaq %s Controller\n" 240 242 " Board ID: 0x%08lx\n" 241 243 " Firmware Revision: %c%c%c%c\n" 242 244 " Controller Sig: 0x%08lx\n" ··· 256 258 h->log_drives, h->phys_drives, 257 259 h->Qdepth, h->maxQsinceinit); 258 260 259 - pos += size; len += size; 260 - 261 - size = sprintf(buffer+len, "Logical Drive Info:\n"); 262 - pos += size; len += size; 261 + seq_puts(m, "Logical Drive Info:\n"); 263 262 264 263 for(i=0; i<h->log_drives; i++) { 265 264 drv = &h->drv[i]; 266 - size = sprintf(buffer+len, "ida/c%dd%d: blksz=%d nr_blks=%d\n", 265 + seq_printf(m, "ida/c%dd%d: blksz=%d nr_blks=%d\n", 267 266 ctlr, i, drv->blk_size, drv->nr_blks); 268 - pos += size; len += size; 269 267 } 270 268 271 269 #ifdef CPQ_PROC_PRINT_QUEUES 272 270 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags); 273 - size = sprintf(buffer+len, "\nCurrent Queues:\n"); 274 - pos += size; len += size; 271 + seq_puts(m, "\nCurrent Queues:\n"); 275 272 276 273 c = h->reqQ; 277 - size = sprintf(buffer+len, "reqQ = %p", c); pos += size; len += size; 274 + seq_printf(m, "reqQ = %p", c); 278 275 if (c) c=c->next; 279 276 while(c && c != h->reqQ) { 280 - size = sprintf(buffer+len, "->%p", c); 281 - pos += size; len += size; 277 + seq_printf(m, "->%p", c); 282 278 c=c->next; 283 279 } 284 280 285 281 c = h->cmpQ; 286 - size = sprintf(buffer+len, "\ncmpQ = %p", c); pos += size; len += size; 282 + seq_printf(m, "\ncmpQ = %p", c); 287 283 if (c) c=c->next; 288 284 while(c && c != h->cmpQ) { 289 - size = sprintf(buffer+len, "->%p", c); 290 - pos += size; len += size; 285 + seq_printf(m, "->%p", c); 291 286 c=c->next; 292 287 } 293 288 294 - size = sprintf(buffer+len, "\n"); pos += size; len += size; 289 + seq_putc(m, '\n'); 295 290 spin_unlock_irqrestore(IDA_LOCK(h->ctlr), flags); 296 291 #endif 297 - size = sprintf(buffer+len, "nr_allocs = %d\nnr_frees = %d\n", 292 + seq_printf(m, "nr_allocs = %d\nnr_frees = %d\n", 298 293 h->nr_allocs, h->nr_frees); 299 - pos += size; len += size; 300 - 301 - *eof = 1; 302 - *start = buffer+offset; 303 - len -= offset; 304 - if (len>length) 305 - len = length; 306 - return len; 294 + return 0; 307 295 } 296 + 297 + static int ida_proc_open(struct inode *inode, struct file *file) 298 + { 299 + return single_open(file, ida_proc_show, PDE(inode)->data); 300 + } 301 + 302 + static const struct file_operations ida_proc_fops = { 303 + .owner = THIS_MODULE, 304 + .open = ida_proc_open, 305 + .read = seq_read, 306 + .llseek = seq_lseek, 307 + .release = single_release, 308 + }; 308 309 #endif /* CONFIG_PROC_FS */ 309 310 310 311 module_param_array(eisa, int, NULL, 0);