From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@infradead.org>
Cc: James Bottomley <jbottomley@parallels.com>,
Ewan Milne <emilne@redhat.com>,
Yoshihiro Yunomae <yoshihiro.yunomae.ez@hitachi.com>,
linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 12/20] scsi: merge print_opcode_name()
Date: Wed, 3 Sep 2014 12:06:07 +0200 [thread overview]
Message-ID: <1409738775-80876-13-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1409738775-80876-1-git-send-email-hare@suse.de>
Instead of having two versions of print_opcode_name() we
should be consolidating them into one version.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/scsi/constants.c | 90 +++++++++++++++++++-----------------------------
1 file changed, 35 insertions(+), 55 deletions(-)
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 364349c..3aee43b 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -30,6 +30,11 @@
#define THIRD_PARTY_COPY_IN 0x84
+struct sa_name_list {
+ int cmd;
+ const struct value_name_pair *arr;
+ int arr_sz;
+};
#ifdef CONFIG_SCSI_CONSTANTS
static const char * cdb_byte0_names[] = {
@@ -244,12 +249,6 @@ static const struct value_name_pair variable_length_arr[] = {
};
#define VARIABLE_LENGTH_SZ ARRAY_SIZE(variable_length_arr)
-struct sa_name_list {
- int cmd;
- const struct value_name_pair *arr;
- int arr_sz;
-};
-
static struct sa_name_list sa_names_arr[] = {
{VARIABLE_LENGTH_CMD, variable_length_arr, VARIABLE_LENGTH_SZ},
{MAINTENANCE_IN, maint_in_arr, MAINT_IN_SZ},
@@ -267,6 +266,28 @@ static struct sa_name_list sa_names_arr[] = {
};
#define SA_NAME_LIST_SZ ARRAY_SIZE(sa_names_arr)
+#else /* ifndef CONFIG_SCSI_CONSTANTS */
+static const char * cdb_byte0_names[] = NULL;
+
+static struct sa_name_list sa_names_arr[] = {
+ {VARIABLE_LENGTH_CMD, NULL, 0},
+ {MAINTENANCE_IN, NULL, 0},
+ {MAINTENANCE_OUT, NULL, 0},
+ {PERSISTENT_RESERVE_IN, NULL, 0},
+ {PERSISTENT_RESERVE_OUT, NULL, 0},
+ {SERVICE_ACTION_IN_12, NULL, 0},
+ {SERVICE_ACTION_OUT_12, NULL, 0},
+ {SERVICE_ACTION_BIDIRECTIONAL, NULL, 0},
+ {SERVICE_ACTION_IN_16, NULL, 0},
+ {SERVICE_ACTION_OUT_16, NULL, 0},
+ {THIRD_PARTY_COPY_IN, NULL, 0},
+ {THIRD_PARTY_COPY_OUT, NULL, 0},
+ {0, NULL, 0},
+};
+#endif /* CONFIG_SCSI_CONSTANTS */
+#define SA_NAME_LIST_SZ ARRAY_SIZE(sa_names_arr)
+#define CDB_BYTE0_NAMES_SZ ARRAY_SIZE(cdb_byte0_names)
+
static bool scsi_opcode_sa_name(int cmd, int service_action,
const char **sa_name)
{
@@ -316,11 +337,14 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
if (!scsi_opcode_sa_name(cdb0, sa, &name)) {
if (cdb0 < 0xc0) {
- name = cdb_byte0_names[cdb0];
- if (name)
- printk("%s", name);
- else
- printk("cdb[0]=0x%x (reserved)", cdb0);
+ if (CDB_BYTE0_NAMES_SZ) {
+ name = cdb_byte0_names[cdb0];
+ if (name)
+ printk("%s", name);
+ else
+ printk("cdb[0]=0x%x (reserved)", cdb0);
+ } else
+ printk("cdb[0]=0x%x", cdb0);
} else
printk("cdb[0]=0x%x (vendor)", cdb0);
} else {
@@ -334,50 +358,6 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
}
}
-#else /* ifndef CONFIG_SCSI_CONSTANTS */
-
-static void print_opcode_name(unsigned char * cdbp, int cdb_len)
-{
- int sa, len, cdb0;
-
- cdb0 = cdbp[0];
- switch(cdb0) {
- case VARIABLE_LENGTH_CMD:
- len = scsi_varlen_cdb_length(cdbp);
- if (len < 10) {
- printk("short opcode=0x%x command, len=%d "
- "ext_len=%d", cdb0, len, cdb_len);
- break;
- }
- sa = (cdbp[8] << 8) + cdbp[9];
- printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
- if (len != cdb_len)
- printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
- break;
- case MAINTENANCE_IN:
- case MAINTENANCE_OUT:
- case PERSISTENT_RESERVE_IN:
- case PERSISTENT_RESERVE_OUT:
- case SERVICE_ACTION_IN_12:
- case SERVICE_ACTION_OUT_12:
- case SERVICE_ACTION_BIDIRECTIONAL:
- case SERVICE_ACTION_IN_16:
- case SERVICE_ACTION_OUT_16:
- case THIRD_PARTY_COPY_IN:
- case THIRD_PARTY_COPY_OUT:
- sa = cdbp[1] & 0x1f;
- printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
- break;
- default:
- if (cdb0 < 0xc0)
- printk("cdb[0]=0x%x", cdb0);
- else
- printk("cdb[0]=0x%x (vendor)", cdb0);
- break;
- }
-}
-#endif
-
void __scsi_print_command(unsigned char *cdb)
{
int k, len;
--
1.8.5.2
next prev parent reply other threads:[~2014-09-03 10:06 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
2014-09-03 10:05 ` [PATCH 01/20] Remove scsi_cmd_print_sense_hdr() Hannes Reinecke
2014-09-03 10:05 ` [PATCH 02/20] aha152x: Debug output update and whitespace cleanup Hannes Reinecke
2014-09-06 0:02 ` Christoph Hellwig
2014-09-03 10:05 ` [PATCH 03/20] sd: Remove scsi_print_sense() in sd_done() Hannes Reinecke
2014-09-03 10:05 ` [PATCH 04/20] scsi: introduce sdev_prefix_printk() Hannes Reinecke
2014-09-06 0:03 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 05/20] scsi: Use sdev as argument for sense code printing Hannes Reinecke
2014-09-03 10:06 ` [PATCH 06/20] scsi: stop decoding if scsi_normalize_sense() fails Hannes Reinecke
2014-09-06 0:04 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 07/20] scsi: do not decode sense extras Hannes Reinecke
2014-09-06 0:04 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense() Hannes Reinecke
2014-09-05 0:51 ` Yoshihiro YUNOMAE
2014-09-05 6:07 ` Hannes Reinecke
2014-09-06 0:09 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 09/20] scsi: remove scsi_print_status() Hannes Reinecke
2014-09-06 0:10 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 10/20] Implement scsi_opcode_sa_name Hannes Reinecke
2014-09-03 10:06 ` [PATCH 11/20] scsi: Use scsi_print_command() where possible Hannes Reinecke
2014-09-06 0:11 ` Christoph Hellwig
2014-09-03 10:06 ` Hannes Reinecke [this message]
2014-09-05 1:24 ` [PATCH 12/20] scsi: merge print_opcode_name() Yoshihiro YUNOMAE
2014-09-06 0:12 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 13/20] scsi: consolidate opcode lookup in scsi_opcode_sa_name() Hannes Reinecke
2014-09-06 0:46 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 14/20] scsi: use local buffer for printing CDB Hannes Reinecke
2014-09-05 2:02 ` Yoshihiro YUNOMAE
2014-09-07 16:10 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 15/20] libata: use __scsi_print_command() Hannes Reinecke
2014-09-03 10:06 ` [PATCH 16/20] scsi: separate out scsi_retval_string() Hannes Reinecke
2014-09-05 2:04 ` Yoshihiro YUNOMAE
2014-09-05 6:14 ` Hannes Reinecke
2014-09-07 16:11 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 17/20] scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte() Hannes Reinecke
2014-09-05 4:19 ` Yoshihiro YUNOMAE
2014-09-07 16:12 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 18/20] scsi: remove scsi_show_result() Hannes Reinecke
2014-09-05 4:22 ` Yoshihiro YUNOMAE
2014-09-07 16:17 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 19/20] sd: Reduce logging output Hannes Reinecke
2014-09-07 16:17 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 20/20] scsi_error: format abort error message Hannes Reinecke
2014-09-05 4:23 ` Yoshihiro YUNOMAE
2014-09-06 0:33 ` Christoph Hellwig
2014-09-13 1:07 ` Elliott, Robert (Server Storage)
2014-09-14 10:49 ` Hannes Reinecke
2014-09-14 16:40 ` Christoph Hellwig
2014-09-06 0:51 ` [PATCHv2 00/20] scsi logging update Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1409738775-80876-13-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=emilne@redhat.com \
--cc=hch@infradead.org \
--cc=jbottomley@parallels.com \
--cc=linux-scsi@vger.kernel.org \
--cc=yoshihiro.yunomae.ez@hitachi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox