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

Heiko Schocher hs at denx.de
Thu Feb 19 09:00:14 CET 2009


Hello ksi,

ksi at koi8.net wrote:
> On Wed, 18 Feb 2009, Wolfgang Denk wrote:
> 
>> Dear ksi at koi8.net,
>>
>> In message <Pine.LNX.4.64ksi.0902181112400.5002 at home-gw.koi8.net> you wrote:
>>>> 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.
>>> It is _NOT_ the same driver. Every bitbaged I2C driver is _DIFFERENT_. Only
>>> the _NAME_ is the same.
>> This is one way to implement it, but not the only one.
>>
>> Just to give  an  example  of  a  different  implementation  (without
>> claiming  that that would be a better one): we could provide an array
>> of functions (instead of macros) for each such adapter, so  we  could
>> use  just  a single instance of the driver which takes the address of
>> the respective array as argument.
> 
> Yes, it is possible, but it is not the best approach. Most of those macros
> translate in 2 to 3 words. If you use functions you should add at very least
> 2 more words to it, one for a function call another for a function return.
> That is without array, just directly linked functions. If you are to use an
> array it adds another 2 words -- one for the array element (the pointer)
> itself and another one for the pointer to that array in i2c function code.
> 
> Linux uses functions for that but they are _INLINE_ ones in headers included
> into the driver file i.e. they are essentially macros.



More information about the U-Boot mailing list