diff options
author | Michael Hunold <devnull@localhost> | 2004-06-22 14:04:02 +0000 |
---|---|---|
committer | Michael Hunold <devnull@localhost> | 2004-06-22 14:04:02 +0000 |
commit | a7d61cec0fe82e1604c968a62bef0f310dd60c74 (patch) | |
tree | bcf69f9d349b050bfa5f575d9382f6ca09345d11 /linux/drivers/media/dvb/frontends/stv0299.c | |
parent | 2ab054a9059005e514cd10e7c546dda722191c05 (diff) | |
download | mediapointer-dvb-s2-a7d61cec0fe82e1604c968a62bef0f310dd60c74.tar.gz mediapointer-dvb-s2-a7d61cec0fe82e1604c968a62bef0f310dd60c74.tar.bz2 |
- more kernel i2c cleanups
Diffstat (limited to 'linux/drivers/media/dvb/frontends/stv0299.c')
-rw-r--r-- | linux/drivers/media/dvb/frontends/stv0299.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/linux/drivers/media/dvb/frontends/stv0299.c b/linux/drivers/media/dvb/frontends/stv0299.c index cd63d9b7d..01c2fa948 100644 --- a/linux/drivers/media/dvb/frontends/stv0299.c +++ b/linux/drivers/media/dvb/frontends/stv0299.c @@ -111,6 +111,7 @@ struct stv0299_state { u32 symbol_rate; fe_code_rate_t fec_inner; struct i2c_adapter *i2c; + struct dvb_adapter *dvb; }; @@ -1343,6 +1344,7 @@ static int attach_adapter(struct i2c_adapter *adapter) struct i2c_client *client; struct stv0299_state* state; int tuner_type; + int ret; u8 id; stv0299_writereg(adapter, 0x02, 0x34); /* standby off */ @@ -1378,36 +1380,49 @@ static int attach_adapter(struct i2c_adapter *adapter) client->addr = (0x68>>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 (uni0299_ioctl, state->dvb, (void*) state, &uni0299_info); + if (ret) { + i2c_detach_client(client); kfree(client); kfree(state); return -EFAULT; } + return 0; } static int detach_client(struct i2c_client *client) { - struct stv0299_data *data = (struct stv0299_data*)i2c_get_clientdata(client); + struct stv0299_state *state = (struct stv0299_state*)i2c_get_clientdata(client); + + dvb_unregister_frontend_new (uni0299_ioctl, state->dvb); i2c_detach_client(client); kfree(client); - kfree(data); + kfree(state); return 0; } static int command (struct i2c_client *client, unsigned int cmd, void *arg) { + struct stv0299_state *data = (struct stv0299_state*)i2c_get_clientdata(client); dprintk ("%s\n", __FUNCTION__); switch (cmd) { case FE_REGISTER: { - struct dvb_adapter *dvb_adapter = (struct dvb_adapter*)arg; - struct stv0299_data *data = (struct stv0299_data*)i2c_get_clientdata(client); - return dvb_register_frontend_new (uni0299_ioctl, dvb_adapter, (void*) data, &uni0299_info); + data->dvb = (struct dvb_adapter*)arg; + break; } case FE_UNREGISTER: { - struct dvb_adapter *dvb_adapter = (struct dvb_adapter*)arg; - dvb_unregister_frontend_new (uni0299_ioctl, dvb_adapter); + data->dvb = NULL; break; } default: |