From: Ismael Luceno Cortes <ismael.luceno@silicon-gears.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 6/6] i2c: rcar_i2c: Move FSDA check to rcar_i2c_recover
Date: Tue, 5 Mar 2019 10:03:54 +0000 [thread overview]
Message-ID: <20190305100354.GB9933@kiki> (raw)
In-Reply-To: <3d006531-f46f-8d43-6ec4-b3bc4eabba29@gmail.com>
On 04/Mar/2019 20:47, Marek Vasut wrote:
> On 3/4/19 3:19 PM, Ismael Luceno Cortes wrote:
>
> Why is this change needed ? A commit message explaining it would help a lot.
It's cosmetic. Any call to the recover function would need to do the
same check afterwards, so it' sensible to make it part of the function.
> > Signed-off-by: Ismael Luceno <ismael.luceno@silicon-gears.com>
> > ---
> > drivers/i2c/rcar_i2c.c | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c
> > index 5e04b68d95..b829e8b20d 100644
> > --- a/drivers/i2c/rcar_i2c.c
> > +++ b/drivers/i2c/rcar_i2c.c
> > @@ -68,7 +68,7 @@ static int rcar_i2c_finish(struct udevice *dev)
> > return ret;
> > }
> >
> > -static void rcar_i2c_recover(struct udevice *dev)
> > +static int rcar_i2c_recover(struct udevice *dev)
> > {
> > struct rcar_i2c_priv *priv = dev_get_priv(dev);
> > u32 mcr = RCAR_I2C_ICMCR_MDBS | RCAR_I2C_ICMCR_OBPC;
> > @@ -93,6 +93,9 @@ static void rcar_i2c_recover(struct udevice *dev)
> > udelay(5);
> > writel(mcra | RCAR_I2C_ICMCR_FSCL, priv->base + RCAR_I2C_ICMCR);
> > udelay(5);
> > +
> > + u32 val = readl(priv->base + RCAR_I2C_ICMSR);
> > + return val & RCAR_I2C_ICMCR_FSDA;
>
> Declare all your variables at the beginning of the function, I believe
> the compiler would even complain about this.
The default mode is -std=gnu11 since GCC 5, and the Makefile defines
CSTD_FLAG to that too.
> > }
> >
> > static int rcar_i2c_set_addr(struct udevice *dev, u8 chip, u8 read)
> > @@ -108,12 +111,11 @@ static int rcar_i2c_set_addr(struct udevice *dev, u8 chip, u8 read)
> > writel(0, priv->base + RCAR_I2C_ICMSR);
> > writel(priv->icccr, priv->base + RCAR_I2C_ICCCR);
> >
> > + /* Wait for the bus */
> > ret = wait_for_bit_le32(priv->base + RCAR_I2C_ICMCR,
> > RCAR_I2C_ICMCR_FSDA, false, 2, true);
> > if (ret) {
> > - rcar_i2c_recover(dev);
> > - val = readl(priv->base + RCAR_I2C_ICMSR);
> > - if (val & RCAR_I2C_ICMCR_FSDA) {
> > + if (rcar_i2c_recover(dev)) {
> > dev_err(dev, "Bus busy, aborting\n");
> > return ret;
> > }
next prev parent reply other threads:[~2019-03-05 10:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-04 14:19 [U-Boot] [PATCH 1/6] i2c: rcar_i2c: Fix u32 cast warnings Ismael Luceno Cortes
2019-03-04 14:19 ` [U-Boot] [PATCH 2/6] i2c: rcar_i2c: Add comments about registers & values Ismael Luceno Cortes
2019-03-04 14:19 ` [U-Boot] [PATCH 3/6] i2c: rcar_i2c: Fix sending of slave addresses Ismael Luceno Cortes
2019-03-04 14:19 ` [U-Boot] [PATCH 4/6] i2c: rcar_i2c: Don't mask errors with EREMOTEIO at rcar_i2c_xfer Ismael Luceno Cortes
2019-03-04 14:19 ` [U-Boot] [PATCH 5/6] i2c: rcar_i2c: Set the slave address from rcar_i2c_xfer Ismael Luceno Cortes
2019-03-04 19:46 ` Marek Vasut
2019-03-05 10:46 ` Ismael Luceno Cortes
2019-03-05 10:55 ` Marek Vasut
2019-03-04 14:19 ` [U-Boot] [PATCH 6/6] i2c: rcar_i2c: Move FSDA check to rcar_i2c_recover Ismael Luceno Cortes
2019-03-04 19:47 ` Marek Vasut
2019-03-05 10:03 ` Ismael Luceno Cortes [this message]
2019-03-05 10:56 ` Marek Vasut
2019-03-04 19:45 ` [U-Boot] [PATCH 1/6] i2c: rcar_i2c: Fix u32 cast warnings Marek Vasut
2019-03-05 10:23 ` Ismael Luceno Cortes
2019-03-05 10:57 ` Marek Vasut
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=20190305100354.GB9933@kiki \
--to=ismael.luceno@silicon-gears.com \
--cc=u-boot@lists.denx.de \
/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