aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libata-scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/libata-scsi.c')
-rw-r--r--drivers/scsi/libata-scsi.c240
1 files changed, 167 insertions, 73 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 59503c9ccac9..ccedb4536977 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -151,7 +151,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
151 struct scsi_sense_hdr sshdr; 151 struct scsi_sense_hdr sshdr;
152 enum dma_data_direction data_dir; 152 enum dma_data_direction data_dir;
153 153
154 if (NULL == (void *)arg) 154 if (arg == NULL)
155 return -EINVAL; 155 return -EINVAL;
156 156
157 if (copy_from_user(args, arg, sizeof(args))) 157 if (copy_from_user(args, arg, sizeof(args)))
@@ -201,7 +201,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
201 /* Need code to retrieve data from check condition? */ 201 /* Need code to retrieve data from check condition? */
202 202
203 if ((argbuf) 203 if ((argbuf)
204 && copy_to_user((void *)(arg + sizeof(args)), argbuf, argsize)) 204 && copy_to_user(arg + sizeof(args), argbuf, argsize))
205 rc = -EFAULT; 205 rc = -EFAULT;
206error: 206error:
207 if (argbuf) 207 if (argbuf)
@@ -228,7 +228,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
228 u8 args[7]; 228 u8 args[7];
229 struct scsi_sense_hdr sshdr; 229 struct scsi_sense_hdr sshdr;
230 230
231 if (NULL == (void *)arg) 231 if (arg == NULL)
232 return -EINVAL; 232 return -EINVAL;
233 233
234 if (copy_from_user(args, arg, sizeof(args))) 234 if (copy_from_user(args, arg, sizeof(args)))
@@ -553,7 +553,7 @@ void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc)
553 /* 553 /*
554 * Read the controller registers. 554 * Read the controller registers.
555 */ 555 */
556 assert(NULL != qc->ap->ops->tf_read); 556 WARN_ON(qc->ap->ops->tf_read == NULL);
557 qc->ap->ops->tf_read(qc->ap, tf); 557 qc->ap->ops->tf_read(qc->ap, tf);
558 558
559 /* 559 /*
@@ -628,7 +628,7 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
628 /* 628 /*
629 * Read the controller registers. 629 * Read the controller registers.
630 */ 630 */
631 assert(NULL != qc->ap->ops->tf_read); 631 WARN_ON(qc->ap->ops->tf_read == NULL);
632 qc->ap->ops->tf_read(qc->ap, tf); 632 qc->ap->ops->tf_read(qc->ap, tf);
633 633
634 /* 634 /*
@@ -684,23 +684,23 @@ int ata_scsi_slave_config(struct scsi_device *sdev)
684 if (sdev->id < ATA_MAX_DEVICES) { 684 if (sdev->id < ATA_MAX_DEVICES) {
685 struct ata_port *ap; 685 struct ata_port *ap;
686 struct ata_device *dev; 686 struct ata_device *dev;
687 unsigned int max_sectors;
687 688
688 ap = (struct ata_port *) &sdev->host->hostdata[0]; 689 ap = (struct ata_port *) &sdev->host->hostdata[0];
689 dev = &ap->device[sdev->id]; 690 dev = &ap->device[sdev->id];
690 691
691 /* TODO: 1024 is an arbitrary number, not the 692 /* TODO: 2048 is an arbitrary number, not the
692 * hardware maximum. This should be increased to 693 * hardware maximum. This should be increased to
693 * 65534 when Jens Axboe's patch for dynamically 694 * 65534 when Jens Axboe's patch for dynamically
694 * determining max_sectors is merged. 695 * determining max_sectors is merged.
695 */ 696 */
696 if ((dev->flags & ATA_DFLAG_LBA48) && 697 max_sectors = ATA_MAX_SECTORS;
697 ((dev->flags & ATA_DFLAG_LOCK_SECTORS) == 0)) { 698 if (dev->flags & ATA_DFLAG_LBA48)
698 /* 699 max_sectors = 2048;
699 * do not overwrite sdev->host->max_sectors, since 700 if (dev->max_sectors)
700 * other drives on this host may not support LBA48 701 max_sectors = dev->max_sectors;
701 */ 702
702 blk_queue_max_sectors(sdev->request_queue, 2048); 703 blk_queue_max_sectors(sdev->request_queue, max_sectors);
703 }
704 704
705 /* 705 /*
706 * SATA DMA transfers must be multiples of 4 byte, so 706 * SATA DMA transfers must be multiples of 4 byte, so
@@ -717,6 +717,47 @@ int ata_scsi_slave_config(struct scsi_device *sdev)
717} 717}
718 718
719/** 719/**
720 * ata_scsi_timed_out - SCSI layer time out callback
721 * @cmd: timed out SCSI command
722 *
723 * Handles SCSI layer timeout. We race with normal completion of
724 * the qc for @cmd. If the qc is already gone, we lose and let
725 * the scsi command finish (EH_HANDLED). Otherwise, the qc has
726 * timed out and EH should be invoked. Prevent ata_qc_complete()
727 * from finishing it by setting EH_SCHEDULED and return
728 * EH_NOT_HANDLED.
729 *
730 * LOCKING:
731 * Called from timer context
732 *
733 * RETURNS:
734 * EH_HANDLED or EH_NOT_HANDLED
735 */
736enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd)
737{
738 struct Scsi_Host *host = cmd->device->host;
739 struct ata_port *ap = (struct ata_port *) &host->hostdata[0];
740 unsigned long flags;
741 struct ata_queued_cmd *qc;
742 enum scsi_eh_timer_return ret = EH_HANDLED;
743
744 DPRINTK("ENTER\n");
745
746 spin_lock_irqsave(&ap->host_set->lock, flags);
747 qc = ata_qc_from_tag(ap, ap->active_tag);
748 if (qc) {
749 WARN_ON(qc->scsicmd != cmd);
750 qc->flags |= ATA_QCFLAG_EH_SCHEDULED;
751 qc->err_mask |= AC_ERR_TIMEOUT;
752 ret = EH_NOT_HANDLED;
753 }
754 spin_unlock_irqrestore(&ap->host_set->lock, flags);
755
756 DPRINTK("EXIT, ret=%d\n", ret);
757 return ret;
758}
759
760/**
720 * ata_scsi_error - SCSI layer error handler callback 761 * ata_scsi_error - SCSI layer error handler callback
721 * @host: SCSI host on which error occurred 762 * @host: SCSI host on which error occurred
722 * 763 *
@@ -732,23 +773,84 @@ int ata_scsi_slave_config(struct scsi_device *sdev)
732int ata_scsi_error(struct Scsi_Host *host) 773int ata_scsi_error(struct Scsi_Host *host)
733{ 774{
734 struct ata_port *ap; 775 struct ata_port *ap;
776 unsigned long flags;
735 777
736 DPRINTK("ENTER\n"); 778 DPRINTK("ENTER\n");
737 779
738 ap = (struct ata_port *) &host->hostdata[0]; 780 ap = (struct ata_port *) &host->hostdata[0];
781
782 spin_lock_irqsave(&ap->host_set->lock, flags);
783 WARN_ON(ap->flags & ATA_FLAG_IN_EH);
784 ap->flags |= ATA_FLAG_IN_EH;
785 WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL);
786 spin_unlock_irqrestore(&ap->host_set->lock, flags);
787
788 ata_port_flush_task(ap);
789
739 ap->ops->eng_timeout(ap); 790 ap->ops->eng_timeout(ap);
740 791
741 /* TODO: this is per-command; when queueing is supported 792 WARN_ON(host->host_failed || !list_empty(&host->eh_cmd_q));
742 * this code will either change or move to a more 793
743 * appropriate place 794 scsi_eh_flush_done_q(&ap->eh_done_q);
744 */ 795
745 host->host_failed--; 796 spin_lock_irqsave(&ap->host_set->lock, flags);
746 INIT_LIST_HEAD(&host->eh_cmd_q); 797 ap->flags &= ~ATA_FLAG_IN_EH;
798 spin_unlock_irqrestore(&ap->host_set->lock, flags);
747 799
748 DPRINTK("EXIT\n"); 800 DPRINTK("EXIT\n");
749 return 0; 801 return 0;
750} 802}
751 803
804static void ata_eh_scsidone(struct scsi_cmnd *scmd)
805{
806 /* nada */
807}
808
809static void __ata_eh_qc_complete(struct ata_queued_cmd *qc)
810{
811 struct ata_port *ap = qc->ap;
812 struct scsi_cmnd *scmd = qc->scsicmd;
813 unsigned long flags;
814
815 spin_lock_irqsave(&ap->host_set->lock, flags);
816 qc->scsidone = ata_eh_scsidone;
817 __ata_qc_complete(qc);
818 WARN_ON(ata_tag_valid(qc->tag));
819 spin_unlock_irqrestore(&ap->host_set->lock, flags);
820
821 scsi_eh_finish_cmd(scmd, &ap->eh_done_q);
822}
823
824/**
825 * ata_eh_qc_complete - Complete an active ATA command from EH
826 * @qc: Command to complete
827 *
828 * Indicate to the mid and upper layers that an ATA command has
829 * completed. To be used from EH.
830 */
831void ata_eh_qc_complete(struct ata_queued_cmd *qc)
832{
833 struct scsi_cmnd *scmd = qc->scsicmd;
834 scmd->retries = scmd->allowed;
835 __ata_eh_qc_complete(qc);
836}
837
838/**
839 * ata_eh_qc_retry - Tell midlayer to retry an ATA command after EH
840 * @qc: Command to retry
841 *
842 * Indicate to the mid and upper layers that an ATA command
843 * should be retried. To be used from EH.
844 *
845 * SCSI midlayer limits the number of retries to scmd->allowed.
846 * This function might need to adjust scmd->retries for commands
847 * which get retried due to unrelated NCQ failures.
848 */
849void ata_eh_qc_retry(struct ata_queued_cmd *qc)
850{
851 __ata_eh_qc_complete(qc);
852}
853
752/** 854/**
753 * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command 855 * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command
754 * @qc: Storage for translated ATA taskfile 856 * @qc: Storage for translated ATA taskfile
@@ -985,9 +1087,13 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc
985 if (dev->flags & ATA_DFLAG_LBA) { 1087 if (dev->flags & ATA_DFLAG_LBA) {
986 tf->flags |= ATA_TFLAG_LBA; 1088 tf->flags |= ATA_TFLAG_LBA;
987 1089
988 if (dev->flags & ATA_DFLAG_LBA48) { 1090 if (lba_28_ok(block, n_block)) {
989 if (n_block > (64 * 1024)) 1091 /* use LBA28 */
990 goto invalid_fld; 1092 tf->command = ATA_CMD_VERIFY;
1093 tf->device |= (block >> 24) & 0xf;
1094 } else if (lba_48_ok(block, n_block)) {
1095 if (!(dev->flags & ATA_DFLAG_LBA48))
1096 goto out_of_range;
991 1097
992 /* use LBA48 */ 1098 /* use LBA48 */
993 tf->flags |= ATA_TFLAG_LBA48; 1099 tf->flags |= ATA_TFLAG_LBA48;
@@ -998,15 +1104,9 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc
998 tf->hob_lbah = (block >> 40) & 0xff; 1104 tf->hob_lbah = (block >> 40) & 0xff;
999 tf->hob_lbam = (block >> 32) & 0xff; 1105 tf->hob_lbam = (block >> 32) & 0xff;
1000 tf->hob_lbal = (block >> 24) & 0xff; 1106 tf->hob_lbal = (block >> 24) & 0xff;
1001 } else { 1107 } else
1002 if (n_block > 256) 1108 /* request too large even for LBA48 */
1003 goto invalid_fld; 1109 goto out_of_range;
1004
1005 /* use LBA28 */
1006 tf->command = ATA_CMD_VERIFY;
1007
1008 tf->device |= (block >> 24) & 0xf;
1009 }
1010 1110
1011 tf->nsect = n_block & 0xff; 1111 tf->nsect = n_block & 0xff;
1012 1112
@@ -1019,8 +1119,8 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc
1019 /* CHS */ 1119 /* CHS */
1020 u32 sect, head, cyl, track; 1120 u32 sect, head, cyl, track;
1021 1121
1022 if (n_block > 256) 1122 if (!lba_28_ok(block, n_block))
1023 goto invalid_fld; 1123 goto out_of_range;
1024 1124
1025 /* Convert LBA to CHS */ 1125 /* Convert LBA to CHS */
1026 track = (u32)block / dev->sectors; 1126 track = (u32)block / dev->sectors;
@@ -1139,9 +1239,11 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1139 if (dev->flags & ATA_DFLAG_LBA) { 1239 if (dev->flags & ATA_DFLAG_LBA) {
1140 tf->flags |= ATA_TFLAG_LBA; 1240 tf->flags |= ATA_TFLAG_LBA;
1141 1241
1142 if (dev->flags & ATA_DFLAG_LBA48) { 1242 if (lba_28_ok(block, n_block)) {
1143 /* The request -may- be too large for LBA48. */ 1243 /* use LBA28 */
1144 if ((block >> 48) || (n_block > 65536)) 1244 tf->device |= (block >> 24) & 0xf;
1245 } else if (lba_48_ok(block, n_block)) {
1246 if (!(dev->flags & ATA_DFLAG_LBA48))
1145 goto out_of_range; 1247 goto out_of_range;
1146 1248
1147 /* use LBA48 */ 1249 /* use LBA48 */
@@ -1152,15 +1254,9 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1152 tf->hob_lbah = (block >> 40) & 0xff; 1254 tf->hob_lbah = (block >> 40) & 0xff;
1153 tf->hob_lbam = (block >> 32) & 0xff; 1255 tf->hob_lbam = (block >> 32) & 0xff;
1154 tf->hob_lbal = (block >> 24) & 0xff; 1256 tf->hob_lbal = (block >> 24) & 0xff;
1155 } else { 1257 } else
1156 /* use LBA28 */ 1258 /* request too large even for LBA48 */
1157 1259 goto out_of_range;
1158 /* The request -may- be too large for LBA28. */
1159 if ((block >> 28) || (n_block > 256))
1160 goto out_of_range;
1161
1162 tf->device |= (block >> 24) & 0xf;
1163 }
1164 1260
1165 if (unlikely(ata_rwcmd_protocol(qc) < 0)) 1261 if (unlikely(ata_rwcmd_protocol(qc) < 0))
1166 goto invalid_fld; 1262 goto invalid_fld;
@@ -1178,7 +1274,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1178 u32 sect, head, cyl, track; 1274 u32 sect, head, cyl, track;
1179 1275
1180 /* The request -may- be too large for CHS addressing. */ 1276 /* The request -may- be too large for CHS addressing. */
1181 if ((block >> 28) || (n_block > 256)) 1277 if (!lba_28_ok(block, n_block))
1182 goto out_of_range; 1278 goto out_of_range;
1183 1279
1184 if (unlikely(ata_rwcmd_protocol(qc) < 0)) 1280 if (unlikely(ata_rwcmd_protocol(qc) < 0))
@@ -1225,7 +1321,7 @@ nothing_to_do:
1225 return 1; 1321 return 1;
1226} 1322}
1227 1323
1228static int ata_scsi_qc_complete(struct ata_queued_cmd *qc) 1324static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1229{ 1325{
1230 struct scsi_cmnd *cmd = qc->scsicmd; 1326 struct scsi_cmnd *cmd = qc->scsicmd;
1231 u8 *cdb = cmd->cmnd; 1327 u8 *cdb = cmd->cmnd;
@@ -1262,7 +1358,7 @@ static int ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1262 1358
1263 qc->scsidone(cmd); 1359 qc->scsidone(cmd);
1264 1360
1265 return 0; 1361 ata_qc_free(qc);
1266} 1362}
1267 1363
1268/** 1364/**
@@ -1328,8 +1424,9 @@ static void ata_scsi_translate(struct ata_port *ap, struct ata_device *dev,
1328 goto early_finish; 1424 goto early_finish;
1329 1425
1330 /* select device, send command to hardware */ 1426 /* select device, send command to hardware */
1331 if (ata_qc_issue(qc)) 1427 qc->err_mask = ata_qc_issue(qc);
1332 goto err_did; 1428 if (qc->err_mask)
1429 ata_qc_complete(qc);
1333 1430
1334 VPRINTK("EXIT\n"); 1431 VPRINTK("EXIT\n");
1335 return; 1432 return;
@@ -1472,8 +1569,8 @@ unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
1472 1569
1473 if (buflen > 35) { 1570 if (buflen > 35) {
1474 memcpy(&rbuf[8], "ATA ", 8); 1571 memcpy(&rbuf[8], "ATA ", 8);
1475 ata_dev_id_string(args->id, &rbuf[16], ATA_ID_PROD_OFS, 16); 1572 ata_id_string(args->id, &rbuf[16], ATA_ID_PROD_OFS, 16);
1476 ata_dev_id_string(args->id, &rbuf[32], ATA_ID_FW_REV_OFS, 4); 1573 ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV_OFS, 4);
1477 if (rbuf[32] == 0 || rbuf[32] == ' ') 1574 if (rbuf[32] == 0 || rbuf[32] == ' ')
1478 memcpy(&rbuf[32], "n/a ", 4); 1575 memcpy(&rbuf[32], "n/a ", 4);
1479 } 1576 }
@@ -1547,8 +1644,8 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
1547 memcpy(rbuf, hdr, sizeof(hdr)); 1644 memcpy(rbuf, hdr, sizeof(hdr));
1548 1645
1549 if (buflen > (ATA_SERNO_LEN + 4 - 1)) 1646 if (buflen > (ATA_SERNO_LEN + 4 - 1))
1550 ata_dev_id_string(args->id, (unsigned char *) &rbuf[4], 1647 ata_id_string(args->id, (unsigned char *) &rbuf[4],
1551 ATA_ID_SERNO_OFS, ATA_SERNO_LEN); 1648 ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
1552 1649
1553 return 0; 1650 return 0;
1554} 1651}
@@ -1713,15 +1810,12 @@ static int ata_dev_supports_fua(u16 *id)
1713 if (!ata_id_has_fua(id)) 1810 if (!ata_id_has_fua(id))
1714 return 0; 1811 return 0;
1715 1812
1716 model[40] = '\0'; 1813 ata_id_c_string(id, model, ATA_ID_PROD_OFS, sizeof(model));
1717 fw[8] = '\0'; 1814 ata_id_c_string(id, fw, ATA_ID_FW_REV_OFS, sizeof(fw));
1718
1719 ata_dev_id_string(id, model, ATA_ID_PROD_OFS, sizeof(model) - 1);
1720 ata_dev_id_string(id, fw, ATA_ID_FW_REV_OFS, sizeof(fw) - 1);
1721 1815
1722 if (strncmp(model, "Maxtor", 6)) 1816 if (strcmp(model, "Maxtor"))
1723 return 1; 1817 return 1;
1724 if (strncmp(fw, "BANC1G10", 8)) 1818 if (strcmp(fw, "BANC1G10"))
1725 return 1; 1819 return 1;
1726 1820
1727 return 0; /* blacklisted */ 1821 return 0; /* blacklisted */
@@ -2015,7 +2109,7 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8
2015 done(cmd); 2109 done(cmd);
2016} 2110}
2017 2111
2018static int atapi_sense_complete(struct ata_queued_cmd *qc) 2112static void atapi_sense_complete(struct ata_queued_cmd *qc)
2019{ 2113{
2020 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) 2114 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0))
2021 /* FIXME: not quite right; we don't want the 2115 /* FIXME: not quite right; we don't want the
@@ -2026,7 +2120,7 @@ static int atapi_sense_complete(struct ata_queued_cmd *qc)
2026 ata_gen_ata_desc_sense(qc); 2120 ata_gen_ata_desc_sense(qc);
2027 2121
2028 qc->scsidone(qc->scsicmd); 2122 qc->scsidone(qc->scsicmd);
2029 return 0; 2123 ata_qc_free(qc);
2030} 2124}
2031 2125
2032/* is it pointless to prefer PIO for "safety reasons"? */ 2126/* is it pointless to prefer PIO for "safety reasons"? */
@@ -2056,7 +2150,7 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
2056 ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer)); 2150 ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer));
2057 qc->dma_dir = DMA_FROM_DEVICE; 2151 qc->dma_dir = DMA_FROM_DEVICE;
2058 2152
2059 memset(&qc->cdb, 0, ap->cdb_len); 2153 memset(&qc->cdb, 0, qc->dev->cdb_len);
2060 qc->cdb[0] = REQUEST_SENSE; 2154 qc->cdb[0] = REQUEST_SENSE;
2061 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE; 2155 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE;
2062 2156
@@ -2075,15 +2169,14 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
2075 2169
2076 qc->complete_fn = atapi_sense_complete; 2170 qc->complete_fn = atapi_sense_complete;
2077 2171
2078 if (ata_qc_issue(qc)) { 2172 qc->err_mask = ata_qc_issue(qc);
2079 qc->err_mask |= AC_ERR_OTHER; 2173 if (qc->err_mask)
2080 ata_qc_complete(qc); 2174 ata_qc_complete(qc);
2081 }
2082 2175
2083 DPRINTK("EXIT\n"); 2176 DPRINTK("EXIT\n");
2084} 2177}
2085 2178
2086static int atapi_qc_complete(struct ata_queued_cmd *qc) 2179static void atapi_qc_complete(struct ata_queued_cmd *qc)
2087{ 2180{
2088 struct scsi_cmnd *cmd = qc->scsicmd; 2181 struct scsi_cmnd *cmd = qc->scsicmd;
2089 unsigned int err_mask = qc->err_mask; 2182 unsigned int err_mask = qc->err_mask;
@@ -2093,7 +2186,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc)
2093 if (unlikely(err_mask & AC_ERR_DEV)) { 2186 if (unlikely(err_mask & AC_ERR_DEV)) {
2094 cmd->result = SAM_STAT_CHECK_CONDITION; 2187 cmd->result = SAM_STAT_CHECK_CONDITION;
2095 atapi_request_sense(qc); 2188 atapi_request_sense(qc);
2096 return 1; 2189 return;
2097 } 2190 }
2098 2191
2099 else if (unlikely(err_mask)) 2192 else if (unlikely(err_mask))
@@ -2133,7 +2226,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc)
2133 } 2226 }
2134 2227
2135 qc->scsidone(cmd); 2228 qc->scsidone(cmd);
2136 return 0; 2229 ata_qc_free(qc);
2137} 2230}
2138/** 2231/**
2139 * atapi_xlat - Initialize PACKET taskfile 2232 * atapi_xlat - Initialize PACKET taskfile
@@ -2159,7 +2252,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
2159 if (ata_check_atapi_dma(qc)) 2252 if (ata_check_atapi_dma(qc))
2160 using_pio = 1; 2253 using_pio = 1;
2161 2254
2162 memcpy(&qc->cdb, scsicmd, qc->ap->cdb_len); 2255 memcpy(&qc->cdb, scsicmd, dev->cdb_len);
2163 2256
2164 qc->complete_fn = atapi_qc_complete; 2257 qc->complete_fn = atapi_qc_complete;
2165 2258
@@ -2519,7 +2612,8 @@ out_unlock:
2519 2612
2520/** 2613/**
2521 * ata_scsi_simulate - simulate SCSI command on ATA device 2614 * ata_scsi_simulate - simulate SCSI command on ATA device
2522 * @id: current IDENTIFY data for target device. 2615 * @ap: port the device is connected to
2616 * @dev: the target device
2523 * @cmd: SCSI command being sent to device. 2617 * @cmd: SCSI command being sent to device.
2524 * @done: SCSI command completion function. 2618 * @done: SCSI command completion function.
2525 * 2619 *