Fwd: [RFC PATCH 2/3] spi: add more spi transfer functions

Franck JULLIEN franck.jullien at gmail.com
Fri Jun 24 09:43:02 EDT 2011


Hi Hubert,

2011/6/24 Hubert Feurstein <h.feurstein at gmail.com>

> Hi Franck,
>
> 2011/6/23 Franck JULLIEN <franck.jullien at 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,
> >> +               const void *txbuf, unsigned n_tx,
> >
> > Could you explain me why const is used here ?
> Because this function will *not* write to the data of txbuf. With the
> const here, this is
> ensured at least at syntax level.
>

OK.


>
> [snip]
> >
> > 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 ???
> Your  transfer function has to handle this correctly:
> while(i < t->len >> 2) {
>   u32 txval = txbuf ? txbuf[i] : 0
>  u32 rxval = imx->xchg_single(imx, txval);
>  if (rxbuf)
>    rxbuf[i] = rxval;
>  i++;
> }
>

That's what I was thinking about. The code above is from imx_spi.c. I am
currently
writing an Altera spi driver that's why I was looking at this...



> 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).
>
>
I agree.


> Hope this helps.
>
> Best Regards
> Hubert
>

Thanks,
Franck.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20110624/abfdaf3e/attachment-0001.html>


More information about the barebox mailing list