2441 if (it->index >= it->max)
2442 return NULL;
2443 return it;
2444}
2445
2446static void * dev_seq_next(struct seq_file *s, void *v, loff_t *pos)
2447{
2448 struct sg_proc_deviter * it = s->private;
2449
2450 *pos = ++it->index;
2451 return (it->index < it->max) ? it : NULL;
2452}
2453
2454static void dev_seq_stop(struct seq_file *s, void *v)
2455{
2456 kfree(s->private);
2457}
2458
2459static int sg_proc_open_dev(struct inode *inode, struct file *file)
2460{
2461 return seq_open(file, &dev_seq_ops);
2462}
2463
2464static int sg_proc_seq_show_dev(struct seq_file *s, void *v)
2465{
2466 struct sg_proc_deviter * it = (struct sg_proc_deviter *) v;
2467 Sg_device *sdp;
2468 struct scsi_device *scsidp;
2469
2470 sdp = it ? sg_get_dev(it->index) : NULL;
2471 if (sdp && (scsidp = sdp->device) && (!sdp->detached))
2472 seq_printf(s, "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
2473 scsidp->host->host_no, scsidp->channel,
2474 scsidp->id, scsidp->lun, (int) scsidp->type,
2475 1,
2476 (int) scsidp->queue_depth,
2477 (int) scsidp->device_busy,
2478 (int) scsi_device_online(scsidp));
2479 else
2480 seq_printf(s, "-1\t-1\t-1\t-1\t-1\t-1\t-1\t-1\t-1\n");
2481 return 0;