public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] i2c:mxc fix array size of i2c_data
@ 2015-01-06  6:12 Peng Fan
  2015-01-09  6:18 ` Heiko Schocher
  2015-01-09 13:33 ` [U-Boot] " Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Peng Fan @ 2015-01-06  6:12 UTC (permalink / raw)
  To: u-boot

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 <Peng.Fan@freescale.com>
---
 drivers/i2c/mxc_i2c.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

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];
-- 
1.8.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] i2c:mxc fix array size of i2c_data
  2015-01-06  6:12 [U-Boot] [PATCH] i2c:mxc fix array size of i2c_data Peng Fan
@ 2015-01-09  6:18 ` Heiko Schocher
  2015-01-09 13:33 ` [U-Boot] " Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Heiko Schocher @ 2015-01-09  6:18 UTC (permalink / raw)
  To: u-boot

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 <Peng.Fan@freescale.com>
> ---
>   drivers/i2c/mxc_i2c.c | 22 +++++++++++-----------
>   1 file changed, 11 insertions(+), 11 deletions(-)

Acked-by: Heiko Schocher <hs@denx.de>

@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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] i2c:mxc fix array size of i2c_data
  2015-01-06  6:12 [U-Boot] [PATCH] i2c:mxc fix array size of i2c_data Peng Fan
  2015-01-09  6:18 ` Heiko Schocher
@ 2015-01-09 13:33 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2015-01-09 13:33 UTC (permalink / raw)
  To: u-boot

On Tue, Jan 06, 2015 at 02:12:51PM +0800, Peng Fan wrote:

> 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 <Peng.Fan@freescale.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150109/449e9f41/attachment.pgp>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-09 13:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-06  6:12 [U-Boot] [PATCH] i2c:mxc fix array size of i2c_data Peng Fan
2015-01-09  6:18 ` Heiko Schocher
2015-01-09 13:33 ` [U-Boot] " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox