[U-Boot] [PATCH v3] i2c: merge all i2c_reg_read() and i2c_reg_write() into inline functions

ksi at koi8.net ksi at koi8.net
Tue Dec 16 19:07:00 CET 2008


On Tue, 16 Dec 2008, Scott Wood wrote:

> On Mon, Dec 15, 2008 at 04:24:26PM -0800, ksi at koi8.net wrote:
>> Then, we could use some kind of array of I2C structures each
> containing
>> pointers to appropriate i2c-{read,write,probe,init}() functions with
> generic
>> i2c functions just calling those pointers using bus number as index
> into
>> that array.
>
> Why not just pass a pointer to the i2c device, rather than an index?

Because it is easier to change bus with i2c_set_bus() function and then use
regular i2c_{read,write,probe}() functions. We are NOT passing anything. One
global variable, bus_num or so, that is changed with i2c_set_bus() is used
as an index for any i2c_{read,write,probe}() function. Those functions are
just one line inlines calling appropriate pointers in i2c_func[bus_num]
area. This way one can still use regular e.g. i2c_write() that translates to
i2c_func[bus_num].i2c_write.

---
******************************************************************
*  KSI at home    KOI8 Net  < >  The impossible we do immediately.  *
*  Las Vegas   NV, USA   < >  Miracles require 24-hour notice.   *
******************************************************************


More information about the U-Boot mailing list