All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] fsl-i2c: fix writes to data segment	before relocation
Date: Mon, 21 Jul 2008 22:13:19 +0200	[thread overview]
Message-ID: <20080721201319.GA16567@game.jcrosoft.org> (raw)
In-Reply-To: <1216668383-17967-1-git-send-email-timur@freescale.com>

On 14:26 Mon 21 Jul     , Timur Tabi wrote:
> Prevent i2c_init() in fsl_i2c.c from writing to the data segment before
> relocation.  Commit d8c82db4 added the ability for i2c_init() to program the
> I2C bus speed and save the value in i2c_bus_speed[], which is a global
> variable.  It is an error to write to the data segment before relocation,
> which is what i2c_init() does when it stores the bus speed in i2c_bus_speed[].
> 
> Signed-off-by: Timur Tabi <timur@freescale.com>
> ---
> 
> Wolfgang, please apply this directly to fix the I2C bug we've been talking about.
> 
>  drivers/i2c/fsl_i2c.c |    9 +++++++--
>  1 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
> index 9f2c1ec..9d5df8a 100644
> --- a/drivers/i2c/fsl_i2c.c
> +++ b/drivers/i2c/fsl_i2c.c
> @@ -143,12 +143,15 @@ void
>  i2c_init(int speed, int slaveadd)
>  {
>  	struct fsl_i2c *dev;
> +	unsigned int temp;
>  
>  	dev = (struct fsl_i2c *) (CFG_IMMR + CFG_I2C_OFFSET);
>  
>  	writeb(0, &dev->cr);			/* stop I2C controller */
>  	udelay(5);				/* let it shutdown in peace */
> -	i2c_bus_speed[0] = set_i2c_bus_speed(dev, gd->i2c1_clk, speed);
> +	temp = set_i2c_bus_speed(dev, gd->i2c1_clk, speed);
> +	if (gd->flags & GD_FLG_RELOC)
Maybe a macro will more clear like
	if(is_relacated())
		i2c_bus_speed[0] = temp;

Best Regards,
J.

  reply	other threads:[~2008-07-21 20:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-21 19:26 [U-Boot-Users] [PATCH] fsl-i2c: fix writes to data segment before relocation Timur Tabi
2008-07-21 20:13 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2008-07-21 20:21   ` Timur Tabi
2008-07-21 20:44   ` Wolfgang Denk
2008-07-21 20:29 ` David Hawkins
2008-07-21 20:31   ` Timur Tabi
2008-07-21 20:39     ` Jerry Van Baren
2008-07-21 20:45   ` Wolfgang Denk
2008-07-29 22:10 ` Wolfgang Denk

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=20080721201319.GA16567@game.jcrosoft.org \
    --to=plagnioj@jcrosoft.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.