2 * drivers/s390/char/tape.c
3 * tape device driver for S/390 and zSeries tapes.
5 * S390 and zSeries version
6 * Copyright (C) 2001 IBM Corporation
7 * Author(s): Carsten Otte <cotte@de.ibm.com>
8 * Michael Holzheu <holzheu@de.ibm.com>
9 * Tuan Ngo-Anh <ngoanh@de.ibm.com>
14 #include <linux/config.h>
15 #include <linux/module.h>
16 #include <linux/vmalloc.h>
17 #include <linux/seq_file.h>
18 #include <linux/proc_fs.h>
20 #define TAPE_DBF_AREA tape_core_dbf
24 #define PRINTK_HEADER "TAPE_PROC: "
26 static const char *tape_med_st_verbose
[MS_SIZE
] =
28 [MS_UNKNOWN
] = "UNKNOWN ",
29 [MS_LOADED
] = "LOADED ",
30 [MS_UNLOADED
] = "UNLOADED"
33 /* our proc tapedevices entry */
34 static struct proc_dir_entry
*tape_proc_devices
;
37 * Show function for /proc/tapedevices
39 static int tape_proc_show(struct seq_file
*m
, void *v
)
41 struct tape_device
*device
;
42 struct tape_request
*request
;
46 n
= (unsigned long) v
- 1;
48 seq_printf(m
, "TapeNo\tBusID CuType/Model\t"
49 "DevType/Model\tBlkSize\tState\tOp\tMedState\n");
51 device
= tape_get_device(n
);
54 spin_lock_irq(get_ccwdev_lock(device
->cdev
));
55 seq_printf(m
, "%d\t", (int) n
);
56 seq_printf(m
, "%-10.10s ", device
->cdev
->dev
.bus_id
);
57 seq_printf(m
, "%04X/", device
->cdev
->id
.cu_type
);
58 seq_printf(m
, "%02X\t", device
->cdev
->id
.cu_model
);
59 seq_printf(m
, "%04X/", device
->cdev
->id
.dev_type
);
60 seq_printf(m
, "%02X\t\t", device
->cdev
->id
.dev_model
);
61 if (device
->char_data
.block_size
== 0)
62 seq_printf(m
, "auto\t");
64 seq_printf(m
, "%i\t", device
->char_data
.block_size
);
65 if (device
->tape_state
>= 0 &&
66 device
->tape_state
< TS_SIZE
)
67 str
= tape_state_verbose
[device
->tape_state
];
70 seq_printf(m
, "%s\t", str
);
71 if (!list_empty(&device
->req_queue
)) {
72 request
= list_entry(device
->req_queue
.next
,
73 struct tape_request
, list
);
74 str
= tape_op_verbose
[request
->op
];
77 seq_printf(m
, "%s\t", str
);
78 seq_printf(m
, "%s\n", tape_med_st_verbose
[device
->medium_state
]);
79 spin_unlock_irq(get_ccwdev_lock(device
->cdev
));
80 tape_put_device(device
);
84 static void *tape_proc_start(struct seq_file
*m
, loff_t
*pos
)
86 if (*pos
>= 256 / TAPE_MINORS_PER_DEV
)
88 return (void *)((unsigned long) *pos
+ 1);
91 static void *tape_proc_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
94 return tape_proc_start(m
, pos
);
97 static void tape_proc_stop(struct seq_file
*m
, void *v
)
101 static struct seq_operations tape_proc_seq
= {
102 .start
= tape_proc_start
,
103 .next
= tape_proc_next
,
104 .stop
= tape_proc_stop
,
105 .show
= tape_proc_show
,
108 static int tape_proc_open(struct inode
*inode
, struct file
*file
)
110 return seq_open(file
, &tape_proc_seq
);
113 static struct file_operations tape_proc_ops
=
115 .open
= tape_proc_open
,
118 .release
= seq_release
,
122 * Initialize procfs stuff on startup
128 create_proc_entry ("tapedevices", S_IFREG
| S_IRUGO
| S_IWUSR
,
130 if (tape_proc_devices
== NULL
) {
131 PRINT_WARN("tape: Cannot register procfs entry tapedevices\n");
134 tape_proc_devices
->proc_fops
= &tape_proc_ops
;
135 tape_proc_devices
->owner
= THIS_MODULE
;
139 * Cleanup all stuff registered to the procfs
142 tape_proc_cleanup(void)
144 if (tape_proc_devices
!= NULL
)
145 remove_proc_entry ("tapedevices", &proc_root
);