X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmedia%2Fvideo%2Fbttv-i2c.c;h=c2368bc832edc248978cb646218184da59d0b4bc;hb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;hp=1315c499cac5e963f6de8c7f3220a0d175b33713;hpb=e3f6fb6212a7102bdb56ba38fa1e98fe72950475;p=linux-2.6.git diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c index 1315c499c..c2368bc83 100644 --- a/drivers/media/video/bttv-i2c.c +++ b/drivers/media/video/bttv-i2c.c @@ -1,5 +1,5 @@ /* - $Id: bttv-i2c.c,v 1.17 2004/12/14 15:33:30 kraxel Exp $ + $Id: bttv-i2c.c,v 1.18 2005/02/16 12:14:10 kraxel Exp $ bttv-i2c.c -- all the i2c code is here @@ -29,6 +29,7 @@ #include #include #include +#include #include #include "bttvp.h" @@ -39,7 +40,6 @@ static struct i2c_adapter bttv_i2c_adap_hw_template; static struct i2c_client bttv_i2c_client_template; static int attach_inform(struct i2c_client *client); -static int detach_inform(struct i2c_client *client); static int i2c_debug = 0; static int i2c_hw = 0; @@ -112,7 +112,6 @@ static struct i2c_adapter bttv_i2c_adap_sw_template = { I2C_DEVNAME("bt848"), .id = I2C_HW_B_BT848, .client_register = attach_inform, - .client_unregister = detach_inform, }; /* ----------------------------------------------------------------------- */ @@ -132,17 +131,14 @@ static u32 functionality(struct i2c_adapter *adap) static int bttv_i2c_wait_done(struct bttv *btv) { - DECLARE_WAITQUEUE(wait, current); int rc = 0; - add_wait_queue(&btv->i2c_queue, &wait); - if (0 == btv->i2c_done) - msleep_interruptible(20); - remove_wait_queue(&btv->i2c_queue, &wait); + /* timeout */ + if (wait_event_interruptible_timeout(btv->i2c_queue, + btv->i2c_done, msecs_to_jiffies(85)) == -ERESTARTSYS) + + rc = -EIO; - if (0 == btv->i2c_done) - /* timeout */ - rc = -EIO; if (btv->i2c_done & BT848_INT_RACK) rc = 1; btv->i2c_done = 0; @@ -245,7 +241,7 @@ bttv_i2c_readbytes(struct bttv *btv, const struct i2c_msg *msg, int last) return retval; } -static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num) +static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) { struct bttv *btv = i2c_get_adapdata(i2c_adap); int retval = 0; @@ -290,7 +286,6 @@ static struct i2c_adapter bttv_i2c_adap_hw_template = { .id = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */, .algo = &bttv_algo, .client_register = attach_inform, - .client_unregister = detach_inform, }; /* ----------------------------------------------------------------------- */ @@ -305,22 +300,12 @@ static int attach_inform(struct i2c_client *client) if (btv->pinnacle_id != UNSET) bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE, &btv->pinnacle_id); - bttv_i2c_info(&btv->c, client, 1); - if (bttv_debug) printk("bttv%d: i2c attach [client=%s]\n", btv->c.nr, i2c_clientname(client)); return 0; } -static int detach_inform(struct i2c_client *client) -{ - struct bttv *btv = i2c_get_adapdata(client->adapter); - - bttv_i2c_info(&btv->c, client, 0); - return 0; -} - void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg) { if (0 != btv->i2c_rc) @@ -330,7 +315,6 @@ void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg) static struct i2c_client bttv_i2c_client_template = { I2C_DEVNAME("bttv internal"), - .id = -1, }; @@ -379,6 +363,9 @@ int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1, /* read EEPROM content */ void __devinit bttv_readee(struct bttv *btv, unsigned char *eedata, int addr) { + memset(eedata, 0, 256); + if (0 != btv->i2c_rc) + return; btv->i2c_client.addr = addr >> 1; tveeprom_read(&btv->i2c_client, eedata, 256); }