From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schocher Date: Fri, 18 Dec 2015 11:24:25 +0100 Subject: [U-Boot] [Patch V3] i2c: mxc: add a condition in case the parameter is NULL In-Reply-To: <1450431481-45235-1-git-send-email-Qianyu.Gong@freescale.com> References: <1450431481-45235-1-git-send-email-Qianyu.Gong@freescale.com> Message-ID: <5673DED9.4090500@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Gong Qianyu, added Stefano Babic to cc as he is the imx maintainer. Am 18.12.2015 um 10:38 schrieb Gong Qianyu: > This could avoid executing the code that only applies to i.MX platforms. > > The bus_i2c_init() is called before relocation and will assgin value > to a static variable. If U-Boot is then still running in a flash > device, it's theoretically not allowed to write data to flash without > an erasing operation. For i.MX platforms, the U-Boot is always running > in DDR. > > Actually it causes asynchronous error when the ARM64 system error > report is enabled and the flash write protect is set. > > Signed-off-by: Gong Qianyu > --- > V3: > - Sorry..Remove an unrelated line in other file. > > drivers/i2c/mxc_i2c.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) Ok, from my side, but it would be better to switch your board(s) to support DM and get rid of this old stuff from this driver. Reviewed-by: Heiko Schocher bye, Heiko > > diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c > index fa4c82f..b2d15c9 100644 > --- a/drivers/i2c/mxc_i2c.c > +++ b/drivers/i2c/mxc_i2c.c > @@ -581,8 +581,16 @@ void bus_i2c_init(int index, int speed, int unused, > return; > } > > - mxc_i2c_buses[index].idle_bus_fn = idle_bus_fn; > - mxc_i2c_buses[index].idle_bus_data = idle_bus_data; > + /* > + * Warning: Be careful to allow the assignment to a static > + * variable here. This function could be called while U-Boot is > + * still running in flash memory. So such assignment is equal > + * to write data to flash without erasing. > + */ > + if (idle_bus_fn) > + mxc_i2c_buses[index].idle_bus_fn = idle_bus_fn; > + if (idle_bus_data) > + mxc_i2c_buses[index].idle_bus_data = idle_bus_data; > > ret = enable_i2c_clk(1, index); > if (ret < 0) { > -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany