From: Sascha Hauer <s.hauer@pengutronix.de>
To: Hubert Feurstein <h.feurstein@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [RFC PATCH] spi: add at25 spi eeprom driver
Date: Mon, 20 Jun 2011 08:45:01 +0200 [thread overview]
Message-ID: <20110620064501.GL23771@pengutronix.de> (raw)
In-Reply-To: <1308211963-4384-1-git-send-email-h.feurstein@gmail.com>
Hi Hubert,
On Thu, Jun 16, 2011 at 10:12:43AM +0200, Hubert Feurstein wrote:
> obj-y += mfd/
> obj-$(CONFIG_LED) += led/
> +obj-y += misc/
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
I think we should move the driver up to drivers/eeprom and skip the
'misc'. The kernel guys like to get rid of it also.
> +
> + /* Wait for non-busy status */
> + start_time = get_time_ns();
> +
> + retries = 0;
> + do {
> +
> + sr = spi_w8r8(at25->spi, AT25_RDSR);
> + if (sr < 0 || (sr & AT25_SR_nRDY)) {
> + dev_dbg(at25->cdev.dev,
> + "rdsr --> %d (%02x)\n", sr, sr);
> + mdelay(1);
> + continue;
> + }
> + if (!(sr & AT25_SR_nRDY))
> + break;
> + } while (retries++ < 3 || !is_timeout(start_time, EE_TIMEOUT));
I don't understand this. The loop is limited by retries++ < 3. Why this
additional is_timeout? Is this the same in the kernel?
> +static int at25_init(void)
> +{
> + register_driver(&at25_driver);
> + return 0;
> +}
> +
> +device_initcall(at25_init);
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 4560259..6456897 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -75,6 +75,7 @@ struct spi_device *spi_new_device(struct spi_master *master,
> proxy->chip_select = chip->chip_select;
> proxy->max_speed_hz = chip->max_speed_hz;
> proxy->mode = chip->mode;
> + proxy->dev.platform_data = chip->platform_data;
This should be a seperate patch.
> strcpy(proxy->dev.name, chip->name);
> proxy->dev.type_data = proxy;
> status = register_device(&proxy->dev);
> @@ -194,3 +195,44 @@ int spi_sync(struct spi_device *spi, struct spi_message *message)
> return spi->master->transfer(spi, message);
> }
>
> +/**
> + * spi_write_then_read - SPI synchronous write followed by read
> + * @spi: device with which data will be exchanged
> + * @txbuf: data to be written
> + * @n_tx: size of txbuf, in bytes
> + * @rxbuf: buffer into which data will be read
> + * @n_rx: size of rxbuf, in bytes
> + * Context: can sleep
> + *
> + * This performs a half duplex MicroWire style transaction with the
> + * device, sending txbuf and then reading rxbuf. The return value
> + * is zero for success, else a negative errno status code.
> + * This call may only be used from a context that may sleep.
> + */
> +int spi_write_then_read(struct spi_device *spi,
> + const void *txbuf, unsigned n_tx,
> + void *rxbuf, unsigned n_rx)
> +{
> + int status;
> + struct spi_message message;
> + struct spi_transfer x[2];
> +
> + spi_message_init(&message);
> + memset(x, 0, sizeof x);
> + if (n_tx) {
> + x[0].len = n_tx;
> + spi_message_add_tail(&x[0], &message);
> + }
> + if (n_rx) {
> + x[1].len = n_rx;
> + spi_message_add_tail(&x[1], &message);
> + }
> +
> + x[0].tx_buf = txbuf;
> + x[1].rx_buf = rxbuf;
> +
> + /* do the i/o */
> + status = spi_sync(spi, &message);
> + return status;
> +}
> +EXPORT_SYMBOL(spi_write_then_read);
Also a seperate patch.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-06-20 6:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-16 8:12 Hubert Feurstein
2011-06-20 6:45 ` Sascha Hauer [this message]
2011-06-20 7:23 ` Hubert Feurstein
2011-06-20 7:37 ` 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=20110620064501.GL23771@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=h.feurstein@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