[media] rtl28xxu: return demod reg page from driver cache
authorAntti Palosaari <crope@iki.fi>
Mon, 5 Oct 2015 23:46:37 +0000 (20:46 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Wed, 23 Dec 2015 16:11:02 +0000 (14:11 -0200)
Return current active rtl2830/rtl2832 register page from the driver
cache in order to reduce I2C I/O. Register page is already cached
due to I2C write needs.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/usb/dvb-usb-v2/rtl28xxu.c

index 5a503a6bb8c5dc9f40b0a4b051db9d489d8ff92c..eb5787a3191e7afc31e69e6e9757297b745279c0 100644 (file)
@@ -181,11 +181,17 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                        goto err_mutex_unlock;
                } else if (msg[0].addr == 0x10) {
                        /* method 1 - integrated demod */
-                       req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
-                       req.index = CMD_DEMOD_RD | dev->page;
-                       req.size = msg[1].len;
-                       req.data = &msg[1].buf[0];
-                       ret = rtl28xxu_ctrl_msg(d, &req);
+                       if (msg[0].buf[0] == 0x00) {
+                               /* return demod page from driver cache */
+                               msg[1].buf[0] = dev->page;
+                               ret = 0;
+                       } else {
+                               req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
+                               req.index = CMD_DEMOD_RD | dev->page;
+                               req.size = msg[1].len;
+                               req.data = &msg[1].buf[0];
+                               ret = rtl28xxu_ctrl_msg(d, &req);
+                       }
                } else if (msg[0].len < 2) {
                        /* method 2 - old I2C */
                        req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);