Hi Franck,
2011/6/23 Franck JULLIEN <franck.jullien@gmail.com>:
> Hello, I have a question regarding the SPI spi_write_then_read function.[snip]
>
>> +int spi_write_then_read(struct spi_device *spi,Because this function will *not* write to the data of txbuf. With the
>> + const void *txbuf, unsigned n_tx,
>
> Could you explain me why const is used here ?
const here, this is
ensured at least at syntax level.
[snip]
>Your transfer function has to handle this correctly:
> Then we call spi_sync then master->transfer. In this last function we have:
> list_for_each_entry (t, &mesg->transfers, transfer_list) {
> const u32 *txbuf = t->tx_buf; <--- point to zero when x[1] right ?????
> u32 *rxbuf = t->rx_buf; <--- point to zero when x[0] right ?????
> int i = 0;
> while(i < t->len >> 2) {
> rxbuf[i] = imx->xchg_single(imx, txbuf[i]);
> i++;
> }
> }
> What am I missing ???
while(i < t->len >> 2) {u32 txval = txbuf ? txbuf[i] : 0
u32 rxval = imx->xchg_single(imx, txval);
if (rxbuf)
rxbuf[i] = rxval;
i++;
}
If no txbuf is available then simply transfer 0, if no rxbuf is
available then throw away the result.
BTW, I'm not sure if the above transfer-handler is able to handle 8bit
transfers correctly (because of len >> 2).
Hope this helps.
Best Regards
Hubert