aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Peschke <mp3@de.ibm.com>2008-03-31 05:15:26 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-04-07 13:19:09 -0400
commitdf29f4ac4d3e8fcc8d8c85b7aeb8cc0df2a3f68a (patch)
treee94df0f63aa6571b5271b79ebddaeb1f689e95f7
parentc7b7fc8c30df49a4ca5743d5f062666adcc1dc15 (diff)
[SCSI] zfcp: Simplify usage of hex dump output function for debug trace.
Simplify usage of output function for hex dumps. Signed-off-by: Martin Peschke <mp3@de.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c69
1 files changed, 28 insertions, 41 deletions
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index 427115b17ed4..0341fc5e06ce 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -90,33 +90,26 @@ static void zfcp_dbf_out(char **buf, const char *s, const char *format, ...)
90 *buf += sprintf(*buf, "\n"); 90 *buf += sprintf(*buf, "\n");
91} 91}
92 92
93static int 93static void zfcp_dbf_outd(char **p, const char *label, char *buffer,
94zfcp_dbf_view_dump(char *out_buf, const char *label, 94 int buflen, int offset, int total_size)
95 char *buffer, int buflen, int offset, int total_size)
96{ 95{
97 int len = 0; 96 if (!offset)
98 97 *p += sprintf(*p, "%-24s ", label);
99 if (offset == 0)
100 len += sprintf(out_buf + len, "%-24s ", label);
101
102 while (buflen--) { 98 while (buflen--) {
103 if (offset > 0) { 99 if (offset > 0) {
104 if ((offset % 32) == 0) 100 if ((offset % 32) == 0)
105 len += sprintf(out_buf + len, "\n%-24c ", ' '); 101 *p += sprintf(*p, "\n%-24c ", ' ');
106 else if ((offset % 4) == 0) 102 else if ((offset % 4) == 0)
107 len += sprintf(out_buf + len, " "); 103 *p += sprintf(*p, " ");
108 } 104 }
109 len += sprintf(out_buf + len, "%02x", *buffer++); 105 *p += sprintf(*p, "%02x", *buffer++);
110 if (++offset == total_size) { 106 if (++offset == total_size) {
111 len += sprintf(out_buf + len, "\n"); 107 *p += sprintf(*p, "\n");
112 break; 108 break;
113 } 109 }
114 } 110 }
115 111 if (!total_size)
116 if (total_size == 0) 112 *p += sprintf(*p, "\n");
117 len += sprintf(out_buf + len, "\n");
118
119 return len;
120} 113}
121 114
122static int 115static int
@@ -133,8 +126,8 @@ zfcp_dbf_view_header(debug_info_t * id, struct debug_view *view, int area,
133 t.tv_sec, t.tv_nsec); 126 t.tv_sec, t.tv_nsec);
134 zfcp_dbf_out(&p, "cpu", "%02i", entry->id.fields.cpuid); 127 zfcp_dbf_out(&p, "cpu", "%02i", entry->id.fields.cpuid);
135 } else { 128 } else {
136 p += zfcp_dbf_view_dump(p, NULL, dump->data, dump->size, 129 zfcp_dbf_outd(&p, NULL, dump->data, dump->size, dump->offset,
137 dump->offset, dump->total_size); 130 dump->total_size);
138 if ((dump->offset + dump->size) == dump->total_size) 131 if ((dump->offset + dump->size) == dump->total_size)
139 p += sprintf(p, "\n"); 132 p += sprintf(p, "\n");
140 } 133 }
@@ -348,14 +341,10 @@ static int zfcp_hba_dbf_view_response(char *buf,
348 zfcp_dbf_out(&p, "fsf_issued", "%011lu:%06lu", t.tv_sec, t.tv_nsec); 341 zfcp_dbf_out(&p, "fsf_issued", "%011lu:%06lu", t.tv_sec, t.tv_nsec);
349 zfcp_dbf_out(&p, "fsf_prot_status", "0x%08x", r->fsf_prot_status); 342 zfcp_dbf_out(&p, "fsf_prot_status", "0x%08x", r->fsf_prot_status);
350 zfcp_dbf_out(&p, "fsf_status", "0x%08x", r->fsf_status); 343 zfcp_dbf_out(&p, "fsf_status", "0x%08x", r->fsf_status);
351 p += zfcp_dbf_view_dump(p, "fsf_prot_status_qual", 344 zfcp_dbf_outd(&p, "fsf_prot_status_qual", r->fsf_prot_status_qual,
352 r->fsf_prot_status_qual, 345 FSF_PROT_STATUS_QUAL_SIZE, 0, FSF_PROT_STATUS_QUAL_SIZE);
353 FSF_PROT_STATUS_QUAL_SIZE, 346 zfcp_dbf_outd(&p, "fsf_status_qual", r->fsf_status_qual,
354 0, FSF_PROT_STATUS_QUAL_SIZE); 347 FSF_STATUS_QUALIFIER_SIZE, 0, FSF_STATUS_QUALIFIER_SIZE);
355 p += zfcp_dbf_view_dump(p, "fsf_status_qual",
356 r->fsf_status_qual,
357 FSF_STATUS_QUALIFIER_SIZE,
358 0, FSF_STATUS_QUALIFIER_SIZE);
359 zfcp_dbf_out(&p, "fsf_req_status", "0x%08x", r->fsf_req_status); 348 zfcp_dbf_out(&p, "fsf_req_status", "0x%08x", r->fsf_req_status);
360 zfcp_dbf_out(&p, "sbal_first", "0x%02x", r->sbal_first); 349 zfcp_dbf_out(&p, "sbal_first", "0x%02x", r->sbal_first);
361 zfcp_dbf_out(&p, "sbal_curr", "0x%02x", r->sbal_curr); 350 zfcp_dbf_out(&p, "sbal_curr", "0x%02x", r->sbal_curr);
@@ -415,12 +404,11 @@ static int zfcp_hba_dbf_view_status(char *buf,
415 zfcp_dbf_out(&p, "failed", "0x%02x", r->failed); 404 zfcp_dbf_out(&p, "failed", "0x%02x", r->failed);
416 zfcp_dbf_out(&p, "status_type", "0x%08x", r->status_type); 405 zfcp_dbf_out(&p, "status_type", "0x%08x", r->status_type);
417 zfcp_dbf_out(&p, "status_subtype", "0x%08x", r->status_subtype); 406 zfcp_dbf_out(&p, "status_subtype", "0x%08x", r->status_subtype);
418 p += zfcp_dbf_view_dump(p, "queue_designator", 407 zfcp_dbf_outd(&p, "queue_designator", (char *)&r->queue_designator,
419 (char *)&r->queue_designator, 408 sizeof(struct fsf_queue_designator), 0,
420 sizeof(struct fsf_queue_designator), 409 sizeof(struct fsf_queue_designator));
421 0, sizeof(struct fsf_queue_designator)); 410 zfcp_dbf_outd(&p, "payload", (char *)&r->payload, r->payload_size, 0,
422 p += zfcp_dbf_view_dump(p, "payload", (char *)&r->payload, 411 r->payload_size);
423 r->payload_size, 0, r->payload_size);
424 return p - buf; 412 return p - buf;
425} 413}
426 414
@@ -1031,7 +1019,7 @@ zfcp_san_dbf_view_format(debug_info_t * id, struct debug_view *view,
1031 buflen = min(total, ZFCP_DBF_ELS_PAYLOAD); 1019 buflen = min(total, ZFCP_DBF_ELS_PAYLOAD);
1032 } 1020 }
1033 1021
1034 p += zfcp_dbf_view_dump(p, "payload", buffer, buflen, 0, total); 1022 zfcp_dbf_outd(&p, "payload", buffer, buflen, 0, total);
1035 if (buflen == total) 1023 if (buflen == total)
1036 p += sprintf(p, "\n"); 1024 p += sprintf(p, "\n");
1037 1025
@@ -1179,8 +1167,8 @@ zfcp_scsi_dbf_view_format(debug_info_t * id, struct debug_view *view,
1179 zfcp_dbf_out(&p, "scsi_result", "0x%08x", r->scsi_result); 1167 zfcp_dbf_out(&p, "scsi_result", "0x%08x", r->scsi_result);
1180 zfcp_dbf_out(&p, "scsi_cmnd", "0x%0Lx", r->scsi_cmnd); 1168 zfcp_dbf_out(&p, "scsi_cmnd", "0x%0Lx", r->scsi_cmnd);
1181 zfcp_dbf_out(&p, "scsi_serial", "0x%016Lx", r->scsi_serial); 1169 zfcp_dbf_out(&p, "scsi_serial", "0x%016Lx", r->scsi_serial);
1182 p += zfcp_dbf_view_dump(p, "scsi_opcode", r->scsi_opcode, 1170 zfcp_dbf_outd(&p, "scsi_opcode", r->scsi_opcode, ZFCP_DBF_SCSI_OPCODE,
1183 ZFCP_DBF_SCSI_OPCODE, 0, ZFCP_DBF_SCSI_OPCODE); 1171 0, ZFCP_DBF_SCSI_OPCODE);
1184 zfcp_dbf_out(&p, "scsi_retries", "0x%02x", r->scsi_retries); 1172 zfcp_dbf_out(&p, "scsi_retries", "0x%02x", r->scsi_retries);
1185 zfcp_dbf_out(&p, "scsi_allowed", "0x%02x", r->scsi_allowed); 1173 zfcp_dbf_out(&p, "scsi_allowed", "0x%02x", r->scsi_allowed);
1186 if (strncmp(r->tag, "abrt", ZFCP_DBF_TAG_SIZE) == 0) 1174 if (strncmp(r->tag, "abrt", ZFCP_DBF_TAG_SIZE) == 0)
@@ -1202,11 +1190,10 @@ zfcp_scsi_dbf_view_format(debug_info_t * id, struct debug_view *view,
1202 r->type.fcp.rsp_code); 1190 r->type.fcp.rsp_code);
1203 zfcp_dbf_out(&p, "fcp_sns_info_len", "0x%08x", 1191 zfcp_dbf_out(&p, "fcp_sns_info_len", "0x%08x",
1204 r->type.fcp.sns_info_len); 1192 r->type.fcp.sns_info_len);
1205 p += zfcp_dbf_view_dump(p, "fcp_sns_info", 1193 zfcp_dbf_outd(&p, "fcp_sns_info", r->type.fcp.sns_info,
1206 r->type.fcp.sns_info, 1194 min((int)r->type.fcp.sns_info_len,
1207 min((int)r->type.fcp.sns_info_len, 1195 ZFCP_DBF_SCSI_FCP_SNS_INFO), 0,
1208 ZFCP_DBF_SCSI_FCP_SNS_INFO), 0, 1196 r->type.fcp.sns_info_len);
1209 r->type.fcp.sns_info_len);
1210 } 1197 }
1211 p += sprintf(p, "\n"); 1198 p += sprintf(p, "\n");
1212 return p - out_buf; 1199 return p - out_buf;