summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb
diff options
context:
space:
mode:
authorMichael Hunold <devnull@localhost>2004-06-22 14:04:02 +0000
committerMichael Hunold <devnull@localhost>2004-06-22 14:04:02 +0000
commita7d61cec0fe82e1604c968a62bef0f310dd60c74 (patch)
treebcf69f9d349b050bfa5f575d9382f6ca09345d11 /linux/drivers/media/dvb
parent2ab054a9059005e514cd10e7c546dda722191c05 (diff)
downloadmediapointer-dvb-s2-a7d61cec0fe82e1604c968a62bef0f310dd60c74.tar.gz
mediapointer-dvb-s2-a7d61cec0fe82e1604c968a62bef0f310dd60c74.tar.bz2
- more kernel i2c cleanups
Diffstat (limited to 'linux/drivers/media/dvb')
-rw-r--r--linux/drivers/media/dvb/frontends/alps_tdlb7.c3
-rw-r--r--linux/drivers/media/dvb/frontends/stv0299.c31
-rw-r--r--linux/drivers/media/dvb/frontends/ves1x93.c30
3 files changed, 47 insertions, 17 deletions
diff --git a/linux/drivers/media/dvb/frontends/alps_tdlb7.c b/linux/drivers/media/dvb/frontends/alps_tdlb7.c
index bf9f8382f..ff3cfe3e6 100644
--- a/linux/drivers/media/dvb/frontends/alps_tdlb7.c
+++ b/linux/drivers/media/dvb/frontends/alps_tdlb7.c
@@ -648,18 +648,19 @@ static int attach_adapter(struct i2c_adapter *adapter)
ret = sp8870_firmware_upload(adapter, fw);
if (ret) {
printk("tdlb7: writing firmware to device failed\n");
+ release_firmware(fw);
goto out;
}
ret = dvb_register_frontend_new (tdlb7_ioctl, state->dvb, (void*) state, &tdlb7_info);
if (ret) {
printk("tdlb7: registering frontend to dvb-core failed.\n");
+ release_firmware(fw);
goto out;
}
return 0;
out:
- release_firmware(fw);
i2c_detach_client(client);
kfree(client);
kfree(state);
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:
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: