From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Michael Lawnick <ml.lawnick-Mmb7MZpHnFY@public.gmane.org>
Cc: Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH v2 1/2] i2c: Multiplexed I2C bus core support
Date: Tue, 15 Jun 2010 11:00:18 +0200 [thread overview]
Message-ID: <20100615110018.3260a511@hyperion.delvare> (raw)
In-Reply-To: <4C173F61.8000007-Mmb7MZpHnFY@public.gmane.org>
Hi Michael,
On Tue, 15 Jun 2010 10:52:49 +0200, Michael Lawnick wrote:
> Hi Jean,
>
> Jean Delvare said the following:
> ...
> >> if (adapter->algo->smbus_xfer) {
> >> - rt_mutex_lock(&adapter->bus_lock);
> >> + i2c_mux_tree_lock(adapter);
> >>
> >> /* Retry automatically on arbitration loss */
> >> orig_jiffies = jiffies;
> >> @@ -1871,7 +1950,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
> >> orig_jiffies + adapter->timeout))
> >> break;
> >> }
> >> - rt_mutex_unlock(&adapter->bus_lock);
> >> + i2c_mux_tree_unlock(adapter);
> >> } else
> >> res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write,
> >> command, protocol, data);
> >
> > I'm worried that this approach is risky. We now use i2c_mux_tree_*lock
> > internally, but still expose the i2c_*lock_adapter() API externally.
> > This API is _not_ mux-aware, and will do the wrong thing if called on a
> > bus segment behind a mux.
> >
> > I'd rather not have two APIs when we really only need one. Let's just
> > update the current public API to be mux-aware, and use that everywhere.
>
> Agree, but I'd vote to do it not inline as its now. Otherwise we start to export
> mux implementation details in i2c.h
Of course. In fact I am preparing a patch which moves these functions
to i2c-core, uninlines them, and uses them as appropriate. Your
multiplexing patch would stack on top of it, so it is nice and clean
and self-contained.
> >> diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
> >> index f4110aa..da5327f 100755
> >> --- a/drivers/i2c/i2c-dev.c
> >> +++ b/drivers/i2c/i2c-dev.c
> >> @@ -193,12 +193,56 @@ static int i2cdev_check(struct device *dev, void *addrp)
> >> return dev->driver ? -EBUSY : 0;
> >> }
> >>
> >> +static int i2cdev_parent_is_i2c_adapter(const struct i2c_adapter *adapter)
> >> +{
> >> + return adapter->dev.parent != NULL
> >> + && adapter->dev.parent->bus == &i2c_bus_type;
> >> +}
> >
> > This is an exact duplicate of the same function in i2c-core. I'd rather
> > make it an inline function in <linux/i2c.h>, or export the one from
> > i2c-core.c. We have enough duplicate code in i2c-dev.c already :(
>
> Must this and the above be done in an extra patch or can it be mixed into this mux patch?
Whatever is easier for you, both are fine with me.
--
Jean Delvare
next prev parent reply other threads:[~2010-06-15 9:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-04 12:46 [PATCH v2 1/2] i2c: Multiplexed I2C bus core support Michael Lawnick
[not found] ` <4BE01741.1010909-Mmb7MZpHnFY@public.gmane.org>
2010-05-04 12:48 ` [PATCH v2 2/2] i2c: Multiplexed I2C bus multiplexer driver pca954x Michael Lawnick
[not found] ` <4BE01795.1090605-Mmb7MZpHnFY@public.gmane.org>
2010-05-04 12:52 ` Rodolfo Giometti
2010-06-09 16:41 ` Jean Delvare
[not found] ` <20100609184143.06488f2f-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-06-10 10:15 ` Michael Lawnick
2010-06-13 12:11 ` Jean Delvare
[not found] ` <20100613141122.1d5b1423-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-06-14 9:09 ` Michael Lawnick
2010-05-04 12:52 ` [PATCH v2 1/2] i2c: Multiplexed I2C bus core support Rodolfo Giometti
2010-05-17 7:36 ` Michael Lawnick
[not found] ` <4BF0F200.5090604-Mmb7MZpHnFY@public.gmane.org>
2010-05-17 8:15 ` Jean Delvare
2010-06-10 13:24 ` Jean Delvare
[not found] ` <20100610152411.5497461c-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-06-11 6:31 ` Michael Lawnick
[not found] ` <4C11D85F.7010604-Mmb7MZpHnFY@public.gmane.org>
2010-06-11 9:40 ` Jean Delvare
[not found] ` <20100611114003.01c15f62-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-06-15 8:53 ` Michael Lawnick
2010-06-15 8:52 ` Michael Lawnick
[not found] ` <4C173F61.8000007-Mmb7MZpHnFY@public.gmane.org>
2010-06-15 9:00 ` Jean Delvare [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-05-04 12:29 Michael Lawnick
[not found] ` <4BE01321.3060704-Mmb7MZpHnFY@public.gmane.org>
2010-05-04 12:33 ` Rodolfo Giometti
2010-05-04 12:37 ` Michael Lawnick
[not found] ` <4BE014ED.9070907-Mmb7MZpHnFY@public.gmane.org>
2010-05-04 15:19 ` Yegor Yefremov
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=20100615110018.3260a511@hyperion.delvare \
--to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ml.lawnick-Mmb7MZpHnFY@public.gmane.org \
/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