summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c
diff options
context:
space:
mode:
authorPatrick Boettcher <devnull@localhost>2004-12-29 20:27:55 +0000
committerPatrick Boettcher <devnull@localhost>2004-12-29 20:27:55 +0000
commitbfca54e0f0214c6c63dc8abdfe32b78a5d519285 (patch)
treef151fdfa1f0237e323a4fb20bbe9375a60870c5c /linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c
parent30205db98dfe86e6793fe1eb27acda2072264062 (diff)
downloadmediapointer-dvb-s2-bfca54e0f0214c6c63dc8abdfe32b78a5d519285.tar.gz
mediapointer-dvb-s2-bfca54e0f0214c6c63dc8abdfe32b78a5d519285.tar.bz2
init state added, clean init and exit of every part
Diffstat (limited to 'linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c')
-rw-r--r--linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c b/linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c
index dc60a6a92..1d5cecd6b 100644
--- a/linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c
+++ b/linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c
@@ -82,28 +82,29 @@ int dibusb_fe_init(struct usb_dibusb* dib)
struct dib3000_config demod_cfg;
int i;
- for (i = 0; i < sizeof(dib->dibdev->parm->demod_i2c_addrs) / sizeof(unsigned char) &&
- dib->dibdev->parm->demod_i2c_addrs[i] != 0; i++) {
-
- demod_cfg.demod_address = dib->dibdev->parm->demod_i2c_addrs[i];
- demod_cfg.pll_addr = dib->dibdev->parm->pll_addr;
- demod_cfg.pll_set = dib->dibdev->parm->pll_set;
- demod_cfg.pll_init = NULL;
-
- switch (dib->dibdev->parm->type) {
- case DIBUSB1_1:
- case DIBUSB1_1_AN2235:
- dib->fe = dib3000mb_attach(&demod_cfg,&dib->i2c_adap,&dib->xfer_ops);
- break;
- case DIBUSB2_0:
- dib->fe = dib3000mc_attach(&demod_cfg,&dib->i2c_adap,&dib->xfer_ops);
- break;
- }
- if (dib->fe != NULL) {
- info("found demodulator at i2c address 0x%x",demod_cfg.demod_address);
- break;
+ if (dib->init_state & DIBUSB_STATE_I2C)
+ for (i = 0; i < sizeof(dib->dibdev->parm->demod_i2c_addrs) / sizeof(unsigned char) &&
+ dib->dibdev->parm->demod_i2c_addrs[i] != 0; i++) {
+
+ demod_cfg.demod_address = dib->dibdev->parm->demod_i2c_addrs[i];
+ demod_cfg.pll_addr = dib->dibdev->parm->pll_addr;
+ demod_cfg.pll_set = dib->dibdev->parm->pll_set;
+ demod_cfg.pll_init = NULL;
+
+ switch (dib->dibdev->parm->type) {
+ case DIBUSB1_1:
+ case DIBUSB1_1_AN2235:
+ dib->fe = dib3000mb_attach(&demod_cfg,&dib->i2c_adap,&dib->xfer_ops);
+ break;
+ case DIBUSB2_0:
+ dib->fe = dib3000mc_attach(&demod_cfg,&dib->i2c_adap,&dib->xfer_ops);
+ break;
+ }
+ if (dib->fe != NULL) {
+ info("found demodulator at i2c address 0x%x",demod_cfg.demod_address);
+ break;
+ }
}
- }
if (dib->fe == NULL) {
err("A frontend driver was not found for device '%s'.",
@@ -148,13 +149,17 @@ int dibusb_i2c_init(struct usb_dibusb *dib)
if ((ret = i2c_add_adapter(&dib->i2c_adap)) < 0)
err("could not add i2c adapter");
-
+
+ dib->init_state |= DIBUSB_STATE_I2C;
+
return ret;
}
int dibusb_i2c_exit(struct usb_dibusb *dib)
{
- i2c_del_adapter(&dib->i2c_adap);
+ if (dib->init_state & DIBUSB_STATE_I2C)
+ i2c_del_adapter(&dib->i2c_adap);
+ dib->init_state &= ~DIBUSB_STATE_I2C;
return 0;
}