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,13 +139,12 @@ static void spi_bit_transfer ( struct spi_bit_basher *spibit,
139 139
  * @v address		Address to read/write (<0 for no address)
140 140
  * @v data_out		TX data buffer (or NULL)
141 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 143
  * @ret rc		Return status code
144 144
  */
145 145
 static int spi_bit_rw ( struct spi_bus *bus, struct spi_device *device,
146 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 148
 	struct spi_bit_basher *spibit
150 149
 		= container_of ( bus, struct spi_bit_basher, bus );
151 150
 	struct spi_device_type *devtype = device->type;
@@ -167,8 +166,7 @@ static int spi_bit_rw ( struct spi_bus *bus, struct spi_device *device,
167 166
 	}
168 167
 
169 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 171
 	/* Deassert chip select on specified slave */
174 172
 	spi_bit_set_slave_select ( spibit, device->slave, DESELECT_SLAVE );

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

@@ -276,7 +276,7 @@ static void rtl_read_mac ( struct rtl8139_nic *rtl, uint8_t *mac_addr ) {
276 276
 	
277 277
 	DBG ( "MAC address is " );
278 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 280
 		DBG ( "%02x%02x", mac_addr[0], mac_addr[1] );
281 281
 		mac_addr += 2;
282 282
 	}

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

@@ -31,17 +31,16 @@
31 31
  * @v device		SPI device
32 32
  * @v address		Address from which to read
33 33
  * @v data		Data buffer
34
- * @v len		Length of data to read, in @b words
34
+ * @v len		Length of data buffer
35 35
  * @ret rc		Return status code
36 36
  */
37 37
 int threewire_read ( struct spi_device *device, unsigned int address,
38
-		     void *data, unsigned int len ) {
38
+		     void *data, size_t len ) {
39 39
 	struct spi_bus *bus = device->bus;
40 40
 
41 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 45
 	return bus->rw ( bus, device, THREEWIRE_READ, address,
47 46
 			 NULL, data, len );

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

@@ -118,21 +118,21 @@ struct spi_device_type {
118 118
 	 * @v device		SPI device
119 119
 	 * @v address		Address from which to read
120 120
 	 * @v data		Data buffer
121
-	 * @v len		Length of data to read, in @b words
121
+	 * @v len		Length of data buffer
122 122
 	 * @ret rc		Return status code
123 123
 	 */
124 124
 	int ( * read ) ( struct spi_device *device, unsigned int address,
125
-			 void *data, unsigned int len );
125
+			 void *data, size_t len );
126 126
 	/** Write data to device
127 127
 	 *
128 128
 	 * @v device		SPI device
129 129
 	 * @v address		Address to which to write
130 130
 	 * @v data		Data buffer
131
-	 * @v len		Length of data to write, in @b words
131
+	 * @v len		Length of data buffer
132 132
 	 * @ret rc		Return status code
133 133
 	 */
134 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,18 +192,15 @@ struct spi_bus {
192 192
 	 * @v address		Address to read/write (<0 for no address)
193 193
 	 * @v data_out		TX data buffer (or NULL)
194 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 197
 	 * This issues the specified command and optional address to
198 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 201
 	int ( * rw ) ( struct spi_bus *bus, struct spi_device *device,
205 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 206
 /** Clock phase (CPHA) mode bit

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

@@ -56,6 +56,6 @@
56 56
 /** @} */
57 57
 
58 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 61
 #endif /* _GPXE_THREEWIRE_H */

Loading…
Cancel
Save