From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schocher Date: Fri, 09 Jan 2015 07:18:21 +0100 Subject: [U-Boot] [PATCH] i2c:mxc fix array size of i2c_data In-Reply-To: <1420524771-28736-1-git-send-email-Peng.Fan@freescale.com> References: <1420524771-28736-1-git-send-email-Peng.Fan@freescale.com> Message-ID: <54AF72AD.9000403@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 Peng Fan, Am 06.01.2015 07:12, schrieb Peng Fan: > We should not hardcode array size of i2c_data to 3. To CONFIG_FSL_LSCH3, > there are 4 i2c interface, but not 3. So the size of i2c_data array should > be calculated using "ARRAY_SIZE(i2c_bases)". > > To avoid compile error, move i2c_bases before sram_data structure which > contains i2c_data array. > > Signed-off-by: Peng Fan > --- > drivers/i2c/mxc_i2c.c | 22 +++++++++++----------- > 1 file changed, 11 insertions(+), 11 deletions(-) Acked-by: Heiko Schocher @Stefano: Would you pick up this patch, or should I? bye, Heiko > > diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c > index 021b2fe..fc5ee35 100644 > --- a/drivers/i2c/mxc_i2c.c > +++ b/drivers/i2c/mxc_i2c.c > @@ -402,17 +402,6 @@ int bus_i2c_write(void *base, uchar chip, uint addr, int alen, > return ret; > } > > -struct i2c_parms { > - void *base; > - void *idle_bus_data; > - int (*idle_bus_fn)(void *p); > -}; > - > -struct sram_data { > - unsigned curr_i2c_bus; > - struct i2c_parms i2c_data[3]; > -}; > - > static void * const i2c_bases[] = { > #if defined(CONFIG_MX25) > (void *)IMX_I2C_BASE, > @@ -439,6 +428,17 @@ static void * const i2c_bases[] = { > #endif > }; > > +struct i2c_parms { > + void *base; > + void *idle_bus_data; > + int (*idle_bus_fn)(void *p); > +}; > + > +struct sram_data { > + unsigned curr_i2c_bus; > + struct i2c_parms i2c_data[ARRAY_SIZE(i2c_bases)]; > +}; > + > void *i2c_get_base(struct i2c_adapter *adap) > { > return i2c_bases[adap->hwadapnr]; > -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany