From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schocher Date: Thu, 19 Feb 2009 09:00:14 +0100 Subject: [U-Boot] [PATCH] 7/12 Multiadapter/multibus I2C, drivers part 4 In-Reply-To: References: <499548C2.7060305@denx.de> <49967FAC.6090905@denx.de> <20090216221151.08966832E893@gemini.denx.de> <20090217224940.02BC6832E893@gemini.denx.de> <20090218001322.4A43C832E893@gemini.denx.de> <499BBD25.4070907@denx.de> <20090218182625.22E71832E43F@gemini.denx.de> <20090218220935.13639832E43F@gemini.denx.de> Message-ID: <499D118E.4070404@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello ksi, ksi at koi8.net wrote: > On Wed, 18 Feb 2009, Wolfgang Denk wrote: > >> Dear ksi at koi8.net, >> >> In message 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.