Commit 88f07ffb authored by Linus Torvalds's avatar Linus Torvalds

Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb

* master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb:
  V4L/DVB (3568k): zoran: Use i2c_master_send when possible
  V4L/DVB (3568j): adv7175: Drop unused encoder dump command
  V4L/DVB (3568i): adv7175: Drop unused register cache
  V4L/DVB (3568h): cpia: correct email address
  V4L/DVB (3568g): sem2mutex: zoran
  V4L/DVB (3568f): saa7110: Fix array overrun
  V4L/DVB (3568e): bt856: Spare memory
  V4L/DVB (3568d): saa7111.c fix
  V4L/DVB (3568c): zoran: Init cleanups
  V4L/DVB (3568b): saa7111: Prevent array overrun
  V4L/DVB (3568a): saa7114: Fix i2c block write
parents b6585ded 9aa45e34
......@@ -124,24 +124,21 @@ adv7170_write_block (struct i2c_client *client,
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
struct adv7170 *encoder = 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++] =
encoder->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 {
......
......@@ -67,8 +67,6 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
/* ----------------------------------------------------------------------- */
struct adv7175 {
unsigned char reg[128];
int norm;
int input;
int enable;
......@@ -94,9 +92,6 @@ adv7175_write (struct i2c_client *client,
u8 reg,
u8 value)
{
struct adv7175 *encoder = i2c_get_clientdata(client);
encoder->reg[reg] = value;
return i2c_smbus_write_byte_data(client, reg, value);
}
......@@ -119,25 +114,21 @@ adv7175_write_block (struct i2c_client *client,
* the adapter understands raw I2C */
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
struct adv7175 *encoder = 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++] =
encoder->reg[reg++] = data[1];
block_data[block_len++] = data[1];
reg++;
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 {
......@@ -170,24 +161,6 @@ set_subcarrier_freq (struct i2c_client *client,
adv7175_write(client, 0x05, 0x25);
}
#ifdef ENCODER_DUMP
static void
dump (struct i2c_client *client)
{
struct adv7175 *encoder = i2c_get_clientdata(client);
int i, j;
printk(KERN_INFO "%s: registry dump\n", I2C_NAME(client));
for (i = 0; i < 182 / 8; i++) {
printk("%s: 0x%02x -", I2C_NAME(client), i * 8);
for (j = 0; j < 8; j++) {
printk(" 0x%02x", encoder->reg[i * 8 + j]);
}
printk("\n");
}
}
#endif
/* ----------------------------------------------------------------------- */
// Output filter: S-Video Composite
......@@ -406,14 +379,6 @@ adv7175_command (struct i2c_client *client,
}
break;
#ifdef ENCODER_DUMP
case ENCODER_DUMP:
{
dump(client);
}
break;
#endif
default:
return -EINVAL;
}
......
......@@ -140,24 +140,21 @@ bt819_write_block (struct i2c_client *client,
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
struct bt819 *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 {
......
......@@ -70,17 +70,14 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
/* ----------------------------------------------------------------------- */
#define REG_OFFSET 0xCE
#define REG_OFFSET 0xDA
#define BT856_NR_REG 6
struct bt856 {
unsigned char reg[32];
unsigned char reg[BT856_NR_REG];
int norm;
int enable;
int bright;
int contrast;
int hue;
int sat;
};
#define I2C_BT856 0x88
......@@ -119,8 +116,8 @@ bt856_dump (struct i2c_client *client)
struct bt856 *encoder = i2c_get_clientdata(client);
printk(KERN_INFO "%s: register dump:", I2C_NAME(client));
for (i = 0xd6; i <= 0xde; i += 2)
printk(" %02x", encoder->reg[i - REG_OFFSET]);
for (i = 0; i < BT856_NR_REG; i += 2)
printk(" %02x", encoder->reg[i]);
printk("\n");
}
......
......@@ -58,7 +58,7 @@ static int video_nr = -1;
#ifdef MODULE
module_param(video_nr, int, 0);
MODULE_AUTHOR("Scott J. Bertin <sbertin@securenym.net> & Peter Pregler <Peter_Pregler@email.com> & Johannes Erdfelt <johannes@erdfeld.com>");
MODULE_AUTHOR("Scott J. Bertin <sbertin@securenym.net> & Peter Pregler <Peter_Pregler@email.com> & Johannes Erdfelt <johannes@erdfelt.com>");
MODULE_DESCRIPTION("V4L-driver for Vision CPiA based cameras");
MODULE_LICENSE("GPL");
MODULE_SUPPORTED_DEVICE("video");
......
......@@ -107,13 +107,8 @@ saa7110_write_block (struct i2c_client *client,
* the adapter understands raw I2C */
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
struct saa7110 *decoder = i2c_get_clientdata(client);
struct i2c_msg msg;
msg.len = len;
msg.buf = (char *) data;
msg.addr = client->addr;
msg.flags = 0;
ret = i2c_transfer(client->adapter, &msg, 1);
ret = i2c_master_send(client, data, len);
/* Cache the written data */
memcpy(decoder->reg + reg, data + 1, len - 1);
......@@ -431,15 +426,13 @@ saa7110_command (struct i2c_client *client,
break;
case DECODER_DUMP:
for (v = 0; v < 0x34; v += 16) {
for (v = 0; v < SAA7110_NR_REG; v += 16) {
int j;
dprintk(1, KERN_INFO "%s: %03x\n", I2C_NAME(client),
dprintk(1, KERN_DEBUG "%s: %02x:", I2C_NAME(client),
v);
for (j = 0; j < 16; j++) {
dprintk(1, KERN_INFO " %02x",
decoder->reg[v + j]);
}
dprintk(1, KERN_INFO "\n");
for (j = 0; j < 16 && v + j < SAA7110_NR_REG; j++)
dprintk(1, " %02x", decoder->reg[v + j]);
dprintk(1, "\n");
}
break;
......
......@@ -69,8 +69,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;
......@@ -109,24 +111,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 {
......@@ -209,6 +208,7 @@ saa7111_command (struct i2c_client *client,
switch (cmd) {
case 0:
break;
case DECODER_INIT:
{
struct video_decoder_init *init = arg;
......@@ -226,11 +226,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));
}
......
......@@ -138,9 +138,6 @@ saa7114_write (struct i2c_client *client,
u8 reg,
u8 value)
{
/*struct saa7114 *decoder = i2c_get_clientdata(client);*/
/*decoder->reg[reg] = value;*/
return i2c_smbus_write_byte_data(client, reg, value);
}
......@@ -156,25 +153,21 @@ saa7114_write_block (struct i2c_client *client,
* the adapter understands raw I2C */
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
/*struct saa7114 *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++] =
/*decoder->reg[reg++] =*/ data[1];
block_data[block_len++] = data[1];
reg++;
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 {
......
......@@ -112,24 +112,21 @@ saa7185_write_block (struct i2c_client *client,
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
struct saa7185 *encoder = 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++] =
encoder->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 {
......
......@@ -395,7 +395,7 @@ struct zoran {
struct videocodec *codec; /* video codec */
struct videocodec *vfe; /* video front end */
struct semaphore resource_lock; /* prevent evil stuff */
struct mutex resource_lock; /* prevent evil stuff */
u8 initialized; /* flag if zoran has been correctly initalized */
int user; /* number of current users */
......
......@@ -47,6 +47,7 @@
#include <linux/interrupt.h>
#include <linux/video_decoder.h>
#include <linux/video_encoder.h>
#include <linux/mutex.h>
#include <asm/io.h>
......@@ -673,7 +674,7 @@ zoran_i2c_client_register (struct i2c_client *client)
KERN_DEBUG "%s: i2c_client_register() - driver id = %d\n",
ZR_DEVNAME(zr), client->driver->id);
down(&zr->resource_lock);
mutex_lock(&zr->resource_lock);
if (zr->user > 0) {
/* we're already busy, so we keep a reference to
......@@ -694,7 +695,7 @@ zoran_i2c_client_register (struct i2c_client *client)
}
clientreg_unlock_and_return:
up(&zr->resource_lock);
mutex_unlock(&zr->resource_lock);
return res;
}
......@@ -707,7 +708,7 @@ zoran_i2c_client_unregister (struct i2c_client *client)
dprintk(2, KERN_DEBUG "%s: i2c_client_unregister()\n", ZR_DEVNAME(zr));
down(&zr->resource_lock);
mutex_lock(&zr->resource_lock);
if (zr->user > 0) {
res = -EBUSY;
......@@ -722,7 +723,7 @@ zoran_i2c_client_unregister (struct i2c_client *client)
snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%d]", zr->id);
}
clientunreg_unlock_and_return:
up(&zr->resource_lock);
mutex_unlock(&zr->resource_lock);
return res;
}
......@@ -995,10 +996,7 @@ test_interrupts (struct zoran *zr)
static int __devinit
zr36057_init (struct zoran *zr)
{
u32 *mem;
void *vdev;
unsigned mem_needed;
int j;
int j, err;
int two = 2;
int zero = 0;
......@@ -1049,19 +1047,16 @@ zr36057_init (struct zoran *zr)
/* allocate memory *before* doing anything to the hardware
* in case allocation fails */
mem_needed = BUZ_NUM_STAT_COM * 4;
mem = kzalloc(mem_needed, GFP_KERNEL);
vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL);
if (!mem || !vdev) {
zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL);
zr->video_dev = kmalloc(sizeof(struct video_device), GFP_KERNEL);
if (!zr->stat_com || !zr->video_dev) {
dprintk(1,
KERN_ERR
"%s: zr36057_init() - kmalloc (STAT_COM) failed\n",
ZR_DEVNAME(zr));
kfree(vdev);
kfree(mem);
return -ENOMEM;
err = -ENOMEM;
goto exit_free;
}
zr->stat_com = mem;
for (j = 0; j < BUZ_NUM_STAT_COM; j++) {
zr->stat_com[j] = 1; /* mark as unavailable to zr36057 */
}
......@@ -1069,16 +1064,11 @@ zr36057_init (struct zoran *zr)
/*
* Now add the template and register the device unit.
*/
zr->video_dev = vdev;
memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template));
strcpy(zr->video_dev->name, ZR_DEVNAME(zr));
if (video_register_device(zr->video_dev, VFL_TYPE_GRABBER,
video_nr) < 0) {
zoran_unregister_i2c(zr);
kfree((void *) zr->stat_com);
kfree(vdev);
return -1;
}
err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr);
if (err < 0)
goto exit_unregister;
zoran_init_hardware(zr);
if (*zr_debug > 2)
......@@ -1092,6 +1082,13 @@ zr36057_init (struct zoran *zr)
zr->zoran_proc = NULL;
zr->initialized = 1;
return 0;
exit_unregister:
zoran_unregister_i2c(zr);
exit_free:
kfree(zr->stat_com);
kfree(zr->video_dev);
return err;
}
static void
......@@ -1121,7 +1118,7 @@ zoran_release (struct zoran *zr)
btwrite(0, ZR36057_SPGPPCR);
free_irq(zr->pci_dev->irq, zr);
/* unmap and free memory */
kfree((void *) zr->stat_com);
kfree(zr->stat_com);
zoran_proc_cleanup(zr);
iounmap(zr->zr36057_mem);
pci_disable_device(zr->pci_dev);
......@@ -1206,7 +1203,7 @@ find_zr36057 (void)
zr->id = zoran_num;
snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id);
spin_lock_init(&zr->spinlock);
init_MUTEX(&zr->resource_lock);
mutex_init(&zr->resource_lock);
if (pci_enable_device(dev))
continue;
zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment