/* Go from a u32 'context' to a struct scsi_cmnd * . This could probably be made more efficient.  */
static struct scsi_cmnd* adpt_cmd_from_context(adpt_hba *pHba, u32 context)
/* Go from a u32 'context' to a struct scsi_cmnd * . This could probably be made more efficient.  */
static struct scsi_cmnd* adpt_cmd_from_context(adpt_hba *pHba, u32 context)
{
	struct scsi_cmnd * cmd;
	struct scsi_device * d;
	if (context == 0)
		return NULL;
	spin_unlock(pHba->host->host_lock);
	shost_for_each_device(d, pHba->host) {
		unsigned long flags;
		spin_lock_irqsave(&d->list_lock, flags);
		list_for_each_entry(cmd, &d->cmd_list, list) {
			if (((u32)cmd->serial_number == context)) {
				spin_unlock_irqrestore(&d->list_lock, flags);
				scsi_device_put(d);
				spin_lock(pHba->host->host_lock);
				return cmd;
			}
		}
		spin_unlock_irqrestore(&d->list_lock, flags);
	}
	spin_lock(pHba->host->host_lock);
	return NULL;
}