struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt); struct scsi_device *sdev = sreq->sr_device; 
struct spi_internal *i = to_spi_internal(sdev->host->transportt); 
spi_dv_retrain(struct scsi_request *sreq, u8 *buffer, u8 *ptr,	       enum spi_compare_returns 	       (*compare_fn)(struct scsi_request *, u8 *, u8 *, int)){	struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt);	struct scsi_device *sdev = sreq->sr_device;	struct scsi_target *starget = sdev->sdev_target;	int period = 0, prevperiod = 0; 	enum spi_compare_returns retval;	for (;;) {		int newperiod;		retval = compare_fn(sreq, buffer, ptr, DV_LOOPS);		if (retval == SPI_COMPARE_SUCCESS		    || retval == SPI_COMPARE_SKIP_TEST)			break;		/* OK, retrain, fallback */		if (i->f->get_iu)			i->f->get_iu(starget);		if (i->f->get_qas)			i->f->get_qas(starget);		if (i->f->get_period)			i->f->get_period(sdev->sdev_target);		/* Here's the fallback sequence; first try turning off		 * IU, then QAS (if we can control them), then finally		 * fall down the periods */		if (i->f->set_iu && spi_iu(starget)) {			SPI_PRINTK(starget, KERN_ERR, "Domain Validation Disabing Information Units\n");			DV_SET(iu, 0);		} else if (i->f->set_qas && spi_qas(starget)) {			SPI_PRINTK(starget, KERN_ERR, "Domain Validation Disabing Quick Arbitration and Selection\n");			DV_SET(qas, 0);		} else {			newperiod = spi_period(starget);			period = newperiod > period ? newperiod : period;			if (period < 0x0d)				period++;			else				period += period >> 1;			if (unlikely(period > 0xff || period == prevperiod)) {				/* Total failure; set to async and return */				SPI_PRINTK(starget, KERN_ERR, "Domain Validation Failure, dropping back to Asynchronous\n");				DV_SET(offset, 0);				return SPI_COMPARE_FAILURE;			}			SPI_PRINTK(starget, KERN_ERR, "Domain Validation detected failure, dropping back\n");			DV_SET(period, period);			prevperiod = period;		}	}	return retval;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/33aa687db90dd8541bd5e9a762eebf880eaee767/scsi_transport_spi.c/clean/drivers/scsi/scsi_transport_spi.c