if (scsi_request_normalize_sense(sreq, &sshdr) 
if (scsi_sense_valid(&sshdr) 
spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer,			  u8 *ptr, const int retries){	struct scsi_device *sdev = sreq->sr_device;	int len = ptr - buffer;	int j, k, r;	unsigned int pattern = 0x0000ffff;	const char spi_write_buffer[] = {		WRITE_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0	};	const char spi_read_buffer[] = {		READ_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0	};	/* set up the pattern buffer.  Doesn't matter if we spill	 * slightly beyond since that's where the read buffer is */	for (j = 0; j < len; ) {		/* fill the buffer with counting (test a) */		for ( ; j < min(len, 32); j++)			buffer[j] = j;		k = j;		/* fill the buffer with alternating words of 0x0 and		 * 0xffff (test b) */		for ( ; j < min(len, k + 32); j += 2) {			u16 *word = (u16 *)&buffer[j];						*word = (j & 0x02) ? 0x0000 : 0xffff;		}		k = j;		/* fill with crosstalk (alternating 0x5555 0xaaa)                 * (test c) */		for ( ; j < min(len, k + 32); j += 2) {			u16 *word = (u16 *)&buffer[j];			*word = (j & 0x02) ? 0x5555 : 0xaaaa;		}		k = j;		/* fill with shifting bits (test d) */		for ( ; j < min(len, k + 32); j += 4) {			u32 *word = (unsigned int *)&buffer[j];			u32 roll = (pattern & 0x80000000) ? 1 : 0;						*word = pattern;			pattern = (pattern << 1) | roll;		}		/* don't bother with random data (test e) */	}	for (r = 0; r < retries; r++) {		sreq->sr_cmd_len = 0;	/* wait_req to fill in */		sreq->sr_data_direction = DMA_TO_DEVICE;		spi_wait_req(sreq, spi_write_buffer, buffer, len);		if(sreq->sr_result || !scsi_device_online(sdev)) {			struct scsi_sense_hdr sshdr;			scsi_device_set_state(sdev, SDEV_QUIESCE);			if (scsi_request_normalize_sense(sreq, &sshdr)			    && sshdr.sense_key == ILLEGAL_REQUEST			    /* INVALID FIELD IN CDB */			    && sshdr.asc == 0x24 && sshdr.ascq == 0x00)				/* This would mean that the drive lied				 * to us about supporting an echo				 * buffer (unfortunately some Western				 * Digital drives do precisely this)				 */				return SPI_COMPARE_SKIP_TEST;			SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Write Buffer failure %x\n", sreq->sr_result);			return SPI_COMPARE_FAILURE;		}		memset(ptr, 0, len);		sreq->sr_cmd_len = 0;	/* wait_req to fill in */		sreq->sr_data_direction = DMA_FROM_DEVICE;		spi_wait_req(sreq, spi_read_buffer, ptr, len);		scsi_device_set_state(sdev, SDEV_QUIESCE);		if (memcmp(buffer, ptr, len) != 0)			return SPI_COMPARE_FAILURE;	}	return SPI_COMPARE_SUCCESS;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/33aa687db90dd8541bd5e9a762eebf880eaee767/scsi_transport_spi.c/clean/drivers/scsi/scsi_transport_spi.c