diff options
| -rw-r--r-- | drivers/scsi/libata-scsi.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index e61cc357ae4a..96517ca021e3 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
| @@ -1248,11 +1248,14 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) | |||
| 1248 | * | 1248 | * |
| 1249 | * LOCKING: | 1249 | * LOCKING: |
| 1250 | * spin_lock_irqsave(host_set lock) | 1250 | * spin_lock_irqsave(host_set lock) |
| 1251 | * | ||
| 1252 | * RETURNS: | ||
| 1253 | * 0 on success, SCSI_ML_QUEUE_DEVICE_BUSY if the command | ||
| 1254 | * needs to be deferred. | ||
| 1251 | */ | 1255 | */ |
| 1252 | 1256 | static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, | |
| 1253 | static void ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, | 1257 | void (*done)(struct scsi_cmnd *), |
| 1254 | void (*done)(struct scsi_cmnd *), | 1258 | ata_xlat_func_t xlat_func) |
| 1255 | ata_xlat_func_t xlat_func) | ||
| 1256 | { | 1259 | { |
| 1257 | struct ata_queued_cmd *qc; | 1260 | struct ata_queued_cmd *qc; |
| 1258 | u8 *scsicmd = cmd->cmnd; | 1261 | u8 *scsicmd = cmd->cmnd; |
| @@ -1290,13 +1293,13 @@ static void ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, | |||
| 1290 | ata_qc_issue(qc); | 1293 | ata_qc_issue(qc); |
| 1291 | 1294 | ||
| 1292 | VPRINTK("EXIT\n"); | 1295 | VPRINTK("EXIT\n"); |
| 1293 | return; | 1296 | return 0; |
| 1294 | 1297 | ||
| 1295 | early_finish: | 1298 | early_finish: |
| 1296 | ata_qc_free(qc); | 1299 | ata_qc_free(qc); |
| 1297 | done(cmd); | 1300 | done(cmd); |
| 1298 | DPRINTK("EXIT - early finish (good or error)\n"); | 1301 | DPRINTK("EXIT - early finish (good or error)\n"); |
| 1299 | return; | 1302 | return 0; |
| 1300 | 1303 | ||
| 1301 | err_did: | 1304 | err_did: |
| 1302 | ata_qc_free(qc); | 1305 | ata_qc_free(qc); |
| @@ -1304,7 +1307,7 @@ err_mem: | |||
| 1304 | cmd->result = (DID_ERROR << 16); | 1307 | cmd->result = (DID_ERROR << 16); |
| 1305 | done(cmd); | 1308 | done(cmd); |
| 1306 | DPRINTK("EXIT - internal\n"); | 1309 | DPRINTK("EXIT - internal\n"); |
| 1307 | return; | 1310 | return 0; |
| 1308 | } | 1311 | } |
| 1309 | 1312 | ||
| 1310 | /** | 1313 | /** |
| @@ -2456,20 +2459,24 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap, | |||
| 2456 | #endif | 2459 | #endif |
| 2457 | } | 2460 | } |
| 2458 | 2461 | ||
| 2459 | static inline void __ata_scsi_queuecmd(struct scsi_cmnd *cmd, | 2462 | static inline int __ata_scsi_queuecmd(struct scsi_cmnd *cmd, |
| 2460 | void (*done)(struct scsi_cmnd *), | 2463 | void (*done)(struct scsi_cmnd *), |
| 2461 | struct ata_device *dev) | 2464 | struct ata_device *dev) |
| 2462 | { | 2465 | { |
| 2466 | int rc = 0; | ||
| 2467 | |||
| 2463 | if (dev->class == ATA_DEV_ATA) { | 2468 | if (dev->class == ATA_DEV_ATA) { |
| 2464 | ata_xlat_func_t xlat_func = ata_get_xlat_func(dev, | 2469 | ata_xlat_func_t xlat_func = ata_get_xlat_func(dev, |
| 2465 | cmd->cmnd[0]); | 2470 | cmd->cmnd[0]); |
| 2466 | 2471 | ||
| 2467 | if (xlat_func) | 2472 | if (xlat_func) |
| 2468 | ata_scsi_translate(dev, cmd, done, xlat_func); | 2473 | rc = ata_scsi_translate(dev, cmd, done, xlat_func); |
| 2469 | else | 2474 | else |
| 2470 | ata_scsi_simulate(dev, cmd, done); | 2475 | ata_scsi_simulate(dev, cmd, done); |
| 2471 | } else | 2476 | } else |
| 2472 | ata_scsi_translate(dev, cmd, done, atapi_xlat); | 2477 | rc = ata_scsi_translate(dev, cmd, done, atapi_xlat); |
| 2478 | |||
| 2479 | return rc; | ||
| 2473 | } | 2480 | } |
| 2474 | 2481 | ||
| 2475 | /** | 2482 | /** |
| @@ -2488,15 +2495,16 @@ static inline void __ata_scsi_queuecmd(struct scsi_cmnd *cmd, | |||
| 2488 | * Releases scsi-layer-held lock, and obtains host_set lock. | 2495 | * Releases scsi-layer-held lock, and obtains host_set lock. |
| 2489 | * | 2496 | * |
| 2490 | * RETURNS: | 2497 | * RETURNS: |
| 2491 | * Zero. | 2498 | * Return value from __ata_scsi_queuecmd() if @cmd can be queued, |
| 2499 | * 0 otherwise. | ||
| 2492 | */ | 2500 | */ |
| 2493 | |||
| 2494 | int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) | 2501 | int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) |
| 2495 | { | 2502 | { |
| 2496 | struct ata_port *ap; | 2503 | struct ata_port *ap; |
| 2497 | struct ata_device *dev; | 2504 | struct ata_device *dev; |
| 2498 | struct scsi_device *scsidev = cmd->device; | 2505 | struct scsi_device *scsidev = cmd->device; |
| 2499 | struct Scsi_Host *shost = scsidev->host; | 2506 | struct Scsi_Host *shost = scsidev->host; |
| 2507 | int rc = 0; | ||
| 2500 | 2508 | ||
| 2501 | ap = ata_shost_to_port(shost); | 2509 | ap = ata_shost_to_port(shost); |
| 2502 | 2510 | ||
| @@ -2507,7 +2515,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) | |||
| 2507 | 2515 | ||
| 2508 | dev = ata_scsi_find_dev(ap, scsidev); | 2516 | dev = ata_scsi_find_dev(ap, scsidev); |
| 2509 | if (likely(dev)) | 2517 | if (likely(dev)) |
| 2510 | __ata_scsi_queuecmd(cmd, done, dev); | 2518 | rc = __ata_scsi_queuecmd(cmd, done, dev); |
| 2511 | else { | 2519 | else { |
| 2512 | cmd->result = (DID_BAD_TARGET << 16); | 2520 | cmd->result = (DID_BAD_TARGET << 16); |
| 2513 | done(cmd); | 2521 | done(cmd); |
| @@ -2515,7 +2523,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) | |||
| 2515 | 2523 | ||
| 2516 | spin_unlock(&ap->host_set->lock); | 2524 | spin_unlock(&ap->host_set->lock); |
| 2517 | spin_lock(shost->host_lock); | 2525 | spin_lock(shost->host_lock); |
| 2518 | return 0; | 2526 | return rc; |
| 2519 | } | 2527 | } |
| 2520 | 2528 | ||
| 2521 | /** | 2529 | /** |
