[U-Boot] [PATCH] 7/12 Multiadapter/multibus I2C, drivers part 4

Wolfgang Denk wd at denx.de
Wed Feb 18 19:26:25 CET 2009


Dear ksi at koi8.net,

In message <Pine.LNX.4.64ksi.0902180945100.5002 at home-gw.koi8.net> you wrote:
> 
> OK, for bitbang driver it is just a source file size reduction. We can
> simply duplicate (triplicate etc.) that file for more than one adapter. What
> I did makes CPP make that duplication instead of us. But I can simply do it
> manually. It will make soft_i2c.c 4 times bigger (for 4 adapters) and the
> resulting object code will remain exactly the same, byte-to-byte.
> 
> The soft_i2c.c source file makes ONE adapter. If we want 2 adapters we
> should have 2 such files. If we want 4 adapters there should be 4 such
> files. It is that simple.

Duplicating the source code (and thus the object code, too) to create
additional instances of basicly the same driver seems to be the wrong
approach to me.

It doesn't scale well, to say the least.

> For the functions that can be parameterized I'm adding a simple wrapper
> function that simply passes additional argument to that parameterizable
> function and calls it. That is in no way worse, or bigger, or more complex
> than accessing some pointer, then getting adapter number, then branching to
> the appropriate function. The wrapper is simpler and smaller. Codewise it is
> even smaller if all arguments fit into registers because when you are
> preparing that actual function call from a wrapper function ALL arguments
> are already loaded into appropriate registers; you only have to load one
> additional register with an immediate constant (channel number) and perform
> a branch.

Is this theory or did you perform code size measurements?

> Look what I do:
> 
> === Cut ===
> static int _i2c_probe(chip, adap_no)
> {
> ...
> }
> 
> static int xx_i2c_probe1(chip)
> {
> 	return _i2c_probe(chip, 0);
> }
> 
> static int xx_i2c_probe2(chip)
> {
> 	return _i2c_probe(chip, 1);
> }
> === Cut ===

Looks like overhead to me.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You Don't Have To Be 'Damned' To Work Here, But It Helps!!!
                                             - Terry Pratchett, _Eric_


More information about the U-Boot mailing list