]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/ata/libata-scsi.c
Merge branches 'for-4.11/upstream-fixes', 'for-4.12/accutouch', 'for-4.12/cp2112...
[karo-tx-linux.git] / drivers / ata / libata-scsi.c
index 28e2530b9cd391feca8f5fdb7de845c0bba93f8f..12d3a66600a3f7a7a7c693b604a6c89ee7bc5576 100644 (file)
@@ -484,13 +484,6 @@ struct device_attribute *ata_common_sdev_attrs[] = {
 };
 EXPORT_SYMBOL_GPL(ata_common_sdev_attrs);
 
-static void ata_scsi_invalid_field(struct ata_device *dev,
-                                  struct scsi_cmnd *cmd, u16 field)
-{
-       ata_scsi_set_invalid_field(dev, cmd, field, 0xff);
-       cmd->scsi_done(cmd);
-}
-
 /**
  *     ata_std_bios_param - generic bios head/sector/cylinder calculator used by sd.
  *     @sdev: SCSI device for which BIOS geometry is to be determined
@@ -1265,13 +1258,13 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev)
  */
 static int atapi_drain_needed(struct request *rq)
 {
-       if (likely(rq->cmd_type != REQ_TYPE_BLOCK_PC))
+       if (likely(!blk_rq_is_passthrough(rq)))
                return 0;
 
        if (!blk_rq_bytes(rq) || op_is_write(req_op(rq)))
                return 0;
 
-       return atapi_cmd_type(rq->cmd[0]) == ATAPI_MISC;
+       return atapi_cmd_type(scsi_req(rq)->cmd[0]) == ATAPI_MISC;
 }
 
 static int ata_scsi_dev_config(struct scsi_device *sdev,
@@ -2139,7 +2132,6 @@ static void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
 
        if (rc == 0)
                cmd->result = SAM_STAT_GOOD;
-       cmd->scsi_done(cmd);
 }
 
 /**
@@ -2460,23 +2452,6 @@ static unsigned int ata_scsiop_inq_b6(struct ata_scsi_args *args, u8 *rbuf)
        return 0;
 }
 
-/**
- *     ata_scsiop_noop - Command handler that simply returns success.
- *     @args: device IDENTIFY data / SCSI command of interest.
- *     @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
- *
- *     No operation.  Simply returns success to caller, to indicate
- *     that the caller should successfully complete this SCSI command.
- *
- *     LOCKING:
- *     spin_lock_irqsave(host lock)
- */
-static unsigned int ata_scsiop_noop(struct ata_scsi_args *args, u8 *rbuf)
-{
-       VPRINTK("ENTER\n");
-       return 0;
-}
-
 /**
  *     modecpy - Prepare response for MODE SENSE
  *     @dest: output buffer
@@ -4360,7 +4335,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
        switch(scsicmd[0]) {
        case INQUIRY:
                if (scsicmd[1] & 2)                /* is CmdDt set?  */
-                   ata_scsi_invalid_field(dev, cmd, 1);
+                       ata_scsi_set_invalid_field(dev, cmd, 1, 0xff);
                else if ((scsicmd[1] & 1) == 0)    /* is EVPD clear? */
                        ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std);
                else switch (scsicmd[2]) {
@@ -4392,7 +4367,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
                        }
                        /* Fallthrough */
                default:
-                       ata_scsi_invalid_field(dev, cmd, 2);
+                       ata_scsi_set_invalid_field(dev, cmd, 2, 0xff);
                        break;
                }
                break;
@@ -4410,7 +4385,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
                if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16)
                        ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap);
                else
-                       ata_scsi_invalid_field(dev, cmd, 1);
+                       ata_scsi_set_invalid_field(dev, cmd, 1, 0xff);
                break;
 
        case REPORT_LUNS:
@@ -4420,7 +4395,6 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
        case REQUEST_SENSE:
                ata_scsi_set_sense(dev, cmd, 0, 0, 0);
                cmd->result = (DRIVER_SENSE << 24);
-               cmd->scsi_done(cmd);
                break;
 
        /* if we reach this, then writeback caching is disabled,
@@ -4434,31 +4408,29 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
        case SEEK_6:
        case SEEK_10:
        case TEST_UNIT_READY:
-               ata_scsi_rbuf_fill(&args, ata_scsiop_noop);
                break;
 
        case SEND_DIAGNOSTIC:
                tmp8 = scsicmd[1] & ~(1 << 3);
-               if ((tmp8 == 0x4) && (!scsicmd[3]) && (!scsicmd[4]))
-                       ata_scsi_rbuf_fill(&args, ata_scsiop_noop);
-               else
-                       ata_scsi_invalid_field(dev, cmd, 1);
+               if (tmp8 != 0x4 || scsicmd[3] || scsicmd[4])
+                       ata_scsi_set_invalid_field(dev, cmd, 1, 0xff);
                break;
 
        case MAINTENANCE_IN:
                if (scsicmd[1] == MI_REPORT_SUPPORTED_OPERATION_CODES)
                        ata_scsi_rbuf_fill(&args, ata_scsiop_maint_in);
                else
-                       ata_scsi_invalid_field(dev, cmd, 1);
+                       ata_scsi_set_invalid_field(dev, cmd, 1, 0xff);
                break;
 
        /* all other commands */
        default:
                ata_scsi_set_sense(dev, cmd, ILLEGAL_REQUEST, 0x20, 0x0);
                /* "Invalid command operation code" */
-               cmd->scsi_done(cmd);
                break;
        }
+
+       cmd->scsi_done(cmd);
 }
 
 int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht)