On 10-09-15 04:39 PM, Douglas Gilbert wrote:
... to something like: scsi_status_byte_div2() or: scsi_broken_status_byte()
The bug in the bsg driver with its SCSI status byte brought this to my attention. If memory serves about 10 years ago some of us tried to kill the status_byte() macro. But it is still there in the kernel's scsi/scsi.h ready to trip up another generation of programmers: #define status_byte(result) (((result) >> 1) & 0x7f) with no explanation that it does NOT yield the SCSI status byte but the right shifted (once) equivalent. The correct macro (or inline function) for obtaining the SCSI status byte from the 32 bit "result" from a LLD would be: #define scsi_status_byte(result) ((result) & 0xff) [Long ago (20 years) something silly was put in bit 0 so masking with 0xfe would work as well.] Another thought, these macros are associated with the mid-level or a ULD deciding whether a SCSI command has succeeded; so scsi_cmnd.h would be a more appropriate header. Happily the version of scsi.h shown to the user space (typically /usr/include/scsi/scsi.h) does not include these defective macros. So any API breakage is limited to the kernel. Doug Gilbert -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html