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 09:37:15 +0200 [thread overview]
Message-ID: <20110620073715.GR23771@pengutronix.de> (raw)
In-Reply-To: <BANLkTi=2s_PWjLeNNEaOigRWfKg7JmYMtg@mail.gmail.com>
On Mon, Jun 20, 2011 at 09:23:40AM +0200, Hubert Feurstein wrote:
> Hi Sascha,
>
> 2011/6/20 Sascha Hauer <s.hauer@pengutronix.de>:
> > 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.
> >
> OK
>
> >> +
> >> + /* 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);
We can remove this mdelay. In the kernel it makes sense to use msleep to
give the cpu a chance to sleep. In barebox we are polling anyway, so we
can better poll the status register instead of the timer register. This
gives us the chance to bail out here after 1.1ms instead of 1, 2, ...
> >> + 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?
> >
> Hmm, I don't know why we have both here. I simply ported the kernel code.
Looking at it again it seems like 'poll for EE_TIMEOUT ms but at least
three times'. I think we can skip the retries and just poll for
EE_TIMEOUT ms. The most important thing about timeouts is that we bail
out after reasonable time to give the user a chance to continue without
this driver and to give him a clue where it hangs. The exact amount
of time we poll is not really important.
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
prev parent reply other threads:[~2011-06-20 7:37 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
2011-06-20 7:23 ` Hubert Feurstein
2011-06-20 7:37 ` Sascha Hauer [this message]
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=20110620073715.GR23771@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