[U-Boot-Users] PATCH: Add command support for multiple I2C controllers

Ben Warren bwarren at qstreams.com
Fri May 19 16:43:30 CEST 2006


Wolfgang,

> No, because this will always be mutually exclusie. I thinkt hat,  for
> a  transition  period  and  on  sytems  that  can  afford  the memory
> footprint, both the old and the new syntac should be available at the
> same time (just  like  we  still  support  the  $(variable)  and  the
> ${variable} formats in parallel - but $(var) will be dropped RSN).
OK
> 
> > This macro (I forgot to assign a value, by the way) is only used in two
> > commands - the probing function and the one that changes buses (it moves
> > a pointer to the correct point in the list).  You'll notice that I have
> > both compile time and run time checks in place that verify that the list
> 
> Yes, but this and the fact that multiple instances of the  macro  are
> used means that we add more than needed to the memory footprint.
> 
> > is properly formed, and hopefully enough comments to show how to create
> > the list.  I'm very open to alternative suggestions, other than 'no'.
> 
> Use arrays, please.
> 
Sorry, I mis-stated this.  The list defined by the macro is only stored
in one place - the 1-D array called 'i2c_no_probes'.  Manipulation is
purely by pointers, so this isn't a memory hog.  I would much prefer to
use a 2-D array, but the C language doesn't allow the initialization of
static 2-D arrays with an arbitrary number of columns (representing
entries in the list).  I can easily define:

#define CFG_I2C_NUM_BUSES    2
#define CFG_I2C_MULTI_NOPROBES {{0x1, 0x2, 0x3}, {0xa, 0xb}}

but the following won't compile:

static uchar [CFG_I2C_NUM_BUSES][] = CFG_I2C_MULTI_NOPROBES;

I could add yet another #define, perhaps  #define CFG_I2C_MAX_NOPROBES 3

static uchar [CFG_I2C_NUM_BUSES][CFG_I2C_MAX_NOPROBES] =
CFG_I2C_MULTI_NOPROBES;

which will work, but isn't very flexible and adds yet another thing the
user must think about.  Of course, we could #define a 1-D array for each
bus, but as you can see this grows ungainly.  My approach of a single
delimited 1-D array has the advantage of being simple, and allows an
arbitrary number of controllers and no-probes in each one, while only
requiring a single #define CFG.

Sorry if this is overly verbose.

regards,
Ben







More information about the U-Boot mailing list