Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: CX88 i2c issue w/ DVB tuners



Andrew de Quincey wrote:
The thin layer already exists, almost all i2c drivers implement the
master_transfer function like this:

int i2c_transfer (struct i2c_adapter *adap,
                  struct i2c_msg msg[],
                  int num)
{
for (i=0; i<num; i++) {
 if (msg[i].flags & I2C_M_RD)
  i2c_read(adap, msg[i].buf, msg[i].len);
 else
  i2c_write(adap, msg[i].buf, msg[i].len);
}
}


Nothing new needs to get introduced despite two convinience functions
which reverse the useless API abstraction and access the read/write
functions directly again:


int card_i2c_write (struct card *card, const u8 *buf, int len)
{
struct i2c_msg m = { .flags = 0, .buf = buf, .len = len };
return i2c_transfer(&card->i2c_adap, &m, 1) == 1 ? len : -EIO;
}


int card_i2c_read (struct card *card, const u8 *buf, int len)
{
struct i2c_msg m = { .flags = I2C_M_RD, .buf = buf, .len = len };
return i2c_transfer(&card->i2c_adap, &m, 1) == 1 ? len : -EIO;
}

"Almost all". The cx88 does not for example. It only implements the setscl, setsda, getscl, getsda functions. The standard kernel i2c bitbanging code does the rest.
the bitbanging driver implements the master_xfer() function mentioned above, thus your can directly use i2c_transfer() and don't have to implement anything new.

Holger




Home | Main Index | Thread Index