diff options
Diffstat (limited to 'linux/drivers/media/dvb/frontends/ves1x93.c')
-rw-r--r-- | linux/drivers/media/dvb/frontends/ves1x93.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/linux/drivers/media/dvb/frontends/ves1x93.c b/linux/drivers/media/dvb/frontends/ves1x93.c index 7b36065a4..5162c3c46 100644 --- a/linux/drivers/media/dvb/frontends/ves1x93.c +++ b/linux/drivers/media/dvb/frontends/ves1x93.c @@ -115,6 +115,7 @@ static u8 init_1993_wtab[] = struct ves1x93_state { fe_spectral_inversion_t inversion; struct i2c_adapter *i2c; + struct dvb_adapter *dvb; }; @@ -588,7 +589,8 @@ static int attach_adapter(struct i2c_adapter *adapter) struct i2c_client *client; struct ves1x93_state* state; u8 identity = ves1x93_readreg(adapter, 0x1e); - + int ret; + switch (identity) { case 0xdc: /* VES1893A rev1 */ printk("ves1x93: Detected ves1893a rev1\n"); @@ -627,17 +629,29 @@ static int attach_adapter(struct i2c_adapter *adapter) client->addr = (0x08>>1); i2c_set_clientdata(client, (void*)state); - if (0 != i2c_attach_client(client)) { + ret = i2c_attach_client(client); + if (ret) { + kfree(client); + kfree(state); + return -EFAULT; + } + + BUG_ON(state->dvb); + + ret = dvb_register_frontend_new (ves1x93_ioctl, state->dvb, (void*) state, &ves1x93_info); + if (ret) { + i2c_detach_client(client); kfree(client); kfree(state); return -EFAULT; } + return 0; } static int detach_client(struct i2c_client *client) { - struct ves1x93_state *data = (struct ves1x93_state*)i2c_get_clientdata(client); + struct ves1x93_state *state = (struct ves1x93_state*)i2c_get_clientdata(client); i2c_detach_client(client); kfree(client); kfree(state); @@ -646,17 +660,17 @@ static int detach_client(struct i2c_client *client) static int command (struct i2c_client *client, unsigned int cmd, void *arg) { + struct ves1x93_state *state = (struct ves1x93_state*)i2c_get_clientdata(client); + dprintk ("%s\n", __FUNCTION__); switch (cmd) { case FE_REGISTER: { - struct dvb_adapter *dvb_adapter = (struct dvb_adapter*)arg; - struct ves1x93_state *data = (struct ves1x93_state*)i2c_get_clientdata(client); - return dvb_register_frontend_new (ves1x93_ioctl, dvb_adapter, (void*) data, &ves1x93_info); + state->dvb = (struct dvb_adapter*)arg; + break; } case FE_UNREGISTER: { - struct dvb_adapter *dvb_adapter = (struct dvb_adapter*)arg; - dvb_unregister_frontend_new (ves1x93_ioctl, dvb_adapter); + state->dvb = NULL; break; } default: |