Browse Source

Changed length parameter in SPI methods to be a byte length, rather than

a word length.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
dc06c895fc

+ 3
- 5
src/drivers/bitbash/spi_bit.c View File

139
  * @v address		Address to read/write (<0 for no address)
139
  * @v address		Address to read/write (<0 for no address)
140
  * @v data_out		TX data buffer (or NULL)
140
  * @v data_out		TX data buffer (or NULL)
141
  * @v data_in		RX data buffer (or NULL)
141
  * @v data_in		RX data buffer (or NULL)
142
- * @v len		Length of transfer (in @b words)
142
+ * @v len		Length of transfer
143
  * @ret rc		Return status code
143
  * @ret rc		Return status code
144
  */
144
  */
145
 static int spi_bit_rw ( struct spi_bus *bus, struct spi_device *device,
145
 static int spi_bit_rw ( struct spi_bus *bus, struct spi_device *device,
146
 			unsigned int command, int address,
146
 			unsigned int command, int address,
147
-			const void *data_out, void *data_in,
148
-			unsigned int len ) {
147
+			const void *data_out, void *data_in, size_t len ) {
149
 	struct spi_bit_basher *spibit
148
 	struct spi_bit_basher *spibit
150
 		= container_of ( bus, struct spi_bit_basher, bus );
149
 		= container_of ( bus, struct spi_bit_basher, bus );
151
 	struct spi_device_type *devtype = device->type;
150
 	struct spi_device_type *devtype = device->type;
167
 	}
166
 	}
168
 
167
 
169
 	/* Transmit/receive data */
168
 	/* Transmit/receive data */
170
-	spi_bit_transfer ( spibit, data_out, data_in,
171
-			   ( len * devtype->word_len ) );
169
+	spi_bit_transfer ( spibit, data_out, data_in, ( len * 8 ) );
172
 
170
 
173
 	/* Deassert chip select on specified slave */
171
 	/* Deassert chip select on specified slave */
174
 	spi_bit_set_slave_select ( spibit, device->slave, DESELECT_SLAVE );
172
 	spi_bit_set_slave_select ( spibit, device->slave, DESELECT_SLAVE );

+ 1
- 1
src/drivers/net/rtl8139.c View File

276
 	
276
 	
277
 	DBG ( "MAC address is " );
277
 	DBG ( "MAC address is " );
278
 	for ( i = EE_MAC ; i < ( EE_MAC + ( ETH_ALEN / 2 ) ) ; i++ ) {
278
 	for ( i = EE_MAC ; i < ( EE_MAC + ( ETH_ALEN / 2 ) ) ; i++ ) {
279
-		device->type->read ( device, i, mac_addr, 1 );
279
+		device->type->read ( device, i, mac_addr, 2 );
280
 		DBG ( "%02x%02x", mac_addr[0], mac_addr[1] );
280
 		DBG ( "%02x%02x", mac_addr[0], mac_addr[1] );
281
 		mac_addr += 2;
281
 		mac_addr += 2;
282
 	}
282
 	}

+ 3
- 4
src/drivers/nvs/threewire.c View File

31
  * @v device		SPI device
31
  * @v device		SPI device
32
  * @v address		Address from which to read
32
  * @v address		Address from which to read
33
  * @v data		Data buffer
33
  * @v data		Data buffer
34
- * @v len		Length of data to read, in @b words
34
+ * @v len		Length of data buffer
35
  * @ret rc		Return status code
35
  * @ret rc		Return status code
36
  */
36
  */
