Hack to not step on vendor commands for some devices
Hi all,
I'm trying to support an usb-storage device that uses vendor-specific SCSI commands for some functions; I'm using the sg interface from user space.
The problem is, the linux kernel will replace some bits in the vendor-specific command with the LUN number, making it unintelligible to the device. I wrote the included patch that works around this problem.
cmd->device->scsi_level is SCSI_2 for this device.
Is there any other user-space solution to this problem? If not, what are the next steps to have a solution appear in the mainline kernel?
Best Regards,
Pontus
Signature · 19 lines
Pontus Lidman, [email protected], Software Engineer diff --recursive -u linux-2.6.24.5/drivers/scsi/scsi.c linux-2.6.24.5.pl/drivers/scsi/scsi.c --- linux-2.6.24.5/drivers/scsi/scsi.c 2008-04-19 03:53:39.000000000 +0200 +++ linux-2.6.24.5.pl/drivers/scsi/scsi.c 2008-04-27 17:17:35.000000000 +0200 @@ -501,9 +501,12 @@ /* * If SCSI-2 or lower, store the LUN value in cmnd. + * However, don't modify the contents of vendor specific + * commands (0xf0-0xff). */ if (cmd->device->scsi_level <= SCSI_2 && - cmd->device->scsi_level != SCSI_UNKNOWN) { + cmd->device->scsi_level != SCSI_UNKNOWN && + cmd->cmnd[0] < 0xf0) { cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) | (cmd->device->lun << 5 & 0xe0); }