From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] i2c, core: optimze i2c_set_bus_num()
Date: Fri, 04 Oct 2013 12:41:43 +0200 [thread overview]
Message-ID: <20131004124143.16541e06@amdc308.digital.local> (raw)
In-Reply-To: <524E8378.9070500@denx.de>
Hi Heiko,
> Hello Lukasz,
>
> Am 04.10.2013 10:42, schrieb Lukasz Majewski:
> > Hi Heiko,
> >
> >> check first, if we are on the bus, we want to enable. If so,
> >> return immediately, do not calc max adapter number, nor check
> >> other things.
> >>
> >> Signed-off-by: Heiko Schocher<hs@denx.de>
> >> Cc: Lukasz Majewski<l.majewski@samsung.com>
> >> ---
> >> drivers/i2c/i2c_core.c | 18 ++++++++++--------
> >> 1 file changed, 10 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
> >> index d1072e8..170423a 100644
> >> --- a/drivers/i2c/i2c_core.c
> >> +++ b/drivers/i2c/i2c_core.c
> >> @@ -278,20 +278,22 @@ unsigned int i2c_get_bus_num(void)
> >> */
> >> int i2c_set_bus_num(unsigned int bus)
> >> {
> >> - int max = ll_entry_count(struct i2c_adapter, i2c);
> >> + int max;
> >> +
> >> + if ((bus == I2C_BUS)&& (I2C_ADAP->init_done> 0))
> >> + return 0;
> >>
> >> - if (I2C_ADAPTER(bus)>= max) {
> >> - printf("Error, wrong i2c adapter %d max %d
> >> possible\n",
> >> - I2C_ADAPTER(bus), max);
> >> - return -2;
> >> - }
> >> #ifndef CONFIG_SYS_I2C_DIRECT_BUS
> >> if (bus>= CONFIG_SYS_NUM_I2C_BUSES)
> >> return -1;
> >> #endif
> >>
> >> - if ((bus == I2C_BUS)&& (I2C_ADAP->init_done> 0))
> >> - return 0;
> >> + max = ll_entry_count(struct i2c_adapter, i2c);
> >> + if (I2C_ADAPTER(bus)>= max) {
> >> + printf("Error, wrong i2c adapter %d max %d
> >> possible\n",
> >
> > Since you are the maintainer of the i2c code, you will decide if
> > those changes shall be applied (they are really cosmetic) :-).
>
> Exactly for this reason a "Acked-by" would not disturb me ;-)
So as requested :-) :
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
>
> > My suggestion: printf -> error() macro @ common.h
>
> Yep ... but this should be a seperate patch.
>
> >> + I2C_ADAPTER(bus), max);
> >> + return -2;
> >
> > I've noticed that i2c_core uses -1/-2 return values for errors
> > globaly.
> >
> > So for a new code we could start using defines from errno.h (-2 ->
> > -ENODEV) ?
>
> Yes, good point!
>
> bye,
> Heiko
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
next prev parent reply other threads:[~2013-10-04 10:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-04 5:36 [U-Boot] [PATCH] i2c, core: optimze i2c_set_bus_num() Heiko Schocher
2013-10-04 8:42 ` Lukasz Majewski
2013-10-04 8:59 ` Heiko Schocher
2013-10-04 10:41 ` Lukasz Majewski [this message]
2013-10-17 6:24 ` Heiko Schocher
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=20131004124143.16541e06@amdc308.digital.local \
--to=l.majewski@samsung.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