/* RETURNS: Return value from __ata_scsi_queuecmd() if @cmd can be queued, 0 otherwise.  */
int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void(*done)(struct scsi_cmnd *))
/* RETURNS: Return value from __ata_scsi_queuecmd() if @cmd can be queued, 0 otherwise.  */
int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void(*done)(struct scsi_cmnd *))
{
	struct ata_port *ap;
	struct ata_device *dev;
	struct scsi_device *scsidev = cmd->device;
	struct Scsi_Host *shost = scsidev->host;
	int rc = 0;
	ap = ata_shost_to_port(shost);
	spin_unlock(shost->host_lock);
	spin_lock(ap->lock);
	ata_scsi_dump_cdb(ap, cmd);
	dev = ata_scsi_find_dev(ap, scsidev);
	if (likely(dev))
		rc = __ata_scsi_queuecmd(cmd, done, dev);
	else {
		cmd->result = (DID_BAD_TARGET << 16);
		done(cmd);
	}
	spin_unlock(ap->lock);
	spin_lock(shost->host_lock);
	return rc;
}