scsi_print_command is using several calls to printk(), causing the output to be garbled. Modify it to use a single call to printk(). Cc: Kay Sievers <kay@xxxxxxxx> Signed-off-by: Hannes Reinecke <hare@xxxxxxx> --- drivers/scsi/constants.c | 71 +++++++++++++++++++++++++++++++++++++++------ 1 files changed, 61 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index b469798..65367e8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -349,34 +349,85 @@ static int print_opcode_name(char *buf, int buf_len, void __scsi_print_command(unsigned char *cdb) { - int k, len; + int k, len, rem, linelen; char cdb_str[64]; + char line[16 * 3 + 1]; print_opcode_name(cdb_str, 64, cdb, 0); - pr_info("%s", cdb_str); len = scsi_command_size(cdb); /* print out all bytes in cdb */ - for (k = 0; k < len; ++k) - printk(" %02x", cdb[k]); - printk("\n"); + switch (len) { + case 6: + pr_info("%s %6ph\n", cdb_str, cdb); + break; + case 10: + pr_info("%s %10ph\n", cdb_str, cdb); + break; + case 12: + pr_info("%s %12ph\n", cdb_str, cdb); + break; + case 16: + pr_info("%s %16ph\n", cdb_str, cdb); + break; + default: + pr_info("%s\n", cdb_str); + rem = len; + for (k = 0; k < len; k += 16) { + linelen = min(rem, 16); + rem -= 16; + + hex_dump_to_buffer(cdb + k, linelen, 16, 1, + line, sizeof(line), false); + pr_info("%s\n", line); + } + break; + } } EXPORT_SYMBOL(__scsi_print_command); void scsi_print_command(struct scsi_cmnd *cmd) { - int k; + int k, rem, linelen; char cdb_str[64]; + char line[16 * 3 + 1]; if (cmd->cmnd == NULL) return; print_opcode_name(cdb_str, 64, cmd->cmnd, cmd->cmd_len); - scmd_printk(KERN_INFO, cmd, "CDB: %s:", cdb_str); /* print out all bytes in cdb */ - for (k = 0; k < cmd->cmd_len; ++k) - printk(" %02x", cmd->cmnd[k]); - printk("\n"); + switch (cmd->cmd_len) { + case 6: + scmd_printk(KERN_INFO, cmd, "CDB: %s: %6ph\n", + cdb_str, cmd->cmnd); + break; + case 10: + scmd_printk(KERN_INFO, cmd, "CDB: %s: %10ph\n", + cdb_str, cmd->cmnd); + break; + case 12: + scmd_printk(KERN_INFO, cmd, "CDB: %s: %12ph\n", + cdb_str, cmd->cmnd); + break; + case 16: + scmd_printk(KERN_INFO, cmd, "CDB: %s: %16ph\n", + cdb_str, cmd->cmnd); + break; + default: + scmd_printk(KERN_INFO, cmd, "CDB: %s\n", cdb_str); + rem = cmd->cmd_len; + for (k = 0; k < cmd->cmd_len; k += 16) { + linelen = min(rem, 16); + rem -= 16; + + hex_dump_to_buffer(cmd->cmnd + k, linelen, 16, 1, + line, sizeof(line), false); + scmd_printk(KERN_INFO, cmd, " %d: %s\n", + k, line); + } + break; + } } EXPORT_SYMBOL(scsi_print_command); -- 1.7.4.2 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html