From b61589a51cc27a9785a2b6faa3541474c8fa1dfa Mon Sep 17 00:00:00 2001 From: Michael Hunold Date: Wed, 15 Sep 2004 16:50:17 +0000 Subject: This updates the cx22702 frontend driver: * make it ignore any non-dvb card i2c adapters. * fixup the registering / unregistering order and make it more robust. (Patch by Gerd Knorr) --- linux/drivers/media/dvb/frontends/cx22702.c | 36 ++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/linux/drivers/media/dvb/frontends/cx22702.c b/linux/drivers/media/dvb/frontends/cx22702.c index 53555ad44..ef5217a61 100644 --- a/linux/drivers/media/dvb/frontends/cx22702.c +++ b/linux/drivers/media/dvb/frontends/cx22702.c @@ -734,6 +734,12 @@ static int cx22702_attach_adapter(struct i2c_adapter *adapter) int minfreq; int pll_type; + if (0 == (adapter->class & I2C_CLASS_TV_DIGITAL)) { + dprintk("Ignoring adapter 0x%x:%s (no digital tv card).\n", + adapter->id, adapter->name); + return 0; + } + dprintk("Trying to attach to adapter 0x%x:%s.\n", adapter->id, adapter->name); @@ -780,17 +786,6 @@ static int cx22702_attach_adapter(struct i2c_adapter *adapter) kfree(state); return ret; } - - BUG_ON(!state->dvb); - - if ((ret = dvb_register_frontend(cx22702_ioctl, state->dvb, state, - &state->cx22702_info, THIS_MODULE))) { - i2c_detach_client(client); - kfree(client); - kfree(state); - return ret; - } - return 0; } @@ -798,9 +793,11 @@ static int cx22702_detach_client(struct i2c_client *client) { struct cx22702_state *state = i2c_get_clientdata(client); - dvb_unregister_frontend (cx22702_ioctl, state->dvb); + if (NULL != state->dvb) { + dvb_unregister_frontend (cx22702_ioctl, state->dvb); + state->dvb = NULL; + } i2c_detach_client(client); - BUG_ON(state->dvb); kfree(client); return 0; } @@ -808,12 +805,25 @@ static int cx22702_detach_client(struct i2c_client *client) static int command(struct i2c_client *client, unsigned int cmd, void *arg) { struct cx22702_state *state = i2c_get_clientdata(client); + int rc; switch(cmd) { case FE_REGISTER: + if (NULL != state->dvb) + break; state->dvb = arg; + rc = dvb_register_frontend(cx22702_ioctl, state->dvb, state, + &state->cx22702_info, THIS_MODULE); + if (0 != rc) { + printk("cx22702: dvb_register_frontend failed with rc=%d\n",rc); + state->dvb = NULL; + return rc; + } break; case FE_UNREGISTER: + if (NULL == state->dvb) + break; + dvb_unregister_frontend (cx22702_ioctl, state->dvb); state->dvb = NULL; break; default: -- cgit v1.2.3