summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/frontends/nxt6000.c
diff options
context:
space:
mode:
authorMichael Hunold <devnull@localhost>2003-11-12 15:41:40 +0000
committerMichael Hunold <devnull@localhost>2003-11-12 15:41:40 +0000
commit3279255983a55caff933d0615483aa8874427bbf (patch)
treeb269ebc91c6ab105ea49a7ab20a46eb0a2d292b6 /linux/drivers/media/dvb/frontends/nxt6000.c
parentda48ce1d7d928d7fe5d427835eca2ac989d0a094 (diff)
downloadmediapointer-dvb-s2-3279255983a55caff933d0615483aa8874427bbf.tar.gz
mediapointer-dvb-s2-3279255983a55caff933d0615483aa8874427bbf.tar.bz2
- use per i2c-adapater void pointer for private data in nxt_attach() / nxt_detach()
feedback appreciated!
Diffstat (limited to 'linux/drivers/media/dvb/frontends/nxt6000.c')
-rw-r--r--linux/drivers/media/dvb/frontends/nxt6000.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/linux/drivers/media/dvb/frontends/nxt6000.c b/linux/drivers/media/dvb/frontends/nxt6000.c
index 1a9d7a369..4d90e3291 100644
--- a/linux/drivers/media/dvb/frontends/nxt6000.c
+++ b/linux/drivers/media/dvb/frontends/nxt6000.c
@@ -700,57 +700,72 @@ static int nxt6000_attach(struct dvb_i2c_bus *i2c, void **data)
{
u8 addr_nr;
u8 fe_count = 0;
- struct nxt6000_config nxt;
+ struct nxt6000_config *pnxt;
dprintk("nxt6000: attach\n");
+ pnxt = kmalloc(sizeof(demod_addr_tbl)*sizeof(struct nxt6000_config), GFP_KERNEL);
+ if (NULL == pnxt) {
+ dprintk("nxt6000: no memory for private data.\n");
+ return -ENOMEM;
+ }
+ *data = pnxt;
+
for (addr_nr = 0; addr_nr < sizeof(demod_addr_tbl); addr_nr++) {
+ struct nxt6000_config *nxt = &pnxt[addr_nr];
if (nxt6000_read(i2c, demod_addr_tbl[addr_nr], OFDM_MSC_REV) != NXT6000ASICDEVICE)
continue;
if (pll_write(i2c, demod_addr_tbl[addr_nr], 0xC0, NULL, 0) == 0) {
- nxt.tuner_addr = 0xC0;
- nxt.tuner_type = TUNER_TYPE_ALP510;
- nxt.clock_inversion = 1;
+ nxt->tuner_addr = 0xC0;
+ nxt->tuner_type = TUNER_TYPE_ALP510;
+ nxt->clock_inversion = 1;
- dprintk("nxt6000: detected TI ALP510 tuner at 0x%02X\n", nxt.tuner_addr);
+ dprintk("nxt6000: detected TI ALP510 tuner at 0x%02X\n", nxt->tuner_addr);
} else if (pll_write(i2c, demod_addr_tbl[addr_nr], 0xC2, NULL, 0) == 0) {
- nxt.tuner_addr = 0xC2;
- nxt.tuner_type = TUNER_TYPE_SP5659;
- nxt.clock_inversion = 0;
+ nxt->tuner_addr = 0xC2;
+ nxt->tuner_type = TUNER_TYPE_SP5659;
+ nxt->clock_inversion = 0;
- dprintk("nxt6000: detected MITEL SP5659 tuner at 0x%02X\n", nxt.tuner_addr);
+ dprintk("nxt6000: detected MITEL SP5659 tuner at 0x%02X\n", nxt->tuner_addr);
} else if (pll_write(i2c, demod_addr_tbl[addr_nr], 0xC0, NULL, 0) == 0) {
- nxt.tuner_addr = 0xC0;
- nxt.tuner_type = TUNER_TYPE_SP5730;
- nxt.clock_inversion = 0;
+ nxt->tuner_addr = 0xC0;
+ nxt->tuner_type = TUNER_TYPE_SP5730;
+ nxt->clock_inversion = 0;
- dprintk("nxt6000: detected SP5730 tuner at 0x%02X\n", nxt.tuner_addr);
+ dprintk("nxt6000: detected SP5730 tuner at 0x%02X\n", nxt->tuner_addr);
} else {
printk("nxt6000: unable to detect tuner\n");
continue;
}
- nxt.demod_addr = demod_addr_tbl[addr_nr];
+ nxt->demod_addr = demod_addr_tbl[addr_nr];
dprintk("nxt6000: attached at %d:%d\n", i2c->adapter->num, i2c->id);
- dvb_register_frontend(nxt6000_ioctl, i2c, (void *) (*((u32 *) & nxt)), &nxt6000_info);
+ dvb_register_frontend(nxt6000_ioctl, i2c, (void *)nxt, &nxt6000_info);
fe_count++;
}
- return (fe_count > 0) ? 0 : -ENODEV;
+ if (fe_count == 0) {
+ kfree(pnxt);
+ return -ENODEV;
+ }
+
+ return 0;
}
static void nxt6000_detach(struct dvb_i2c_bus *i2c, void *data)
{
+ struct nxt6000_config *pnxt = (struct nxt6000_config *)data;
dprintk("nxt6000: detach\n");
dvb_unregister_frontend(nxt6000_ioctl, i2c);
+ kfree(pnxt);
}
static __init int nxt6000_init(void)