diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2009-05-22 15:19:40 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-06-03 14:05:08 -0400 |
commit | f488b72de5bb2f380c157135922bac3ca1648564 (patch) | |
tree | 768c233de807f1f0026cf17368e3feb11671d066 /drivers/net/wireless | |
parent | 55aa4e0f16aa55e4b8cbe40b11e09cf029848f02 (diff) |
net/libertas: make SPI interface big endian aware
The comment (which I remove) says that the translation is done SPI routines.
IMHO this can't work because the SPI driver does not know whether the incomming
bytes are part of the registers/bytes which need to be flipped or part of
packet data which has to remain untouched.
While adding le helpers I also removed spu_write_u32() which has no users.
Tested-by: Andrey Yurovsky <andrey@cozybit.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/libertas/if_spi.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c index 5fa55fe1f860..ea23c5de1420 100644 --- a/drivers/net/wireless/libertas/if_spi.c +++ b/drivers/net/wireless/libertas/if_spi.c | |||
@@ -119,9 +119,6 @@ static struct chip_ident chip_id_to_device_name[] = { | |||
119 | * First we have to put a SPU register name on the bus. Then we can | 119 | * First we have to put a SPU register name on the bus. Then we can |
120 | * either read from or write to that register. | 120 | * either read from or write to that register. |
121 | * | 121 | * |
122 | * For 16-bit transactions, byte order on the bus is big-endian. | ||
123 | * We don't have to worry about that here, though. | ||
124 | * The translation takes place in the SPI routines. | ||
125 | */ | 122 | */ |
126 | 123 | ||
127 | static void spu_transaction_init(struct if_spi_card *card) | 124 | static void spu_transaction_init(struct if_spi_card *card) |
@@ -147,7 +144,7 @@ static void spu_transaction_finish(struct if_spi_card *card) | |||
147 | static int spu_write(struct if_spi_card *card, u16 reg, const u8 *buf, int len) | 144 | static int spu_write(struct if_spi_card *card, u16 reg, const u8 *buf, int len) |
148 | { | 145 | { |
149 | int err = 0; | 146 | int err = 0; |
150 | u16 reg_out = reg | IF_SPI_WRITE_OPERATION_MASK; | 147 | u16 reg_out = cpu_to_le16(reg | IF_SPI_WRITE_OPERATION_MASK); |
151 | 148 | ||
152 | /* You must give an even number of bytes to the SPU, even if it | 149 | /* You must give an even number of bytes to the SPU, even if it |
153 | * doesn't care about the last one. */ | 150 | * doesn't care about the last one. */ |
@@ -169,16 +166,10 @@ out: | |||
169 | 166 | ||
170 | static inline int spu_write_u16(struct if_spi_card *card, u16 reg, u16 val) | 167 | static inline int spu_write_u16(struct if_spi_card *card, u16 reg, u16 val) |
171 | { | 168 | { |
172 | return spu_write(card, reg, (u8 *)&val, sizeof(u16)); | 169 | u16 buff; |
173 | } | ||
174 | 170 | ||
175 | static inline int spu_write_u32(struct if_spi_card *card, u16 reg, u32 val) | 171 | buff = cpu_to_le16(val); |
176 | { | 172 | return spu_write(card, reg, (u8 *)&buff, sizeof(u16)); |
177 | /* The lower 16 bits are written first. */ | ||
178 | u16 out[2]; | ||
179 | out[0] = val & 0xffff; | ||
180 | out[1] = (val & 0xffff0000) >> 16; | ||
181 | return spu_write(card, reg, (u8 *)&out, sizeof(u32)); | ||
182 | } | 173 | } |
183 | 174 | ||
184 | static inline int spu_reg_is_port_reg(u16 reg) | 175 | static inline int spu_reg_is_port_reg(u16 reg) |
@@ -198,7 +189,7 @@ static int spu_read(struct if_spi_card *card, u16 reg, u8 *buf, int len) | |||
198 | unsigned int i, delay; | 189 | unsigned int i, delay; |
199 | int err = 0; | 190 | int err = 0; |
200 | u16 zero = 0; | 191 | u16 zero = 0; |
201 | u16 reg_out = reg | IF_SPI_READ_OPERATION_MASK; | 192 | u16 reg_out = cpu_to_le16(reg | IF_SPI_READ_OPERATION_MASK); |
202 | 193 | ||
203 | /* You must take an even number of bytes from the SPU, even if you | 194 | /* You must take an even number of bytes from the SPU, even if you |
204 | * don't care about the last one. */ | 195 | * don't care about the last one. */ |
@@ -236,18 +227,25 @@ out: | |||
236 | /* Read 16 bits from an SPI register */ | 227 | /* Read 16 bits from an SPI register */ |
237 | static inline int spu_read_u16(struct if_spi_card *card, u16 reg, u16 *val) | 228 | static inline int spu_read_u16(struct if_spi_card *card, u16 reg, u16 *val) |
238 | { | 229 | { |
239 | return spu_read(card, reg, (u8 *)val, sizeof(u16)); | 230 | u16 buf; |
231 | int ret; | ||
232 | |||
233 | ret = spu_read(card, reg, (u8 *)&buf, sizeof(buf)); | ||
234 | if (ret == 0) | ||
235 | *val = le16_to_cpup(&buf); | ||
236 | return ret; | ||
240 | } | 237 | } |
241 | 238 | ||
242 | /* Read 32 bits from an SPI register. | 239 | /* Read 32 bits from an SPI register. |
243 | * The low 16 bits are read first. */ | 240 | * The low 16 bits are read first. */ |
244 | static int spu_read_u32(struct if_spi_card *card, u16 reg, u32 *val) | 241 | static int spu_read_u32(struct if_spi_card *card, u16 reg, u32 *val) |
245 | { | 242 | { |
246 | u16 buf[2]; | 243 | u32 buf; |
247 | int err; | 244 | int err; |
248 | err = spu_read(card, reg, (u8 *)buf, sizeof(u32)); | 245 | |
246 | err = spu_read(card, reg, (u8 *)&buf, sizeof(buf)); | ||
249 | if (!err) | 247 | if (!err) |
250 | *val = buf[0] | (buf[1] << 16); | 248 | *val = le32_to_cpup(&buf); |
251 | return err; | 249 | return err; |
252 | } | 250 | } |
253 | 251 | ||