ahd_linux_dev_reset(Scsi_Cmnd *cmd) 
ahd_linux_dev_reset(struct scsi_cmnd *cmd) 
ahd_linux_dev_reset(Scsi_Cmnd *cmd){	struct	ahd_softc *ahd;	struct	scsi_cmnd *recovery_cmd;	struct	ahd_linux_device *dev;	struct	ahd_initiator_tinfo *tinfo;	struct	ahd_tmode_tstate *tstate;	struct	scb *scb;	struct	hardware_scb *hscb;	u_long	s;	struct	timer_list timer;	int	retval;	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;	recovery_cmd = malloc(sizeof(struct scsi_cmnd), M_DEVBUF, M_WAITOK);	if (!recovery_cmd)		return (FAILED);	memset(recovery_cmd, 0, sizeof(struct scsi_cmnd));	recovery_cmd->device = cmd->device;	recovery_cmd->scsi_done = ahd_linux_dev_reset_complete;#ifdef AHD_DEBUG	if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)		printf("%s:%d:%d:%d: Device reset called for cmd %p\n",		       ahd_name(ahd), cmd->device->channel, cmd->device->id,		       cmd->device->lun, cmd);#endif	ahd_lock(ahd, &s);	dev = ahd_linux_get_device(ahd, cmd->device->channel, cmd->device->id,				   cmd->device->lun, /*alloc*/FALSE);	if (dev == NULL) {		ahd_unlock(ahd, &s);		kfree(recovery_cmd);		return (FAILED);	}	if ((scb = ahd_get_scb(ahd, AHD_NEVER_COL_IDX)) == NULL) {		ahd_unlock(ahd, &s);		kfree(recovery_cmd);		return (FAILED);	}	tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,				    cmd->device->id, &tstate);	recovery_cmd->result = CAM_REQ_INPROG << 16;	recovery_cmd->host_scribble = (char *)scb;	scb->io_ctx = recovery_cmd;	scb->platform_data->dev = dev;	scb->sg_count = 0;	ahd_set_residual(scb, 0);	ahd_set_sense_residual(scb, 0);	hscb = scb->hscb;	hscb->control = 0;	hscb->scsiid = BUILD_SCSIID(ahd, cmd);	hscb->lun = cmd->device->lun;	hscb->cdb_len = 0;	hscb->task_management = SIU_TASKMGMT_LUN_RESET;	scb->flags |= SCB_DEVICE_RESET|SCB_RECOVERY_SCB|SCB_ACTIVE;	if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {		scb->flags |= SCB_PACKETIZED;	} else {		hscb->control |= MK_MESSAGE;	}	dev->openings--;	dev->active++;	dev->commands_issued++;	LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links);	ahd_queue_scb(ahd, scb);	scb->platform_data->flags |= AHD_SCB_UP_EH_SEM;	ahd_unlock(ahd, &s);	init_timer(&timer);	timer.data = (u_long)scb;	timer.expires = jiffies + (5 * HZ);	timer.function = ahd_linux_sem_timeout;	add_timer(&timer);	printf("Recovery code sleeping\n");	down(&ahd->platform_data->eh_sem);	printf("Recovery code awake\n");	retval = SUCCESS;	if (del_timer_sync(&timer) == 0) {		printf("Timer Expired\n");		retval = FAILED;	}	ahd_lock(ahd, &s);	ahd_linux_run_complete_queue(ahd);	ahd_unlock(ahd, &s);	printf("%s: Device reset returning 0x%x\n", ahd_name(ahd), retval);	return (retval);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/73a25462100772b72a5d62fd66dff01b53018618/aic79xx_osm.c/buggy/drivers/scsi/aic7xxx/aic79xx_osm.c