mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Hubert Feurstein <h.feurstein@gmail.com>
To: Franck JULLIEN <franck.jullien@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [RFC PATCH 2/3] spi: add more spi transfer functions
Date: Fri, 24 Jun 2011 15:12:32 +0200	[thread overview]
Message-ID: <BANLkTi=-Aff5any29Fj8BwBLzehv28FweA@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=Bx41-N8=68LKxFKw5Lf8+6DW_FA@mail.gmail.com>

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,
>> +               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.

[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++;
}
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

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2011-06-24 13:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-20 21:46 [RFC PATCH 1/3] spi: add platform_data pointer to spi_board_info Hubert Feurstein
2011-06-20 21:46 ` [RFC PATCH 2/3] spi: add more spi transfer functions Hubert Feurstein
2011-06-23 19:47   ` Franck JULLIEN
2011-06-24 13:12     ` Hubert Feurstein [this message]
     [not found]       ` <BANLkTin9gmGY+CApY98wEX_qTkoAgKcU6A@mail.gmail.com>
2011-06-24 13:43         ` Fwd: " Franck JULLIEN
2011-06-20 21:46 ` [RFC PATCH 3/3] eeprom: add at25 eeprom driver Hubert Feurstein
2011-06-21 11:57 ` [RFC PATCH 1/3] spi: add platform_data pointer to spi_board_info Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTi=-Aff5any29Fj8BwBLzehv28FweA@mail.gmail.com' \
    --to=h.feurstein@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=franck.jullien@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox