From 6eb5d9ca9f1496108cb86f2d9bfc2db5d9c796fe Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 22 Mar 2006 03:48:32 -0300 Subject: V4L/DVB (3568b): saa7111: Prevent array overrun Explicitely state the number of registers the SAA7111 has, and use that defined value where relevant. This should prevent any future array overrun like the one I just fixed in the saa7110 driver. This patch also saves 8 bytes of memory as a side effect, as the register cache was larger than needed. Signed-off-by: Jean Delvare Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa7111.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/media/video/saa7111.c') diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 8c06592b37ff..a2e1ccb79e49 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c @@ -70,8 +70,10 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); /* ----------------------------------------------------------------------- */ +#define SAA7111_NR_REG 0x18 + struct saa7111 { - unsigned char reg[32]; + unsigned char reg[SAA7111_NR_REG]; int norm; int input; @@ -227,11 +229,11 @@ saa7111_command (struct i2c_client *client, { int i; - for (i = 0; i < 32; i += 16) { + for (i = 0; i < SAA7111_NR_REG; i += 16) { int j; printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i); - for (j = 0; j < 16; ++j) { + for (j = 0; j < 16 && i + j < SAA7111_NR_REG; ++j) { printk(" %02x", saa7111_read(client, i + j)); } -- cgit v1.2.3 From 58a0b84c92e62c2cc42036259a4b51e0bcaf8fa5 Mon Sep 17 00:00:00 2001 From: Martin Samuelsson Date: Wed, 22 Mar 2006 03:48:38 -0300 Subject: V4L/DVB (3568d): saa7111.c fix When grabbing composite video with Iomega Buz, the stock driver will prevent grabbing from the same input twice in a row, forcing the user to switch inputs before anything useful can be grabbed again. It is caused by some optimization code in the input selection parts, and triggered by the saa7111_command() executing cmd 0. The attached patch will remedy this by disabling cmd 0 altogether; a fix that has no found negative effects on the rest of the code. In fact, saa7110.c does the exact same thing. Acked-by: Ronald S. Bultje Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa7111.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/media/video/saa7111.c') diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index a2e1ccb79e49..6bd1789c8f78 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c @@ -212,6 +212,7 @@ saa7111_command (struct i2c_client *client, switch (cmd) { case 0: + break; case DECODER_INIT: { struct video_decoder_init *init = arg; -- cgit v1.2.3 From 9aa45e34d2948f360f8c0e63d10f49015ca51edd Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 22 Mar 2006 03:48:35 -0300 Subject: V4L/DVB (3568k): zoran: Use i2c_master_send when possible Change all the Zoran (ZR36050/ZR36060) drivers to use i2c_master_send instead of i2c_transfer when possible. This simplifies the code by a few lines in each driver. Signed-off-by: Jean Delvare Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa7111.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'drivers/media/video/saa7111.c') diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 6bd1789c8f78..cb27917c376a 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c @@ -112,24 +112,21 @@ saa7111_write_block (struct i2c_client *client, if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { /* do raw I2C, not smbus compatible */ struct saa7111 *decoder = i2c_get_clientdata(client); - struct i2c_msg msg; u8 block_data[32]; + int block_len; - msg.addr = client->addr; - msg.flags = 0; while (len >= 2) { - msg.buf = (char *) block_data; - msg.len = 0; - block_data[msg.len++] = reg = data[0]; + block_len = 0; + block_data[block_len++] = reg = data[0]; do { - block_data[msg.len++] = + block_data[block_len++] = decoder->reg[reg++] = data[1]; len -= 2; data += 2; } while (len >= 2 && data[0] == reg && - msg.len < 32); - if ((ret = i2c_transfer(client->adapter, - &msg, 1)) < 0) + block_len < 32); + if ((ret = i2c_master_send(client, block_data, + block_len)) < 0) break; } } else { -- cgit v1.2.3