[1/4] scsi: Add scsi_prot_op_normal()

Message ID 1542725944-244183-2-git-send-email-john.garry@huawei.com
State New
Headers show
Series
  • hisi_sas: DIF/DIX support
Related show

Commit Message

John Garry Nov. 20, 2018, 2:59 p.m.
It is a common pattern to check if a Scsi command protection option is
"normal", i.e. regular IO.

Add a common simple wrapper for this.

Signed-off-by: John Garry <john.garry@huawei.com>

---
 include/scsi/scsi_cmnd.h | 5 +++++
 1 file changed, 5 insertions(+)

-- 
1.9.1

Comments

Christoph Hellwig Nov. 20, 2018, 4:19 p.m. | #1
> +static inline bool scsi_prot_op_normal(struct scsi_cmnd *scmd)

> +{

> +	return scmd->prot_op == SCSI_PROT_NORMAL;

> +}


This "wrapper" just obsfucates the check being performed, please drop
it.
John Garry Nov. 20, 2018, 4:36 p.m. | #2
On 20/11/2018 16:19, Christoph Hellwig wrote:
>> +static inline bool scsi_prot_op_normal(struct scsi_cmnd *scmd)

>> +{

>> +	return scmd->prot_op == SCSI_PROT_NORMAL;

>> +}

>

> This "wrapper" just obsfucates the check being performed, please drop

> it.

>

> .

>


ok, if you think so.

I just thought that was better for a more concise check, rather than 
this common pattern:
if ((scsi_get_prot_op(scsi_cmnd) != SCSI_PROT_NORMAL) ...

cheers,

Patch

diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index c891ada..3b26ea1 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -271,6 +271,11 @@  static inline unsigned char scsi_get_prot_op(struct scsi_cmnd *scmd)
 	return scmd->prot_op;
 }
 
+static inline bool scsi_prot_op_normal(struct scsi_cmnd *scmd)
+{
+	return scmd->prot_op == SCSI_PROT_NORMAL;
+}
+
 enum scsi_prot_flags {
 	SCSI_PROT_TRANSFER_PI		= 1 << 0,
 	SCSI_PROT_GUARD_CHECK		= 1 << 1,