On Sat, Mar 13, 2010 at 11:47 AM, Jean Delvare <khali@xxxxxxxxxxxx> 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@xxxxxxxxxxxx> > Cc: Alex Deucher <alexdeucher@xxxxxxxxx> > Cc: Michael Krufky <mkrufky@xxxxxxxxxxx> > --- > 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 > -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html