diff options
author | Hannes Reinecke <hare@suse.de> | 2015-12-01 04:16:52 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2015-12-02 16:37:14 -0500 |
commit | a7089770b95902854f48b3bc7bec026dc8403286 (patch) | |
tree | f71435add33ecd86a366a316a4ccde95e27df0a6 /drivers/scsi/device_handler/scsi_dh_alua.c | |
parent | 6c4fc04491754834d5b5be189ee8f49a1d92b433 (diff) |
scsi_dh_alua: use unaligned access macros
Use 'get_unaligned_XX' and 'put_unaligned_XX' instead of
open-coding it.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/device_handler/scsi_dh_alua.c')
-rw-r--r-- | drivers/scsi/device_handler/scsi_dh_alua.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index d99fc14370cc..1c8e538d4a2e 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <asm/unaligned.h> | ||
25 | #include <scsi/scsi.h> | 26 | #include <scsi/scsi.h> |
26 | #include <scsi/scsi_dbg.h> | 27 | #include <scsi/scsi_dbg.h> |
27 | #include <scsi/scsi_eh.h> | 28 | #include <scsi/scsi_eh.h> |
@@ -152,10 +153,7 @@ static unsigned submit_rtpg(struct scsi_device *sdev, struct alua_dh_data *h) | |||
152 | rq->cmd[1] = MI_REPORT_TARGET_PGS | MI_EXT_HDR_PARAM_FMT; | 153 | rq->cmd[1] = MI_REPORT_TARGET_PGS | MI_EXT_HDR_PARAM_FMT; |
153 | else | 154 | else |
154 | rq->cmd[1] = MI_REPORT_TARGET_PGS; | 155 | rq->cmd[1] = MI_REPORT_TARGET_PGS; |
155 | rq->cmd[6] = (h->bufflen >> 24) & 0xff; | 156 | put_unaligned_be32(h->bufflen, &rq->cmd[6]); |
156 | rq->cmd[7] = (h->bufflen >> 16) & 0xff; | ||
157 | rq->cmd[8] = (h->bufflen >> 8) & 0xff; | ||
158 | rq->cmd[9] = h->bufflen & 0xff; | ||
159 | rq->cmd_len = COMMAND_SIZE(MAINTENANCE_IN); | 157 | rq->cmd_len = COMMAND_SIZE(MAINTENANCE_IN); |
160 | 158 | ||
161 | rq->sense = h->sense; | 159 | rq->sense = h->sense; |
@@ -236,8 +234,7 @@ static unsigned submit_stpg(struct alua_dh_data *h) | |||
236 | /* Prepare the data buffer */ | 234 | /* Prepare the data buffer */ |
237 | memset(h->buff, 0, stpg_len); | 235 | memset(h->buff, 0, stpg_len); |
238 | h->buff[4] = TPGS_STATE_OPTIMIZED & 0x0f; | 236 | h->buff[4] = TPGS_STATE_OPTIMIZED & 0x0f; |
239 | h->buff[6] = (h->group_id >> 8) & 0xff; | 237 | put_unaligned_be16(h->group_id, &h->buff[6]); |
240 | h->buff[7] = h->group_id & 0xff; | ||
241 | 238 | ||
242 | rq = get_alua_req(sdev, h->buff, stpg_len, WRITE); | 239 | rq = get_alua_req(sdev, h->buff, stpg_len, WRITE); |
243 | if (!rq) | 240 | if (!rq) |
@@ -246,10 +243,7 @@ static unsigned submit_stpg(struct alua_dh_data *h) | |||
246 | /* Prepare the command. */ | 243 | /* Prepare the command. */ |
247 | rq->cmd[0] = MAINTENANCE_OUT; | 244 | rq->cmd[0] = MAINTENANCE_OUT; |
248 | rq->cmd[1] = MO_SET_TARGET_PGS; | 245 | rq->cmd[1] = MO_SET_TARGET_PGS; |
249 | rq->cmd[6] = (stpg_len >> 24) & 0xff; | 246 | put_unaligned_be32(stpg_len, &rq->cmd[6]); |
250 | rq->cmd[7] = (stpg_len >> 16) & 0xff; | ||
251 | rq->cmd[8] = (stpg_len >> 8) & 0xff; | ||
252 | rq->cmd[9] = stpg_len & 0xff; | ||
253 | rq->cmd_len = COMMAND_SIZE(MAINTENANCE_OUT); | 247 | rq->cmd_len = COMMAND_SIZE(MAINTENANCE_OUT); |
254 | 248 | ||
255 | rq->sense = h->sense; | 249 | rq->sense = h->sense; |
@@ -343,11 +337,11 @@ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h) | |||
343 | switch (d[1] & 0xf) { | 337 | switch (d[1] & 0xf) { |
344 | case 0x4: | 338 | case 0x4: |
345 | /* Relative target port */ | 339 | /* Relative target port */ |
346 | h->rel_port = (d[6] << 8) + d[7]; | 340 | h->rel_port = get_unaligned_be16(&d[6]); |
347 | break; | 341 | break; |
348 | case 0x5: | 342 | case 0x5: |
349 | /* Target port group */ | 343 | /* Target port group */ |
350 | h->group_id = (d[6] << 8) + d[7]; | 344 | h->group_id = get_unaligned_be16(&d[6]); |
351 | break; | 345 | break; |
352 | default: | 346 | default: |
353 | break; | 347 | break; |
@@ -540,8 +534,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h, int wait_ | |||
540 | return SCSI_DH_IO; | 534 | return SCSI_DH_IO; |
541 | } | 535 | } |
542 | 536 | ||
543 | len = (h->buff[0] << 24) + (h->buff[1] << 16) + | 537 | len = get_unaligned_be32(&h->buff[0]) + 4; |
544 | (h->buff[2] << 8) + h->buff[3] + 4; | ||
545 | 538 | ||
546 | if (len > h->bufflen) { | 539 | if (len > h->bufflen) { |
547 | /* Resubmit with the correct length */ | 540 | /* 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 | k < len; | 569 | k < len; |
577 | k += off, ucp += off) { | 570 | k += off, ucp += off) { |
578 | 571 | ||
579 | if (h->group_id == (ucp[2] << 8) + ucp[3]) { | 572 | if (h->group_id == get_unaligned_be16(&ucp[2])) { |
580 | h->state = ucp[0] & 0x0f; | 573 | h->state = ucp[0] & 0x0f; |
581 | h->pref = ucp[0] >> 7; | 574 | h->pref = ucp[0] >> 7; |
582 | valid_states = ucp[1]; | 575 | valid_states = ucp[1]; |