diff mbox

[VERY,EARLY,RFC,04/13] scsi: add enum for driver byte codes

Message ID 20180418150116.18807-5-jthumshirn@suse.de (mailing list archive)
State Changes Requested
Headers show

Commit Message

Johannes Thumshirn April 18, 2018, 3:01 p.m. UTC
Add enum for driver byte codes and adopt set_driver_byte()'s
signature.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Suggested-by: Bart Van Assche <Bart.VanAssche@wdc.com>
---
 include/scsi/scsi.h      | 33 ++++++++++++++++++++-------------
 include/scsi/scsi_cmnd.h |  3 ++-
 2 files changed, 22 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 4dfc5e11a5b2..2694faafaddf 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -161,21 +161,24 @@  enum scsi_host_byte {
 	DID_ALLOC_FAILURE,	/* Space allocation on the device failed */
 	DID_MEDIUM_ERROR,	/* Medium error */
 };
-#define DRIVER_OK       0x00	/* Driver status                           */
 
-/*
- *  These indicate the error that occurred, and what is available.
- */
+enum scsi_driver_byte {
+	DRIVER_OK,	/* Driver status */
 
-#define DRIVER_BUSY         0x01
-#define DRIVER_SOFT         0x02
-#define DRIVER_MEDIA        0x03
-#define DRIVER_ERROR        0x04
+	/*
+	 *  These indicate the error that occurred, and what is available.
+	 */
 
-#define DRIVER_INVALID      0x05
-#define DRIVER_TIMEOUT      0x06
-#define DRIVER_HARD         0x07
-#define DRIVER_SENSE	    0x08
+	DRIVER_BUSY,
+	DRIVER_SOFT,
+	DRIVER_MEDIA,
+	DRIVER_ERROR,
+
+	DRIVER_INVALID,
+	DRIVER_TIMEOUT,
+	DRIVER_HARD,
+	DRIVER_SENSE,
+};
 
 /*
  * Internal return values.
@@ -215,7 +218,11 @@  static inline enum scsi_host_byte host_byte(int result)
 {
 	return (result >> 16) & 0xff;
 }
-#define driver_byte(result) (((result) >> 24) & 0xff)
+
+static inline enum scsi_driver_byte driver_byte(int result)
+{
+	return (result >> 24) & 0xff;
+}
 
 #define sense_class(sense)  (((sense) >> 4) & 0x7)
 #define sense_error(sense)  ((sense) & 0xf)
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index b678cd99b12b..da8ea89ccc0a 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -348,7 +348,8 @@  static inline void set_host_byte(struct scsi_cmnd *cmd,
 	cmd->result = (cmd->result & 0xff00ffff) | (status << 16);
 }
 
-static inline void set_driver_byte(struct scsi_cmnd *cmd, char status)
+static inline void set_driver_byte(struct scsi_cmnd *cmd,
+				   enum scsi_driver_byte status)
 {
 	cmd->result = (cmd->result & 0x00ffffff) | (status << 24);
 }