diff options
author | Thierry Reding <treding@nvidia.com> | 2014-08-26 17:34:00 +0200 |
---|---|---|
committer | Marcel Ziswiler <marcel.ziswiler@toradex.com> | 2014-10-11 01:08:34 +0200 |
commit | 255e0ca96f808faf560b8d4d644d6e6f75c4fe9a (patch) | |
tree | 87279983f6381fc3315a6d7012b104a2ca4f16e3 | |
parent | 2ca50f89b3b7de836d5491c16beb4e4e7f77fa60 (diff) |
i2c: Refactor adapter initialization
A subsequent patch will introduce a new API to access I2C adapters
directly rather than going through the bus number and constantly looking
up the same adapter. In order to share the adapter initialization code,
move it into a separate function and make i2c_init_bus() use it to avoid
code duplication.
Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r-- | drivers/i2c/i2c_core.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c index cca455bc9c6..f6179a16244 100644 --- a/drivers/i2c/i2c_core.c +++ b/drivers/i2c/i2c_core.c @@ -207,6 +207,18 @@ static int i2c_mux_disconnet_all(void) } #endif +static void i2c_adapter_init(struct i2c_adapter *adapter, unsigned int speed, + unsigned int slaveaddr) +{ + adapter->init(adapter, speed, slaveaddr); + + if (gd->flags & GD_FLG_RELOC) { + adapter->slaveaddr = slaveaddr; + adapter->speed = speed; + adapter->init_done = 1; + } +} + /* * i2c_init_bus(): * --------------- @@ -222,13 +234,7 @@ static void i2c_init_bus(unsigned int bus, int speed, int slaveaddr) return; adapter = i2c_get_adapter(I2C_ADAPTER(bus)); - adapter->init(adapter, speed, slaveaddr); - - if (gd->flags & GD_FLG_RELOC) { - adapter->init_done = 1; - adapter->speed = speed; - adapter->slaveaddr = slaveaddr; - } + i2c_adapter_init(adapter, speed, slaveaddr); } /* implement possible board specific board init */ |