--- linux/drivers/scsi/scsi_ioctl.c 2004-10-23 15:01:08.000000000 +1000 +++ linux/drivers/scsi/scsi_ioctl.c2610rc1ds 2004-11-08 20:56:44.000000000 +1000 @@ -21,6 +21,7 @@ #include #include #include +#include #include "scsi_logging.h" @@ -94,12 +95,13 @@ { struct scsi_request *sreq; int result; + struct scsi_sense_hdr sshdr; SCSI_LOG_IOCTL(1, printk("Trying ioctl with scsi command %d\n", *cmd)); sreq = scsi_allocate_request(sdev, GFP_KERNEL); if (!sreq) { - printk("SCSI internal ioctl failed, no memory\n"); + printk(KERN_WARNING "SCSI internal ioctl failed, no memory\n"); return -ENOMEM; } @@ -108,17 +110,21 @@ SCSI_LOG_IOCTL(2, printk("Ioctl returned 0x%x\n", sreq->sr_result)); - if (driver_byte(sreq->sr_result)) { - switch (sreq->sr_sense_buffer[2] & 0xf) { + if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) && + (scsi_request_normalize_sense(sreq, &sshdr))) { + switch (sshdr.sense_key) { case ILLEGAL_REQUEST: if (cmd[0] == ALLOW_MEDIUM_REMOVAL) sdev->lockable = 0; else - printk("SCSI device (ioctl) reports ILLEGAL REQUEST.\n"); + printk(KERN_INFO "ioctl_internal_command: " + "ILLEGAL REQUEST asc=0x%x ascq=0x%x\n", + sshdr.asc, sshdr.ascq); break; case NOT_READY: /* This happens if there is no disc in drive */ if (sdev->removable && (cmd[0] != TEST_UNIT_READY)) { - printk(KERN_INFO "Device not ready. Make sure there is a disc in the drive.\n"); + printk(KERN_INFO "Device not ready. Make sure" + " there is a disc in the drive.\n"); break; } case UNIT_ATTENTION: @@ -128,16 +134,15 @@ break; } default: /* Fall through for non-removable media */ - printk("SCSI error: host %d id %d lun %d return code = %x\n", + printk(KERN_INFO "ioctl_internal_command: <%d %d %d " + "%d> return code = %x\n", sdev->host->host_no, + sdev->channel, sdev->id, sdev->lun, sreq->sr_result); - printk("\tSense class %x, sense error %x, extended sense %x\n", - sense_class(sreq->sr_sense_buffer[0]), - sense_error(sreq->sr_sense_buffer[0]), - sreq->sr_sense_buffer[2] & 0xf); - + scsi_print_req_sense(" ", sreq); + break; } } @@ -401,7 +406,8 @@ case SCSI_IOCTL_SYNC: case SCSI_IOCTL_START_UNIT: case SCSI_IOCTL_STOP_UNIT: - printk(KERN_WARNING "program %s is using a deprecated SCSI ioctl, please convert it to SG_IO\n", current->comm); + printk(KERN_WARNING "program %s is using a deprecated SCSI " + "ioctl, please convert it to SG_IO\n", current->comm); break; default: break;