linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Michael Krufky <mkrufky-dJidKbW2IEtAfugRpC6u6w@public.gmane.org>
Subject: Re: [PATCH] i2c-algo-bit: Add pre- and post-xfer hooks
Date: Sat, 13 Mar 2010 11:52:06 -0500	[thread overview]
Message-ID: <a728f9f91003130852x2640fa44l6da686d01a43e7e7@mail.gmail.com> (raw)
In-Reply-To: <20100313174757.4a9f40d7-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>

On Sat, Mar 13, 2010 at 11:47 AM, Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:
> Drivers might have to do random things before and/or after I2C
> transfers. Add hooks to the i2c-algo-bit implementation to let them do
> so.
>
> Signed-off-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> Cc: Alex Deucher <alexdeucher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: Michael Krufky <mkrufky-dJidKbW2IEtAfugRpC6u6w@public.gmane.org>
> ---
> Alex, compared to the first version I sent, I have removed the second
> parameter of the hooks. You did not use it, I'm not really sure why
> anybody would, and if one really needs the private data, it can be
> reached from the i2c_adapter struct itself. So I'd rather start simple,
> and add parameters only if a clear need appears over time. You'll have
> to update your patch to the radeon driver accordingly.

No problem.  I'll update my radeon patches next week.

Alex

>
> Michael, I seem to recall you wanted something like that a couple years
> ago?
>
>  drivers/i2c/algos/i2c-algo-bit.c |    9 +++++++++
>  include/linux/i2c-algo-bit.h     |    2 ++
>  2 files changed, 11 insertions(+)
>
> --- linux-2.6.34-rc1.orig/drivers/i2c/algos/i2c-algo-bit.c      2010-03-13 16:26:30.000000000 +0100
> +++ linux-2.6.34-rc1/drivers/i2c/algos/i2c-algo-bit.c   2010-03-13 16:41:05.000000000 +0100
> @@ -522,6 +522,12 @@ static int bit_xfer(struct i2c_adapter *
>        int i, ret;
>        unsigned short nak_ok;
>
> +       if (adap->pre_xfer) {
> +               ret = adap->pre_xfer(i2c_adap);
> +               if (ret < 0)
> +                       return ret;
> +       }
> +
>        bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
>        i2c_start(adap);
>        for (i = 0; i < num; i++) {
> @@ -570,6 +576,9 @@ static int bit_xfer(struct i2c_adapter *
>  bailout:
>        bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
>        i2c_stop(adap);
> +
> +       if (adap->post_xfer)
> +               adap->post_xfer(i2c_adap);
>        return ret;
>  }
>
> --- linux-2.6.34-rc1.orig/include/linux/i2c-algo-bit.h  2010-03-13 16:26:30.000000000 +0100
> +++ linux-2.6.34-rc1/include/linux/i2c-algo-bit.h       2010-03-13 17:23:03.000000000 +0100
> @@ -36,6 +36,8 @@ struct i2c_algo_bit_data {
>        void (*setscl) (void *data, int state);
>        int  (*getsda) (void *data);
>        int  (*getscl) (void *data);
> +       int  (*pre_xfer)  (struct i2c_adapter *);
> +       void (*post_xfer) (struct i2c_adapter *);
>
>        /* local settings */
>        int udelay;             /* half clock cycle time in us,
>
>
> --
> Jean Delvare
>

      parent reply	other threads:[~2010-03-13 16:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-13 16:47 [PATCH] i2c-algo-bit: Add pre- and post-xfer hooks Jean Delvare
     [not found] ` <20100313174757.4a9f40d7-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-03-13 16:52   ` Alex Deucher [this message]

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=a728f9f91003130852x2640fa44l6da686d01a43e7e7@mail.gmail.com \
    --to=alexdeucher-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mkrufky-dJidKbW2IEtAfugRpC6u6w@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).