提交 a7089770 编写于 作者: H Hannes Reinecke 提交者: Martin K. Petersen

scsi_dh_alua: use unaligned access macros

Use 'get_unaligned_XX' and 'put_unaligned_XX' instead of
open-coding it.
Signed-off-by: NHannes Reinecke <hare@suse.de>
Reviewed-by: NMartin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 6c4fc044
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/module.h> #include <linux/module.h>
#include <asm/unaligned.h>
#include <scsi/scsi.h> #include <scsi/scsi.h>
#include <scsi/scsi_dbg.h> #include <scsi/scsi_dbg.h>
#include <scsi/scsi_eh.h> #include <scsi/scsi_eh.h>
...@@ -152,10 +153,7 @@ static unsigned submit_rtpg(struct scsi_device *sdev, struct alua_dh_data *h) ...@@ -152,10 +153,7 @@ static unsigned submit_rtpg(struct scsi_device *sdev, struct alua_dh_data *h)
rq->cmd[1] = MI_REPORT_TARGET_PGS | MI_EXT_HDR_PARAM_FMT; rq->cmd[1] = MI_REPORT_TARGET_PGS | MI_EXT_HDR_PARAM_FMT;
else else
rq->cmd[1] = MI_REPORT_TARGET_PGS; rq->cmd[1] = MI_REPORT_TARGET_PGS;
rq->cmd[6] = (h->bufflen >> 24) & 0xff; put_unaligned_be32(h->bufflen, &rq->cmd[6]);
rq->cmd[7] = (h->bufflen >> 16) & 0xff;
rq->cmd[8] = (h->bufflen >> 8) & 0xff;
rq->cmd[9] = h->bufflen & 0xff;
rq->cmd_len = COMMAND_SIZE(MAINTENANCE_IN); rq->cmd_len = COMMAND_SIZE(MAINTENANCE_IN);
rq->sense = h->sense; rq->sense = h->sense;
...@@ -236,8 +234,7 @@ static unsigned submit_stpg(struct alua_dh_data *h) ...@@ -236,8 +234,7 @@ static unsigned submit_stpg(struct alua_dh_data *h)
/* Prepare the data buffer */ /* Prepare the data buffer */
memset(h->buff, 0, stpg_len); memset(h->buff, 0, stpg_len);
h->buff[4] = TPGS_STATE_OPTIMIZED & 0x0f; h->buff[4] = TPGS_STATE_OPTIMIZED & 0x0f;
h->buff[6] = (h->group_id >> 8) & 0xff; put_unaligned_be16(h->group_id, &h->buff[6]);
h->buff[7] = h->group_id & 0xff;
rq = get_alua_req(sdev, h->buff, stpg_len, WRITE); rq = get_alua_req(sdev, h->buff, stpg_len, WRITE);
if (!rq) if (!rq)
...@@ -246,10 +243,7 @@ static unsigned submit_stpg(struct alua_dh_data *h) ...@@ -246,10 +243,7 @@ static unsigned submit_stpg(struct alua_dh_data *h)
/* Prepare the command. */ /* Prepare the command. */
rq->cmd[0] = MAINTENANCE_OUT; rq->cmd[0] = MAINTENANCE_OUT;
rq->cmd[1] = MO_SET_TARGET_PGS; rq->cmd[1] = MO_SET_TARGET_PGS;
rq->cmd[6] = (stpg_len >> 24) & 0xff; put_unaligned_be32(stpg_len, &rq->cmd[6]);
rq->cmd[7] = (stpg_len >> 16) & 0xff;
rq->cmd[8] = (stpg_len >> 8) & 0xff;
rq->cmd[9] = stpg_len & 0xff;
rq->cmd_len = COMMAND_SIZE(MAINTENANCE_OUT); rq->cmd_len = COMMAND_SIZE(MAINTENANCE_OUT);
rq->sense = h->sense; rq->sense = h->sense;
...@@ -343,11 +337,11 @@ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h) ...@@ -343,11 +337,11 @@ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h)
switch (d[1] & 0xf) { switch (d[1] & 0xf) {
case 0x4: case 0x4:
/* Relative target port */ /* Relative target port */
h->rel_port = (d[6] << 8) + d[7]; h->rel_port = get_unaligned_be16(&d[6]);
break; break;
case 0x5: case 0x5:
/* Target port group */ /* Target port group */
h->group_id = (d[6] << 8) + d[7]; h->group_id = get_unaligned_be16(&d[6]);
break; break;
default: default:
break; break;
...@@ -540,8 +534,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h, int wait_ ...@@ -540,8 +534,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h, int wait_
return SCSI_DH_IO; return SCSI_DH_IO;
} }
len = (h->buff[0] << 24) + (h->buff[1] << 16) + len = get_unaligned_be32(&h->buff[0]) + 4;
(h->buff[2] << 8) + h->buff[3] + 4;
if (len > h->bufflen) { if (len > h->bufflen) {
/* Resubmit with the correct length */ /* Resubmit with the correct length */
...@@ -576,7 +569,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h, int wait_ ...@@ -576,7 +569,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h, int wait_
k < len; k < len;
k += off, ucp += off) { k += off, ucp += off) {
if (h->group_id == (ucp[2] << 8) + ucp[3]) { if (h->group_id == get_unaligned_be16(&ucp[2])) {
h->state = ucp[0] & 0x0f; h->state = ucp[0] & 0x0f;
h->pref = ucp[0] >> 7; h->pref = ucp[0] >> 7;
valid_states = ucp[1]; valid_states = ucp[1];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册