aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2010-02-26 16:37:50 -0500
committerMartin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com>2010-02-26 16:37:32 -0500
commit34b9243a300736c08dc32eaeb2f359401fcf9c0a (patch)
treeb20eb0bf67e5cf169e378d3686cda83ca418058d /drivers
parent618708ff04f3a7b74f54210bd518aa1d827d8e65 (diff)
[S390] seq_file: convert drivers/s390/
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/s390/block/dasd_proc.c109
-rw-r--r--drivers/s390/crypto/zcrypt_api.c158
2 files changed, 122 insertions, 145 deletions
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index 71f95f54866f..f13a0bdd148c 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -165,51 +165,32 @@ static const struct file_operations dasd_devices_file_ops = {
165 .release = seq_release, 165 .release = seq_release,
166}; 166};
167 167
168static int
169dasd_calc_metrics(char *page, char **start, off_t off,
170 int count, int *eof, int len)
171{
172 len = (len > off) ? len - off : 0;
173 if (len > count)
174 len = count;
175 if (len < count)
176 *eof = 1;
177 *start = page + off;
178 return len;
179}
180
181#ifdef CONFIG_DASD_PROFILE 168#ifdef CONFIG_DASD_PROFILE
182static char * 169static void dasd_statistics_array(struct seq_file *m, unsigned int *array, int factor)
183dasd_statistics_array(char *str, unsigned int *array, int factor)
184{ 170{
185 int i; 171 int i;
186 172
187 for (i = 0; i < 32; i++) { 173 for (i = 0; i < 32; i++) {
188 str += sprintf(str, "%7d ", array[i] / factor); 174 seq_printf(m, "%7d ", array[i] / factor);
189 if (i == 15) 175 if (i == 15)
190 str += sprintf(str, "\n"); 176 seq_putc(m, '\n');
191 } 177 }
192 str += sprintf(str,"\n"); 178 seq_putc(m, '\n');
193 return str;
194} 179}
195#endif /* CONFIG_DASD_PROFILE */ 180#endif /* CONFIG_DASD_PROFILE */
196 181
197static int 182static int dasd_stats_proc_show(struct seq_file *m, void *v)
198dasd_statistics_read(char *page, char **start, off_t off,
199 int count, int *eof, void *data)
200{ 183{
201 unsigned long len;
202#ifdef CONFIG_DASD_PROFILE 184#ifdef CONFIG_DASD_PROFILE
203 struct dasd_profile_info_t *prof; 185 struct dasd_profile_info_t *prof;
204 char *str;
205 int factor; 186 int factor;
206 187
207 /* check for active profiling */ 188 /* check for active profiling */
208 if (dasd_profile_level == DASD_PROFILE_OFF) { 189 if (dasd_profile_level == DASD_PROFILE_OFF) {
209 len = sprintf(page, "Statistics are off - they might be " 190 seq_printf(m, "Statistics are off - they might be "
210 "switched on using 'echo set on > " 191 "switched on using 'echo set on > "
211 "/proc/dasd/statistics'\n"); 192 "/proc/dasd/statistics'\n");
212 return dasd_calc_metrics(page, start, off, count, eof, len); 193 return 0;
213 } 194 }
214 195
215 prof = &dasd_global_profile; 196 prof = &dasd_global_profile;
@@ -217,47 +198,49 @@ dasd_statistics_read(char *page, char **start, off_t off,
217 for (factor = 1; (prof->dasd_io_reqs / factor) > 9999999; 198 for (factor = 1; (prof->dasd_io_reqs / factor) > 9999999;
218 factor *= 10); 199 factor *= 10);
219 200
220 str = page; 201 seq_printf(m, "%d dasd I/O requests\n", prof->dasd_io_reqs);
221 str += sprintf(str, "%d dasd I/O requests\n", prof->dasd_io_reqs); 202 seq_printf(m, "with %u sectors(512B each)\n",
222 str += sprintf(str, "with %u sectors(512B each)\n",
223 prof->dasd_io_sects); 203 prof->dasd_io_sects);
224 str += sprintf(str, "Scale Factor is %d\n", factor); 204 seq_printf(m, "Scale Factor is %d\n", factor);
225 str += sprintf(str, 205 seq_printf(m,
226 " __<4 ___8 __16 __32 __64 _128 " 206 " __<4 ___8 __16 __32 __64 _128 "
227 " _256 _512 __1k __2k __4k __8k " 207 " _256 _512 __1k __2k __4k __8k "
228 " _16k _32k _64k 128k\n"); 208 " _16k _32k _64k 128k\n");
229 str += sprintf(str, 209 seq_printf(m,
230 " _256 _512 __1M __2M __4M __8M " 210 " _256 _512 __1M __2M __4M __8M "
231 " _16M _32M _64M 128M 256M 512M " 211 " _16M _32M _64M 128M 256M 512M "
232 " __1G __2G __4G " " _>4G\n"); 212 " __1G __2G __4G " " _>4G\n");
233 213
234 str += sprintf(str, "Histogram of sizes (512B secs)\n"); 214 seq_printf(m, "Histogram of sizes (512B secs)\n");
235 str = dasd_statistics_array(str, prof->dasd_io_secs, factor); 215 dasd_statistics_array(m, prof->dasd_io_secs, factor);
236 str += sprintf(str, "Histogram of I/O times (microseconds)\n"); 216 seq_printf(m, "Histogram of I/O times (microseconds)\n");
237 str = dasd_statistics_array(str, prof->dasd_io_times, factor); 217 dasd_statistics_array(m, prof->dasd_io_times, factor);
238 str += sprintf(str, "Histogram of I/O times per sector\n"); 218 seq_printf(m, "Histogram of I/O times per sector\n");
239 str = dasd_statistics_array(str, prof->dasd_io_timps, factor); 219 dasd_statistics_array(m, prof->dasd_io_timps, factor);
240 str += sprintf(str, "Histogram of I/O time till ssch\n"); 220 seq_printf(m, "Histogram of I/O time till ssch\n");
241 str = dasd_statistics_array(str, prof->dasd_io_time1, factor); 221 dasd_statistics_array(m, prof->dasd_io_time1, factor);
242 str += sprintf(str, "Histogram of I/O time between ssch and irq\n"); 222 seq_printf(m, "Histogram of I/O time between ssch and irq\n");
243 str = dasd_statistics_array(str, prof->dasd_io_time2, factor); 223 dasd_statistics_array(m, prof->dasd_io_time2, factor);
244 str += sprintf(str, "Histogram of I/O time between ssch " 224 seq_printf(m, "Histogram of I/O time between ssch "
245 "and irq per sector\n"); 225 "and irq per sector\n");
246 str = dasd_statistics_array(str, prof->dasd_io_time2ps, factor); 226 dasd_statistics_array(m, prof->dasd_io_time2ps, factor);
247 str += sprintf(str, "Histogram of I/O time between irq and end\n"); 227 seq_printf(m, "Histogram of I/O time between irq and end\n");
248 str = dasd_statistics_array(str, prof->dasd_io_time3, factor); 228 dasd_statistics_array(m, prof->dasd_io_time3, factor);
249 str += sprintf(str, "# of req in chanq at enqueuing (1..32) \n"); 229 seq_printf(m, "# of req in chanq at enqueuing (1..32) \n");
250 str = dasd_statistics_array(str, prof->dasd_io_nr_req, factor); 230 dasd_statistics_array(m, prof->dasd_io_nr_req, factor);
251 len = str - page;
252#else 231#else
253 len = sprintf(page, "Statistics are not activated in this kernel\n"); 232 seq_printf(m, "Statistics are not activated in this kernel\n");
254#endif 233#endif
255 return dasd_calc_metrics(page, start, off, count, eof, len); 234 return 0;
256} 235}
257 236
258static int 237static int dasd_stats_proc_open(struct inode *inode, struct file *file)
259dasd_statistics_write(struct file *file, const char __user *user_buf, 238{
260 unsigned long user_len, void *data) 239 return single_open(file, dasd_stats_proc_show, NULL);
240}
241
242static ssize_t dasd_stats_proc_write(struct file *file,
243 const char __user *user_buf, size_t user_len, loff_t *pos)
261{ 244{
262#ifdef CONFIG_DASD_PROFILE 245#ifdef CONFIG_DASD_PROFILE
263 char *buffer, *str; 246 char *buffer, *str;
@@ -308,6 +291,15 @@ out_error:
308#endif /* CONFIG_DASD_PROFILE */ 291#endif /* CONFIG_DASD_PROFILE */
309} 292}
310 293
294static const struct file_operations dasd_stats_proc_fops = {
295 .owner = THIS_MODULE,
296 .open = dasd_stats_proc_open,
297 .read = seq_read,
298 .llseek = seq_lseek,
299 .release = single_release,
300 .write = dasd_stats_proc_write,
301};
302
311/* 303/*
312 * Create dasd proc-fs entries. 304 * Create dasd proc-fs entries.
313 * In case creation failed, cleanup and return -ENOENT. 305 * In case creation failed, cleanup and return -ENOENT.
@@ -324,13 +316,12 @@ dasd_proc_init(void)
324 &dasd_devices_file_ops); 316 &dasd_devices_file_ops);
325 if (!dasd_devices_entry) 317 if (!dasd_devices_entry)
326 goto out_nodevices; 318 goto out_nodevices;
327 dasd_statistics_entry = create_proc_entry("statistics", 319 dasd_statistics_entry = proc_create("statistics",
328 S_IFREG | S_IRUGO | S_IWUSR, 320 S_IFREG | S_IRUGO | S_IWUSR,
329 dasd_proc_root_entry); 321 dasd_proc_root_entry,
322 &dasd_stats_proc_fops);
330 if (!dasd_statistics_entry) 323 if (!dasd_statistics_entry)
331 goto out_nostatistics; 324 goto out_nostatistics;
332 dasd_statistics_entry->read_proc = dasd_statistics_read;
333 dasd_statistics_entry->write_proc = dasd_statistics_write;
334 return 0; 325 return 0;
335 326
336 out_nostatistics: 327 out_nostatistics:
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index c68be24e27d9..ba50fe02e572 100644
--- a/drivers/s390/crypto/zcrypt_api.c
+++ b/drivers/s390/crypto/zcrypt_api.c
@@ -33,6 +33,7 @@
33#include <linux/miscdevice.h> 33#include <linux/miscdevice.h>
34#include <linux/fs.h> 34#include <linux/fs.h>
35#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
36#include <linux/seq_file.h>
36#include <linux/compat.h> 37#include <linux/compat.h>
37#include <linux/smp_lock.h> 38#include <linux/smp_lock.h>
38#include <asm/atomic.h> 39#include <asm/atomic.h>
@@ -912,126 +913,105 @@ static struct miscdevice zcrypt_misc_device = {
912 */ 913 */
913static struct proc_dir_entry *zcrypt_entry; 914static struct proc_dir_entry *zcrypt_entry;
914 915
915static int sprintcl(unsigned char *outaddr, unsigned char *addr, 916static void sprintcl(struct seq_file *m, unsigned char *addr, unsigned int len)
916 unsigned int len)
917{ 917{
918 int hl, i; 918 int i;
919 919
920 hl = 0;
921 for (i = 0; i < len; i++) 920 for (i = 0; i < len; i++)
922 hl += sprintf(outaddr+hl, "%01x", (unsigned int) addr[i]); 921 seq_printf(m, "%01x", (unsigned int) addr[i]);
923 hl += sprintf(outaddr+hl, " "); 922 seq_putc(m, ' ');
924 return hl;
925} 923}
926 924
927static int sprintrw(unsigned char *outaddr, unsigned char *addr, 925static void sprintrw(struct seq_file *m, unsigned char *addr, unsigned int len)
928 unsigned int len)
929{ 926{
930 int hl, inl, c, cx; 927 int inl, c, cx;
931 928
932 hl = sprintf(outaddr, " "); 929 seq_printf(m, " ");
933 inl = 0; 930 inl = 0;
934 for (c = 0; c < (len / 16); c++) { 931 for (c = 0; c < (len / 16); c++) {
935 hl += sprintcl(outaddr+hl, addr+inl, 16); 932 sprintcl(m, addr+inl, 16);
936 inl += 16; 933 inl += 16;
937 } 934 }
938 cx = len%16; 935 cx = len%16;
939 if (cx) { 936 if (cx) {
940 hl += sprintcl(outaddr+hl, addr+inl, cx); 937 sprintcl(m, addr+inl, cx);
941 inl += cx; 938 inl += cx;
942 } 939 }
943 hl += sprintf(outaddr+hl, "\n"); 940 seq_putc(m, '\n');
944 return hl;
945} 941}
946 942
947static int sprinthx(unsigned char *title, unsigned char *outaddr, 943static void sprinthx(unsigned char *title, struct seq_file *m,
948 unsigned char *addr, unsigned int len) 944 unsigned char *addr, unsigned int len)
949{ 945{
950 int hl, inl, r, rx; 946 int inl, r, rx;
951 947
952 hl = sprintf(outaddr, "\n%s\n", title); 948 seq_printf(m, "\n%s\n", title);
953 inl = 0; 949 inl = 0;
954 for (r = 0; r < (len / 64); r++) { 950 for (r = 0; r < (len / 64); r++) {
955 hl += sprintrw(outaddr+hl, addr+inl, 64); 951 sprintrw(m, addr+inl, 64);
956 inl += 64; 952 inl += 64;
957 } 953 }
958 rx = len % 64; 954 rx = len % 64;
959 if (rx) { 955 if (rx) {
960 hl += sprintrw(outaddr+hl, addr+inl, rx); 956 sprintrw(m, addr+inl, rx);
961 inl += rx; 957 inl += rx;
962 } 958 }
963 hl += sprintf(outaddr+hl, "\n"); 959 seq_putc(m, '\n');
964 return hl;
965} 960}
966 961
967static int sprinthx4(unsigned char *title, unsigned char *outaddr, 962static void sprinthx4(unsigned char *title, struct seq_file *m,
968 unsigned int *array, unsigned int len) 963 unsigned int *array, unsigned int len)
969{ 964{
970 int hl, r; 965 int r;
971 966
972 hl = sprintf(outaddr, "\n%s\n", title); 967 seq_printf(m, "\n%s\n", title);
973 for (r = 0; r < len; r++) { 968 for (r = 0; r < len; r++) {
974 if ((r % 8) == 0) 969 if ((r % 8) == 0)
975 hl += sprintf(outaddr+hl, " "); 970 seq_printf(m, " ");
976 hl += sprintf(outaddr+hl, "%08X ", array[r]); 971 seq_printf(m, "%08X ", array[r]);
977 if ((r % 8) == 7) 972 if ((r % 8) == 7)
978 hl += sprintf(outaddr+hl, "\n"); 973 seq_putc(m, '\n');
979 } 974 }
980 hl += sprintf(outaddr+hl, "\n"); 975 seq_putc(m, '\n');
981 return hl;
982} 976}
983 977
984static int zcrypt_status_read(char *resp_buff, char **start, off_t offset, 978static int zcrypt_proc_show(struct seq_file *m, void *v)
985 int count, int *eof, void *data)
986{ 979{
987 unsigned char *workarea; 980 char workarea[sizeof(int) * AP_DEVICES];
988 int len; 981
989 982 seq_printf(m, "\nzcrypt version: %d.%d.%d\n",
990 len = 0; 983 ZCRYPT_VERSION, ZCRYPT_RELEASE, ZCRYPT_VARIANT);
991 984 seq_printf(m, "Cryptographic domain: %d\n", ap_domain_index);
992 /* resp_buff is a page. Use the right half for a work area */ 985 seq_printf(m, "Total device count: %d\n", zcrypt_device_count);
993 workarea = resp_buff + 2000; 986 seq_printf(m, "PCICA count: %d\n", zcrypt_count_type(ZCRYPT_PCICA));
994 len += sprintf(resp_buff + len, "\nzcrypt version: %d.%d.%d\n", 987 seq_printf(m, "PCICC count: %d\n", zcrypt_count_type(ZCRYPT_PCICC));
995 ZCRYPT_VERSION, ZCRYPT_RELEASE, ZCRYPT_VARIANT); 988 seq_printf(m, "PCIXCC MCL2 count: %d\n",
996 len += sprintf(resp_buff + len, "Cryptographic domain: %d\n", 989 zcrypt_count_type(ZCRYPT_PCIXCC_MCL2));
997 ap_domain_index); 990 seq_printf(m, "PCIXCC MCL3 count: %d\n",
998 len += sprintf(resp_buff + len, "Total device count: %d\n", 991 zcrypt_count_type(ZCRYPT_PCIXCC_MCL3));
999 zcrypt_device_count); 992 seq_printf(m, "CEX2C count: %d\n", zcrypt_count_type(ZCRYPT_CEX2C));
1000 len += sprintf(resp_buff + len, "PCICA count: %d\n", 993 seq_printf(m, "CEX2A count: %d\n", zcrypt_count_type(ZCRYPT_CEX2A));
1001 zcrypt_count_type(ZCRYPT_PCICA)); 994 seq_printf(m, "CEX3C count: %d\n", zcrypt_count_type(ZCRYPT_CEX3C));
1002 len += sprintf(resp_buff + len, "PCICC count: %d\n", 995 seq_printf(m, "CEX3A count: %d\n", zcrypt_count_type(ZCRYPT_CEX3A));
1003 zcrypt_count_type(ZCRYPT_PCICC)); 996 seq_printf(m, "requestq count: %d\n", zcrypt_requestq_count());
1004 len += sprintf(resp_buff + len, "PCIXCC MCL2 count: %d\n", 997 seq_printf(m, "pendingq count: %d\n", zcrypt_pendingq_count());
1005 zcrypt_count_type(ZCRYPT_PCIXCC_MCL2)); 998 seq_printf(m, "Total open handles: %d\n\n",
1006 len += sprintf(resp_buff + len, "PCIXCC MCL3 count: %d\n", 999 atomic_read(&zcrypt_open_count));
1007 zcrypt_count_type(ZCRYPT_PCIXCC_MCL3));
1008 len += sprintf(resp_buff + len, "CEX2C count: %d\n",
1009 zcrypt_count_type(ZCRYPT_CEX2C));
1010 len += sprintf(resp_buff + len, "CEX2A count: %d\n",
1011 zcrypt_count_type(ZCRYPT_CEX2A));
1012 len += sprintf(resp_buff + len, "CEX3C count: %d\n",
1013 zcrypt_count_type(ZCRYPT_CEX3C));
1014 len += sprintf(resp_buff + len, "CEX3A count: %d\n",
1015 zcrypt_count_type(ZCRYPT_CEX3A));
1016 len += sprintf(resp_buff + len, "requestq count: %d\n",
1017 zcrypt_requestq_count());
1018 len += sprintf(resp_buff + len, "pendingq count: %d\n",
1019 zcrypt_pendingq_count());
1020 len += sprintf(resp_buff + len, "Total open handles: %d\n\n",
1021 atomic_read(&zcrypt_open_count));
1022 zcrypt_status_mask(workarea); 1000 zcrypt_status_mask(workarea);
1023 len += sprinthx("Online devices: 1=PCICA 2=PCICC 3=PCIXCC(MCL2) " 1001 sprinthx("Online devices: 1=PCICA 2=PCICC 3=PCIXCC(MCL2) "
1024 "4=PCIXCC(MCL3) 5=CEX2C 6=CEX2A 7=CEX3C 8=CEX3A", 1002 "4=PCIXCC(MCL3) 5=CEX2C 6=CEX2A 7=CEX3C 8=CEX3A",
1025 resp_buff+len, workarea, AP_DEVICES); 1003 m, workarea, AP_DEVICES);
1026 zcrypt_qdepth_mask(workarea); 1004 zcrypt_qdepth_mask(workarea);
1027 len += sprinthx("Waiting work element counts", 1005 sprinthx("Waiting work element counts", m, workarea, AP_DEVICES);
1028 resp_buff+len, workarea, AP_DEVICES);
1029 zcrypt_perdev_reqcnt((int *) workarea); 1006 zcrypt_perdev_reqcnt((int *) workarea);
1030 len += sprinthx4("Per-device successfully completed request counts", 1007 sprinthx4("Per-device successfully completed request counts",
1031 resp_buff+len,(unsigned int *) workarea, AP_DEVICES); 1008 m, (unsigned int *) workarea, AP_DEVICES);
1032 *eof = 1; 1009 return 0;
1033 memset((void *) workarea, 0x00, AP_DEVICES * sizeof(unsigned int)); 1010}
1034 return len; 1011
1012static int zcrypt_proc_open(struct inode *inode, struct file *file)
1013{
1014 return single_open(file, zcrypt_proc_show, NULL);
1035} 1015}
1036 1016
1037static void zcrypt_disable_card(int index) 1017static void zcrypt_disable_card(int index)
@@ -1061,11 +1041,11 @@ static void zcrypt_enable_card(int index)
1061 spin_unlock_bh(&zcrypt_device_lock); 1041 spin_unlock_bh(&zcrypt_device_lock);
1062} 1042}
1063 1043
1064static int zcrypt_status_write(struct file *file, const char __user *buffer, 1044static ssize_t zcrypt_proc_write(struct file *file, const char __user *buffer,
1065 unsigned long count, void *data) 1045 size_t count, loff_t *pos)
1066{ 1046{
1067 unsigned char *lbuf, *ptr; 1047 unsigned char *lbuf, *ptr;
1068 unsigned long local_count; 1048 size_t local_count;
1069 int j; 1049 int j;
1070 1050
1071 if (count <= 0) 1051 if (count <= 0)
@@ -1115,6 +1095,15 @@ out:
1115 return count; 1095 return count;
1116} 1096}
1117 1097
1098static const struct file_operations zcrypt_proc_fops = {
1099 .owner = THIS_MODULE,
1100 .open = zcrypt_proc_open,
1101 .read = seq_read,
1102 .llseek = seq_lseek,
1103 .release = single_release,
1104 .write = zcrypt_proc_write,
1105};
1106
1118static int zcrypt_rng_device_count; 1107static int zcrypt_rng_device_count;
1119static u32 *zcrypt_rng_buffer; 1108static u32 *zcrypt_rng_buffer;
1120static int zcrypt_rng_buffer_index; 1109static int zcrypt_rng_buffer_index;
@@ -1197,14 +1186,11 @@ int __init zcrypt_api_init(void)
1197 goto out; 1186 goto out;
1198 1187
1199 /* Set up the proc file system */ 1188 /* Set up the proc file system */
1200 zcrypt_entry = create_proc_entry("driver/z90crypt", 0644, NULL); 1189 zcrypt_entry = proc_create("driver/z90crypt", 0644, NULL, &zcrypt_proc_fops);
1201 if (!zcrypt_entry) { 1190 if (!zcrypt_entry) {
1202 rc = -ENOMEM; 1191 rc = -ENOMEM;
1203 goto out_misc; 1192 goto out_misc;
1204 } 1193 }
1205 zcrypt_entry->data = NULL;
1206 zcrypt_entry->read_proc = zcrypt_status_read;
1207 zcrypt_entry->write_proc = zcrypt_status_write;
1208 1194
1209 return 0; 1195 return 0;
1210 1196