Commit c36ecf3abfbc20719bbc7229c9a112e2e137a400
Committed by
Tom Rini
1 parent
5ea0196164
Exists in
v2017.01-smarct4x
and in
37 other branches
i2c:mxc fix array size of i2c_data
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>
Showing 1 changed file with 11 additions and 11 deletions Side-by-side Diff
drivers/i2c/mxc_i2c.c
... | ... | @@ -402,17 +402,6 @@ |
402 | 402 | return ret; |
403 | 403 | } |
404 | 404 | |
405 | -struct i2c_parms { | |
406 | - void *base; | |
407 | - void *idle_bus_data; | |
408 | - int (*idle_bus_fn)(void *p); | |
409 | -}; | |
410 | - | |
411 | -struct sram_data { | |
412 | - unsigned curr_i2c_bus; | |
413 | - struct i2c_parms i2c_data[3]; | |
414 | -}; | |
415 | - | |
416 | 405 | static void * const i2c_bases[] = { |
417 | 406 | #if defined(CONFIG_MX25) |
418 | 407 | (void *)IMX_I2C_BASE, |
... | ... | @@ -437,6 +426,17 @@ |
437 | 426 | #else |
438 | 427 | #error "architecture not supported" |
439 | 428 | #endif |
429 | +}; | |
430 | + | |
431 | +struct i2c_parms { | |
432 | + void *base; | |
433 | + void *idle_bus_data; | |
434 | + int (*idle_bus_fn)(void *p); | |
435 | +}; | |
436 | + | |
437 | +struct sram_data { | |
438 | + unsigned curr_i2c_bus; | |
439 | + struct i2c_parms i2c_data[ARRAY_SIZE(i2c_bases)]; | |
440 | 440 | }; |
441 | 441 | |
442 | 442 | void *i2c_get_base(struct i2c_adapter *adap) |