public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Timur Tabi <timur@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] i2c: merge all i2c_reg_read() and i2c_reg_write() into inline functions
Date: Tue, 16 Dec 2008 09:19:01 -0600	[thread overview]
Message-ID: <4947C6E5.3070403@freescale.com> (raw)
In-Reply-To: <Pine.LNX.4.64ksi.0812151606250.22631@home-gw.koi8.net>

ksi at koi8.net wrote:

> That looks similar. But why do you want to remove i2c_set_bus_num()? I think
> it would be less work to keep it. 

Perhaps, but it would be even better to get rid of it.  IMHO, it's a kludge.  It
was a hack added to allow existing I2C routines to function while adding minimal
support for multiple buses on those platforms that needed it.

> This way you can leave 90% or so of
> existing I2C code unchanged by setting bus number to 0 at init. 

I only intend on exporting the multiple-bus versions of the I2C function if
CONFIG_I2C_MULTI_BUS is defined.

> My idea is to have global bus number variable in a single place and a single
> i2c_set_bus_num() that can be excluded for most boards with a single bus
> with #ifdef...

We already have something like that.  A global variable is inconvenient because
every time you want to access the bus, you need to do something like this:

	bus = i2c_get_bus_num();
	i2c_set_bus_num(x);
	i2c_write(...)
	i2c_set_bus_num(bus);

We need to save/restore the current bus number, because the I2C command-line has
the concept of a

> 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.

Sounds complicated.

> That would allow for unlimited number of different adapters for any board.

Ah, now this is something else entirely.  I don't think U-boot supports this at
all.  I think you're being too ambitious.  It's a noble idea, and I think U-boot
should support it, but I think we need to simplify the support for multiple
buses first.

> Initial code for initializing such an array would have to go into each and
> every $(BOARD).c board specific file.

Ugh.

-- 
Timur Tabi
Linux kernel developer at Freescale

  reply	other threads:[~2008-12-16 15:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-03 17:28 [U-Boot] [PATCH v3] i2c: merge all i2c_reg_read() and i2c_reg_write() into inline functions Timur Tabi
2008-12-06 17:49 ` Jean-Christophe PLAGNIOL-VILLARD
2008-12-15 22:47 ` Wolfgang Denk
2008-12-15 23:37   ` ksi at koi8.net
2008-12-15 23:42     ` Timur Tabi
2008-12-16  0:24       ` ksi at koi8.net
2008-12-16 15:19         ` Timur Tabi [this message]
2008-12-16 17:58           ` ksi at koi8.net
2008-12-16 18:51             ` Timur Tabi
2008-12-16 19:40               ` ksi at koi8.net
2008-12-16 20:35                 ` Jerry Van Baren
2008-12-16 20:58                 ` Wolfgang Denk
2008-12-17  3:55                   ` ksi at koi8.net
2008-12-16 20:49               ` Wolfgang Denk
2008-12-16 23:46                 ` Timur Tabi
2008-12-17  1:00                   ` ksi at koi8.net
2008-12-17  1:28                   ` Wolfgang Denk
2008-12-16 17:47         ` Scott Wood
2008-12-16 18:07           ` ksi at koi8.net

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4947C6E5.3070403@freescale.com \
    --to=timur@freescale.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox