From: Kim Phillips Date: Mon, 23 Feb 2009 16:35:48 -0600 Subject: [U-Boot] [PATCH 4/9 v3] 83xx, i2c: add mux support for fsl_i2c In-Reply-To: <499D87A9.3060004@denx.de> References: <499D87A9.3060004@denx.de> Message-ID: <20090223163548.7bcc21b6.kim.phillips@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thu, 19 Feb 2009 17:24:09 +0100 Heiko Schocher wrote: > @@ -369,6 +370,23 @@ i2c_probe(uchar chip) > > int i2c_set_bus_num(unsigned int bus) > { > +#if defined(CONFIG_I2C_MUX) > + if (bus < CONFIG_SYS_MAX_I2C_BUS) { > + i2c_bus_num = bus; > + } else { [1] > + int ret; > + > + ret = i2x_mux_select_mux(bus); > + if (ret == 0) { > + /* with CONFIG_I2C_MUX only I2C Controller 1 > + * is usable > + */ > + i2c_bus_num = 0; > + i2c_bus_num_mux = bus; > + } else > + return ret; > + } how about ret = i2x_... if (ret) return ret; /* with... > +#else > #ifdef CONFIG_SYS_I2C2_OFFSET > if (bus > 1) { > #else > @@ -378,7 +396,7 @@ int i2c_set_bus_num(unsigned int bus) > } > > i2c_bus_num = bus; > - > +#endif reuse code and moved the ifdef up, then [1] would just be: if (bus >= CONFIG_SYS_MAX_I2C_BUS) { > return 0; > } > > @@ -396,7 +414,11 @@ int i2c_set_bus_speed(unsigned int speed) > > unsigned int i2c_get_bus_num(void) > { > +#if defined(CONFIG_I2C_MUX) > + return i2c_bus_num_mux; > +#else > return i2c_bus_num; > +#endif > } I don't get this mux variant - why aren't we reusing i2c_bus_num in the mux case? Kim