37
 int threewire_read ( struct spi_device *device, unsigned int address,
37
 int threewire_read ( struct spi_device *device, unsigned int address,
38
-		     void *data, unsigned int len ) {
38
+		     void *data, size_t len ) {
39
 	struct spi_bus *bus = device->bus;
39
 	struct spi_bus *bus = device->bus;
40
 
40
 
41
 	assert ( bus->mode == SPI_MODE_THREEWIRE );
41
 	assert ( bus->mode == SPI_MODE_THREEWIRE );
42
 
42
 
43
-	DBG ( "3wire %p reading words [%04x,%04x)\n", device,
44
-	      address, ( address + len ) );
43
+	DBG ( "3wire %p reading %d bytes at %04x\n", device, len, address );
45
 
44
 
46
 	return bus->rw ( bus, device, THREEWIRE_READ, address,
45
 	return bus->rw ( bus, device, THREEWIRE_READ, address,
47
 			 NULL, data, len );
46
 			 NULL, data, len );

+ 7
- 10
src/include/gpxe/spi.h View File

118
 	 * @v device		SPI device
118
 	 * @v device		SPI device
119
 	 * @v address		Address from which to read
119
 	 * @v address		Address from which to read
120
 	 * @v data		Data buffer
120
 	 * @v data		Data buffer
121
-	 * @v len		Length of data to read, in @b words
121
+	 * @v len		Length of data buffer
122
 	 * @ret rc		Return status code
122
 	 * @ret rc		Return status code
123
 	 */
123
 	 */
124
 	int ( * read ) ( struct spi_device *device, unsigned int address,
124
 	int ( * read ) ( struct spi_device *device, unsigned int address,
125
-			 void *data, unsigned int len );
125
+			 void *data, size_t len );
126
 	/** Write data to device
126
 	/** Write data to device
127
 	 *
127
 	 *
128
 	 * @v device		SPI device
128
 	 * @v device		SPI device
129
 	 * @v address		Address to which to write
129
 	 * @v address		Address to which to write
130
 	 * @v data		Data buffer
130
 	 * @v data		Data buffer
131
-	 * @v len		Length of data to write, in @b words
131
+	 * @v len		Length of data buffer
132
 	 * @ret rc		Return status code
132
 	 * @ret rc		Return status code
133
 	 */
133
 	 */
134
 	int ( * write ) ( struct spi_device *device, unsigned int address,
134
 	int ( * write ) ( struct spi_device *device, unsigned int address,
135
-			  const void *data, unsigned int len );
135
+			  const void *data, size_t len );
136
 };
136
 };
137
 
137
 
138
 /**
138
 /**
192
 	 * @v address		Address to read/write (<0 for no address)
192
 	 * @v address		Address to read/write (<0 for no address)
193
 	 * @v data_out		TX data buffer (or NULL)
193
 	 * @v data_out		TX data buffer (or NULL)
194
 	 * @v data_in		RX data buffer (or NULL)
194
 	 * @v data_in		RX data buffer (or NULL)
195
-	 * @v len		Length of transfer (in @b words)
195
+	 * @v len		Length of data buffer(s)
196
 	 *
196
 	 *
197
 	 * This issues the specified command and optional address to
197
 	 * This issues the specified command and optional address to
198
 	 * the SPI device, then reads and/or writes data to/from the
198
 	 * the SPI device, then reads and/or writes data to/from the
199
-	 * data buffers.  Note that the transfer length is measured in
200
-	 * words, not in bytes.  Some SPI devices have 16-bit word
201
-	 * lengths; take care with these devices not to accidentally
202
-	 * read or write twice as much data as intended.
199
+	 * data buffers.
203
 	 */
200
 	 */
204
 	int ( * rw ) ( struct spi_bus *bus, struct spi_device *device,
201
 	int ( * rw ) ( struct spi_bus *bus, struct spi_device *device,
205
 		       unsigned int command, int address,
202
 		       unsigned int command, int address,
206
-		       const void *data_out, void *data_in, unsigned int len );
203
+		       const void *data_out, void *data_in, size_t len );
207
 };
204
 };
208
 
205
 
209
 /** Clock phase (CPHA) mode bit
206
 /** Clock phase (CPHA) mode bit

+ 1
- 1
src/include/gpxe/threewire.h View File

56
 /** @} */
56
 /** @} */
57
 
57
 
58
 extern int threewire_read ( struct spi_device *device, unsigned int address,
58
 extern int threewire_read ( struct spi_device *device, unsigned int address,
59
-			    void *data, unsigned int len );
59
+			    void *data, size_t len );
60
 
60
 
61
 #endif /* _GPXE_THREEWIRE_H */
61
 #endif /* _GPXE_THREEWIRE_H */

Loading…
Cancel
Save