From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Alex Deucher <alexdeucher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Using algo-bit in another i2c algo
Date: Wed, 10 Mar 2010 22:49:36 +0100 [thread overview]
Message-ID: <20100310224936.0d4f8a65@hyperion.delvare> (raw)
In-Reply-To: <a728f9f91003101116l422374d2vceb1e5dddfdf44d8-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Wed, 10 Mar 2010 14:16:18 -0500, Alex Deucher wrote:
> I tested the second patch with a trivial patch to the radeon drm:
>
> --- a/drivers/gpu/drm/radeon/radeon_i2c.c
> +++ b/drivers/gpu/drm/radeon/radeon_i2c.c
> @@ -892,9 +892,9 @@ struct radeon_i2c_chan *radeon_i2c_create(struct
> drm_device *dev,
> * make this, 2 jiffies is a lot more reliable */
> i2c->algo.radeon.bit_data.timeout = 2;
> i2c->algo.radeon.bit_data.data = i2c;
> - ret = i2c_bit_add_bus(&i2c->algo.radeon.bit_adapter);
> + ret = i2c_bit_prepare_bus(&i2c->algo.radeon.bit_adapter);
> if (ret) {
> - DRM_ERROR("Failed to register internal bit i2c %s\n", name);
> + DRM_ERROR("Failed to prepare internal bit i2c %s\n", name);
> goto out_free;
> }
> /* set the radeon i2c adapter */
>
> However, just calling i2c_bit_prepare_bus does not appear to be
> enough. as I get the following oops:
> (...)
Hmm, sorry, I have probably not been clear about the intent of
i2c_bit_prepare_bus(). It does _not_ give you a usable i2c_adapter. The
actual initialization happens in i2c_register_adapter(), in i2c-core.
What it gives you is a usable i2c _algorithm_. That is, you can call
bit_adapter.algo->master_xfer(), presumably from within your actual
(registered) adapter's master_xfer() function.
Now, I have to admit that it is pretty confusing that you call a
"prepare" function on an i2c_adapter and you can't use it. And looking
a bit more into it... Even calling bit_adapter.algo->master_xfer()
assumes an initialized i2c_adapter, at least for error messages. So my
proposal was probably not such a good idea, at least not with the
current i2c-algo-bit implementation, and probably not without a big
rework of the i2c algorithm structure itself: at the moment, i2c
algorithms really assume that they have an i2c_adapter associated _and_
that this i2c_adapter has a device associated.
Maybe we could move the core of i2c-algo-bit to a library so that it is
easier to reuse. But that would be a lot more work, so we will only do
this there is a clear benefit. At this point, it seems cheaper to
pursue the first option (pre- and post-xfer hooks) if that works for
you.
--
Jean Delvare
next prev parent reply other threads:[~2010-03-10 21:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-11 22:13 Using algo-bit in another i2c algo Alex Deucher
[not found] ` <a728f9f91001111413t1a733e0rbc0352ddd2d9de7c-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-03-10 9:44 ` Jean Delvare
[not found] ` <20100310104401.57fc43b2-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-03-10 16:58 ` Alex Deucher
2010-03-10 19:16 ` Alex Deucher
[not found] ` <a728f9f91003101116l422374d2vceb1e5dddfdf44d8-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-03-10 21:49 ` Jean Delvare [this message]
[not found] ` <20100310224936.0d4f8a65-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-03-10 22:56 ` Alex Deucher
2010-03-10 20:47 ` Alex Deucher
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=20100310224936.0d4f8a65@hyperion.delvare \
--to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
--cc=alexdeucher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-i2c-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).