FreeBSD/sys/dev/cxgb/common/cxgb_t3_hw.c
/**
 *	t3_read_flash - read words from serial flash
 *	@adapter: the adapter
 *	@addr: the start address for the read
 *	@nwords: how many 32-bit words to read
 *	@data: where to store the read data
 *	@byte_oriented: whether to store data as bytes or as words
 *
 *	Read the specified number of 32-bit words from the serial flash.
 *	If @byte_oriented is set the read data is stored as a byte array
 *	(i.e., big-endian), otherwise as 32-bit words in the platform's
 *	natural endianness.
 */


Read the specified number of 32-bit words from the serial flash.
If @byte_oriented is set the read data is stored as a byte array
, otherwise as 32-bit words in the platform's
natural endianness.
Read the specified number of 32 - bit words from the serial flash . If @byte_oriented is set the read data is stored as a byte array otherwise as 32 - bit words in the platform ' s natural endianness .
int t3_read_flash(adapter_t *adapter, unsigned int addr, unsigned int nwords,
		  u32 *data, int byte_oriented)
{
	int ret;
	if (addr + nwords * sizeof(u32) > SF_SIZE || (addr & 3))
		return -EINVAL;
	addr = swab32(addr) | SF_RD_DATA_FAST;
	if ((ret = sf1_write(adapter, 4, 1, addr)) != 0 ||
	    (ret = sf1_read(adapter, 1, 1, data)) != 0)
		return ret;
	for ( ; nwords; nwords--, data++) {
		ret = sf1_read(adapter, 4, nwords > 1, data);
		if (ret)
			return ret;
		if (byte_oriented)
			*data = htonl(*data);
	}
	return 0;
}
int t3_read_flash ( adapter_t * adapter , unsigned int addr , unsigned int nwords , u32 * data , int byte_oriented ) { int ret ; if ( addr + nwords * sizeof ( u32 ) > SF_SIZE || ( addr & 3 ) ) return - EINVAL ; addr = swab32 ( addr ) | SF_RD_DATA_FAST ; if ( ( ret = sf1_write ( adapter , 4 , 1 , addr ) ) != 0 || ( ret = sf1_read ( adapter , 1 , 1 , data ) ) != 0 ) return ret ; for ( ; nwords ; nwords -- , data ++ ) { ret = sf1_read ( adapter , 4 , nwords > 1 , data ) ; if ( ret ) return ret ; if ( byte_oriented ) * data = htonl ( * data ) ; } return 0 ; }
t3_read_flash - read words from serial flash
      @adapter: the adapter
      @addr: the start address for the read
      @nwords: how many 32-bit words to read
      @data: where to store the read data
      @byte_oriented: whether to store data as bytes or as words
t3_read_flash - read words from serial flash @adapter : the adapter @addr : the start address for the read @nwords : how many 32 - bit words to read @data : where to store the read data @byte_oriented : whether to store data as bytes or as words