spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 
static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int destid,				    quadlet_t *data, u64 addr, size_t length, u16 fl){	struct sbp2scsi_host_info *hi;	struct scsi_id_instance_data *scsi_id = NULL, *scsi_id_tmp;	u32 id;	struct scsi_cmnd *SCpnt = NULL;	u32 scsi_status = SBP2_SCSI_STATUS_GOOD;	struct sbp2_command_info *command;	SBP2_DEBUG("sbp2_handle_status_write");	sbp2util_packet_dump(data, length, "sbp2 status write by device", (u32)addr);	if (!host) {		SBP2_ERR("host is NULL - this is bad!");		return(RCODE_ADDRESS_ERROR);	}	hi = hpsb_get_hostinfo(&sbp2_highlevel, host);	if (!hi) {		SBP2_ERR("host info is NULL - this is bad!");		return(RCODE_ADDRESS_ERROR);	}	/*	 * Find our scsi_id structure by looking at the status fifo address written to by	 * the sbp2 device.	 */	id = SBP2_STATUS_FIFO_OFFSET_TO_ENTRY((u32)(addr - SBP2_STATUS_FIFO_ADDRESS));	list_for_each_entry(scsi_id_tmp, &hi->scsi_ids, scsi_list) {		if (scsi_id_tmp->ne->nodeid == nodeid && scsi_id_tmp->ud->id == id) {			scsi_id = scsi_id_tmp;			break;		}	}	if (!scsi_id) {		SBP2_ERR("scsi_id is NULL - device is gone?");		return(RCODE_ADDRESS_ERROR);	}	/*	 * Put response into scsi_id status fifo...	 */	memcpy(&scsi_id->status_block, data, length);	/*	 * Byte swap first two quadlets (8 bytes) of status for processing	 */	sbp2util_be32_to_cpu_buffer(&scsi_id->status_block, 8);	/*	 * Handle command ORB status here if necessary. First, need to match status with command.	 */	command = sbp2util_find_command_for_orb(scsi_id, scsi_id->status_block.ORB_offset_lo);	if (command) {		SBP2_DEBUG("Found status for command ORB");		pci_dma_sync_single_for_cpu(hi->host->pdev, command->command_orb_dma,					    sizeof(struct sbp2_command_orb),					    PCI_DMA_BIDIRECTIONAL);		pci_dma_sync_single_for_cpu(hi->host->pdev, command->sge_dma,					    sizeof(command->scatter_gather_element),					    PCI_DMA_BIDIRECTIONAL);		SBP2_ORB_DEBUG("matched command orb %p", &command->command_orb);		outstanding_orb_decr;		/*		 * Matched status with command, now grab scsi command pointers and check status		 */		SCpnt = command->Current_SCpnt;		sbp2util_mark_command_completed(scsi_id, command);		if (SCpnt) {			/*			 * See if the target stored any scsi status information			 */			if (STATUS_GET_LENGTH(scsi_id->status_block.ORB_offset_hi_misc) > 1) {				/*				 * Translate SBP-2 status to SCSI sense data				 */				SBP2_DEBUG("CHECK CONDITION");				scsi_status = sbp2_status_to_sense_data((unchar *)&scsi_id->status_block, SCpnt->sense_buffer);			}			/*			 * Check to see if the dead bit is set. If so, we'll have to initiate			 * a fetch agent reset.			 */			if (STATUS_GET_DEAD_BIT(scsi_id->status_block.ORB_offset_hi_misc)) {				/*				 * Initiate a fetch agent reset.				 */				SBP2_DEBUG("Dead bit set - initiating fetch agent reset");                                sbp2_agent_reset(scsi_id, 0);			}			SBP2_ORB_DEBUG("completing command orb %p", &command->command_orb);		}		/*		 * Check here to see if there are no commands in-use. If there are none, we can		 * null out last orb so that next time around we write directly to the orb pointer...		 * Quick start saves one 1394 bus transaction.		 */		if (list_empty(&scsi_id->sbp2_command_orb_inuse)) {			scsi_id->last_orb = NULL;		}	} else {		/*		 * It's probably a login/logout/reconnect status.		 */		if ((scsi_id->login_orb_dma == scsi_id->status_block.ORB_offset_lo) ||		    (scsi_id->query_logins_orb_dma == scsi_id->status_block.ORB_offset_lo) ||		    (scsi_id->reconnect_orb_dma == scsi_id->status_block.ORB_offset_lo) ||		    (scsi_id->logout_orb_dma == scsi_id->status_block.ORB_offset_lo)) {			atomic_set(&scsi_id->sbp2_login_complete, 1);		}	}	if (SCpnt) {		/* Complete the SCSI command. */		SBP2_DEBUG("Completing SCSI command");		sbp2scsi_complete_command(scsi_id, scsi_status, SCpnt,					  command->Current_done);		SBP2_ORB_DEBUG("command orb completed");	}	return(RCODE_COMPLETE);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/7945619794314414a5c44df11fca4d3f2a3389cf/sbp2.c/buggy/drivers/ieee1394/sbp2.c