Skip to content

Commit

Permalink
advansys: fix big-endian builds
Browse files Browse the repository at this point in the history
Building the advansys driver in a big-endian configuration such as
ARM allmodconfig shows a warning:

 drivers/scsi/advansys.c: In function 'adv_build_req':
 include/uapi/linux/byteorder/big_endian.h:32:26: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
 drivers/scsi/advansys.c:7806:22: note: in expansion of macro 'cpu_to_le32'
   scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);

It turns out that the commit that introduced this used the cpu_to_le32()
incorrectly on an 8-bit field, which results in the sense_len to always
be set to zero, as the SCSI_SENSE_BUFFERSIZE value gets moved to upper
byte of the 32-bit intermediate.

This removes the cpu_to_le32() call to restore the original version.

I found this only by looking at the compiler output and have not done a
full review for possible further endianess bugs in the same driver.

Signed-off-by: Arnd Bergmann <[email protected]>
Fixes: 811ddc0 ("advansys: use DMA-API for mapping sense buffer")
Reviewed-by: Hannes Reinecke <[email protected]>
Cc: [email protected] # v4.2+
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
arndb authored and martinkpetersen committed Nov 18, 2015
1 parent 0874f8e commit 757b22f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/scsi/advansys.c
Original file line number Diff line number Diff line change
Expand Up @@ -7803,7 +7803,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
return ASC_BUSY;
}
scsiqp->sense_addr = cpu_to_le32(sense_addr);
scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;

/* Build ADV_SCSI_REQ_Q */

Expand Down

0 comments on commit 757b22f

Please sign in to comment.