From: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [RFC/PATCH 2/3] i2c: Fall back to emulated SMBus if the operation isn't supported natively
Date: Tue, 17 Jul 2012 17:06:52 +0200 [thread overview]
Message-ID: <1505616.XoIl1gvLjc@avalon> (raw)
In-Reply-To: <20120717170243.5def41a3-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
Hi Jean,
On Tuesday 17 July 2012 17:02:43 Jean Delvare wrote:
> On Tue, 26 Jun 2012 16:17:08 +0200, Laurent Pinchart wrote:
> > Adapter drivers might support only a subset of the SMBus operations
> > natively. Those drivers currently have to manually emulate unsupported
> > operations using I2C.
> >
> > Make the i2c_smbus_xfer() function fall back to
> > i2c_smbus_xfer_emulated() when the adapter's .smbus_xfer() operation
> > returns -EOPNOTSUPP, like it already does when the .smbus_xfer()
> > operation isn't available at all.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
> > ---
> >
> > drivers/i2c/i2c-core.c | 9 +++++++--
> > 1 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> > index 8cfa660..16e750e 100644
> > --- a/drivers/i2c/i2c-core.c
> > +++ b/drivers/i2c/i2c-core.c
> > @@ -2113,8 +2113,8 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16
> > addr, unsigned short flags,
> > union i2c_smbus_data *data)
> > {
> > unsigned long orig_jiffies;
> > + s32 res = -EOPNOTSUPP;
> > int try;
> > - s32 res;
> >
> > flags &= I2C_M_TEN | I2C_CLIENT_PEC | I2C_CLIENT_SCCB;
> >
> > @@ -2134,7 +2134,12 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16
> > addr, unsigned short flags,
> > break;
> > }
> > i2c_unlock_adapter(adapter);
> > - } else
> > + }
> > +
> > + /* Fall back to i2c_smbus_xfer_emulated of the adapter doesn't
implement
> > + * native support for the SMBus operation.
> > + */
> > + if (res == -EOPNOTSUPP && adapter->algo->master_xfer)
> > res = i2c_smbus_xfer_emulated(adapter, addr, flags, read_write,
> > command, protocol, data);
>
> Looks good overall, but maybe the following variant would be preferable
> from a performance perspective:
>
> --- linux-3.5-rc7.orig/drivers/i2c/i2c-core.c 2012-07-17
16:35:42.566799611
> +0200 +++ linux-3.5-rc7/drivers/i2c/i2c-core.c 2012-07-17
> 16:59:55.334530352 +0200 @@ -2140,11 +2140,17 @@ s32 i2c_smbus_xfer(struct
> i2c_adapter *a
> break;
> }
> i2c_unlock_adapter(adapter);
> - } else
> - res = i2c_smbus_xfer_emulated(adapter, addr, flags, read_write,
> - command, protocol, data);
>
> - return res;
> + if (res != -EOPNOTSUPP || !adapter->algo->master_xfer)
> + return res;
> + /*
> + * Fall back to i2c_smbus_xfer_emulated if the adapter doesn't
implement
> + * native support for the SMBus operation.
> + */
> + }
> +
> + return i2c_smbus_xfer_emulated(adapter, addr, flags, read_write,
> + command, protocol, data);
> }
> EXPORT_SYMBOL(i2c_smbus_xfer);
>
>
> What do you think? The advantage is that we can skip the tests for
> adapters which only implement adapter->algo->master_xfer().
I'm fine with that.
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2012-07-17 15:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-26 14:17 [RFC/PATCH 0/3] OMAP3 I2C/SCCB support Laurent Pinchart
2012-06-26 14:17 ` [RFC/PATCH 1/3] i2c: Add SCCB support Laurent Pinchart
2012-07-17 11:53 ` Jean Delvare
[not found] ` <20120717135307.6745729f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-07-17 11:57 ` Laurent Pinchart
2012-07-17 12:08 ` Jean Delvare
2012-06-26 14:17 ` [RFC/PATCH 2/3] i2c: Fall back to emulated SMBus if the operation isn't supported natively Laurent Pinchart
[not found] ` <1340720229-30356-3-git-send-email-laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2012-07-17 15:02 ` Jean Delvare
[not found] ` <20120717170243.5def41a3-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-07-17 15:06 ` Laurent Pinchart [this message]
[not found] ` <1340720229-30356-1-git-send-email-laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2012-06-26 14:17 ` [RFC/PATCH 3/3] i2c: omap: Add support for I2C_M_STOP message flag Laurent Pinchart
[not found] ` <1340720229-30356-4-git-send-email-laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2012-07-17 15:29 ` Jean Delvare
[not found] ` <20120717172935.45ff210f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-07-18 1:05 ` Laurent Pinchart
2012-07-18 6:19 ` Shubhrajyoti
[not found] ` <5006556C.8070003-l0cyMroinI0@public.gmane.org>
2012-07-18 11:13 ` Laurent Pinchart
2012-07-18 12:08 ` Shubhrajyoti Datta
2012-06-26 14:49 ` [RFC/PATCH 0/3] OMAP3 I2C/SCCB support jean-philippe francois
2012-06-26 16:20 ` Laurent Pinchart
2012-06-26 16:25 ` Gary Thomas
[not found] ` <4FE9E296.4020905-kIKI1E8EpGZWk0Htik3J/w@public.gmane.org>
2012-06-26 16:36 ` Laurent Pinchart
2012-06-26 16:56 ` Jean Delvare
[not found] ` <20120626185616.7fafc53b-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-06-26 21:37 ` Laurent Pinchart
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=1505616.XoIl1gvLjc@avalon \
--to=laurent.pinchart-rylnwiuwjnjg/c1bvhzhaw@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.