X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fmedia%2Fvideo%2Fsaa6588.c;h=f05024259f0150707957dfc37b6e973ae0bcb011;hb=35ea11ff84719b1bfab2909903a9640a86552fd1;hp=1a657a70ff43c53158a50ce2140e90c55429889d;hpb=10b89ee387fd6cc38532a881f64b3d35f338ea0b;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c index 1a657a7..f050242 100644 --- a/drivers/media/video/saa6588.c +++ b/drivers/media/video/saa6588.c @@ -31,9 +31,7 @@ #include #include -#include - -#include "rds.h" +#include /* Addresses to scan */ static unsigned short normal_i2c[] = { @@ -45,21 +43,21 @@ static unsigned short normal_i2c[] = { I2C_CLIENT_INSMOD; /* insmod options */ -static unsigned int debug = 0; -static unsigned int xtal = 0; -static unsigned int rbds = 0; -static unsigned int plvl = 0; +static unsigned int debug; +static unsigned int xtal; +static unsigned int rbds; +static unsigned int plvl; static unsigned int bufblocks = 100; -MODULE_PARM(debug, "i"); +module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "enable debug messages"); -MODULE_PARM(xtal, "i"); +module_param(xtal, int, 0); MODULE_PARM_DESC(xtal, "select oscillator frequency (0..3), default 0"); -MODULE_PARM(rbds, "i"); +module_param(rbds, int, 0); MODULE_PARM_DESC(rbds, "select mode, 0=RDS, 1=RBDS, default 0"); -MODULE_PARM(plvl, "i"); +module_param(plvl, int, 0); MODULE_PARM_DESC(plvl, "select pause level (0..3), default 0"); -MODULE_PARM(bufblocks, "i"); +module_param(bufblocks, int, 0); MODULE_PARM_DESC(bufblocks, "number of buffered blocks, default 100"); MODULE_DESCRIPTION("v4l2 driver module for SAA6588 RDS decoder"); @@ -157,7 +155,7 @@ static struct i2c_client client_template; /* ---------------------------------------------------------------------- */ -static int block_to_user_buf(struct saa6588 *s, unsigned char *user_buf) +static int block_to_user_buf(struct saa6588 *s, unsigned char __user *user_buf) { int i; @@ -191,7 +189,7 @@ static void read_from_buf(struct saa6588 *s, struct rds_command *a) { unsigned long flags; - unsigned char *buf_ptr = a->buffer; /* This is a user space buffer! */ + unsigned char __user *buf_ptr = a->buffer; unsigned int i; unsigned int rd_blocks; @@ -213,8 +211,10 @@ static void read_from_buf(struct saa6588 *s, struct rds_command *a) if (rd_blocks > s->block_count) rd_blocks = s->block_count; - if (!rd_blocks) + if (!rd_blocks) { + spin_unlock_irqrestore(&s->lock, flags); return; + } for (i = 0; i < rd_blocks; i++) { if (block_to_user_buf(s, buf_ptr)) { @@ -246,7 +246,7 @@ static void block_to_buf(struct saa6588 *s, unsigned char *blockbuf) s->wr_index = 0; if (s->wr_index == s->rd_index) { - s->rd_index++; + s->rd_index += 3; if (s->rd_index >= s->buf_size) s->rd_index = 0; } else @@ -323,12 +323,12 @@ static void saa6588_timer(unsigned long data) schedule_work(&s->work); } -static void saa6588_work(void *data) +static void saa6588_work(struct work_struct *work) { - struct saa6588 *s = (struct saa6588 *)data; + struct saa6588 *s = container_of(work, struct saa6588, work); saa6588_i2c_poll(s); - mod_timer(&s->timer, jiffies + HZ / 50); /* 20 msec */ + mod_timer(&s->timer, jiffies + msecs_to_jiffies(20)); } static int saa6588_configure(struct saa6588 *s) @@ -405,6 +405,7 @@ static int saa6588_attach(struct i2c_adapter *adap, int addr, int kind) kfree(s); return -ENOMEM; } + spin_lock_init(&s->lock); s->client = client_template; s->block_count = 0; s->wr_index = 0; @@ -418,29 +419,18 @@ static int saa6588_attach(struct i2c_adapter *adap, int addr, int kind) saa6588_configure(s); /* start polling via eventd */ - INIT_WORK(&s->work, saa6588_work, s); + INIT_WORK(&s->work, saa6588_work); init_timer(&s->timer); s->timer.function = saa6588_timer; s->timer.data = (unsigned long)s; schedule_work(&s->work); - return 0; } static int saa6588_probe(struct i2c_adapter *adap) { -#ifdef I2C_CLASS_TV_ANALOG if (adap->class & I2C_CLASS_TV_ANALOG) return i2c_probe(adap, &addr_data, saa6588_attach); -#else - switch (adap->id) { - case I2C_ALGO_BIT | I2C_HW_B_BT848: - case I2C_ALGO_BIT | I2C_HW_B_RIVA: - case I2C_ALGO_SAA7134: - return i2c_probe(adap, &addr_data, saa6588_attach); - break; - } -#endif return 0; } @@ -497,10 +487,10 @@ static int saa6588_command(struct i2c_client *client, unsigned int cmd, /* ----------------------------------------------------------------------- */ static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "i2c saa6588 driver", + .driver = { + .name = "saa6588", + }, .id = -1, /* FIXME */ - .flags = I2C_DF_NOTIFY, .attach_adapter = saa6588_probe, .detach_client = saa6588_detach, .command = saa6588_command, @@ -508,7 +498,6 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { .name = "saa6588", - .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, };