From: Patrick Boettcher Date: Mon, 30 Nov 2009 17:14:36 +0000 (-0300) Subject: V4L/DVB (13581): DiBUSB: fix I2c access when there is a read-access w/o write sequence X-Git-Tag: upstream/snapshot3+hdmi~16131^2~73 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=38ffcd10d6831efd15ec5a223b1050eac12d4c28;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git V4L/DVB (13581): DiBUSB: fix I2c access when there is a read-access w/o write sequence This patch fixes the behaviour of the dibusb-i2c-access which was previously changed to avoid accidental EEprom writes: Now it allow i2c-reads without prepended i2c-writes, but it is still not doing anything in case the EEprom is addressed. Thanks to Mario Bachmann for testing. Tested-by: Mario Bachmann Cc: Mario Bachmann Signed-off-by: Patrick Boettcher Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c index b395e85..9143b56 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-common.c +++ b/drivers/media/dvb/dvb-usb/dibusb-common.c @@ -142,8 +142,13 @@ static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num } else if ((msg[i].flags & I2C_M_RD) == 0) { if (dibusb_i2c_msg(d, msg[i].addr, msg[i].buf,msg[i].len,NULL,0) < 0) break; - } else - break; + } else if (msg[i].addr != 0x50) { + /* 0x50 is the address of the eeprom - we need to protect it + * from dibusb's bad i2c implementation: reads without + * writing the offset before are forbidden */ + if (dibusb_i2c_msg(d, msg[i].addr, NULL, 0, msg[i].buf, msg[i].len) < 0) + break; + } } mutex_unlock(&d->i2c_mutex);