Commit 49bd4833 authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] Add private data pointer to DVB frontends

 - allow private data to be associated with dvb frontend devices
   (Andreas Oberritter)
 - fixed fe_count countint in nxt6000 frontend driver (Andreas
   Oberritter)
parent 7ddf4633
...@@ -32,8 +32,9 @@ ...@@ -32,8 +32,9 @@
struct dvb_i2c_device { struct dvb_i2c_device {
struct list_head list_head; struct list_head list_head;
struct module *owner; struct module *owner;
int (*attach) (struct dvb_i2c_bus *i2c); int (*attach) (struct dvb_i2c_bus *i2c, void **data);
void (*detach) (struct dvb_i2c_bus *i2c); void (*detach) (struct dvb_i2c_bus *i2c, void *data);
void *data;
}; };
LIST_HEAD(dvb_i2c_buslist); LIST_HEAD(dvb_i2c_buslist);
...@@ -66,7 +67,7 @@ static void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *d ...@@ -66,7 +67,7 @@ static void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *d
return; return;
} }
if (dev->attach (i2c) == 0) { if (dev->attach (i2c, &dev->data) == 0) {
register_i2c_client (i2c, dev); register_i2c_client (i2c, dev);
} else { } else {
if (dev->owner) if (dev->owner)
...@@ -77,7 +78,7 @@ static void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *d ...@@ -77,7 +78,7 @@ static void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *d
static void detach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) static void detach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev)
{ {
dev->detach (i2c); dev->detach (i2c, dev->data);
if (dev->owner) if (dev->owner)
module_put (dev->owner); module_put (dev->owner);
...@@ -229,8 +230,8 @@ void dvb_unregister_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c, ...@@ -229,8 +230,8 @@ void dvb_unregister_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
int dvb_register_i2c_device (struct module *owner, int dvb_register_i2c_device (struct module *owner,
int (*attach) (struct dvb_i2c_bus *i2c), int (*attach) (struct dvb_i2c_bus *i2c, void **data),
void (*detach) (struct dvb_i2c_bus *i2c)) void (*detach) (struct dvb_i2c_bus *i2c, void *data))
{ {
struct dvb_i2c_device *entry; struct dvb_i2c_device *entry;
...@@ -256,7 +257,7 @@ int dvb_register_i2c_device (struct module *owner, ...@@ -256,7 +257,7 @@ int dvb_register_i2c_device (struct module *owner,
} }
int dvb_unregister_i2c_device (int (*attach) (struct dvb_i2c_bus *i2c)) int dvb_unregister_i2c_device (int (*attach) (struct dvb_i2c_bus *i2c, void **data))
{ {
struct list_head *entry, *n; struct list_head *entry, *n;
......
...@@ -54,10 +54,10 @@ void dvb_unregister_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c, ...@@ -54,10 +54,10 @@ void dvb_unregister_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
extern int dvb_register_i2c_device (struct module *owner, extern int dvb_register_i2c_device (struct module *owner,
int (*attach) (struct dvb_i2c_bus *i2c), int (*attach) (struct dvb_i2c_bus *i2c, void **data),
void (*detach) (struct dvb_i2c_bus *i2c)); void (*detach) (struct dvb_i2c_bus *i2c, void *data));
extern int dvb_unregister_i2c_device (int (*attach) (struct dvb_i2c_bus *i2c)); extern int dvb_unregister_i2c_device (int (*attach) (struct dvb_i2c_bus *i2c, void **data));
#endif #endif
...@@ -402,7 +402,7 @@ static int tdmb7_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg) ...@@ -402,7 +402,7 @@ static int tdmb7_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
static int tdmb7_attach (struct dvb_i2c_bus *i2c) static int tdmb7_attach (struct dvb_i2c_bus *i2c, void **data)
{ {
struct i2c_msg msg = { .addr = 0x43, .flags = 0, .buf = NULL,. len = 0 }; struct i2c_msg msg = { .addr = 0x43, .flags = 0, .buf = NULL,. len = 0 };
...@@ -411,13 +411,11 @@ static int tdmb7_attach (struct dvb_i2c_bus *i2c) ...@@ -411,13 +411,11 @@ static int tdmb7_attach (struct dvb_i2c_bus *i2c)
if (i2c->xfer (i2c, &msg, 1) != 1) if (i2c->xfer (i2c, &msg, 1) != 1)
return -ENODEV; return -ENODEV;
dvb_register_frontend (tdmb7_ioctl, i2c, NULL, &tdmb7_info); return dvb_register_frontend (tdmb7_ioctl, i2c, NULL, &tdmb7_info);
return 0;
} }
static void tdmb7_detach (struct dvb_i2c_bus *i2c) static void tdmb7_detach (struct dvb_i2c_bus *i2c, void *data)
{ {
dprintk ("%s\n", __FUNCTION__); dprintk ("%s\n", __FUNCTION__);
......
...@@ -643,7 +643,7 @@ static int cx24110_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg) ...@@ -643,7 +643,7 @@ static int cx24110_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
} }
static int cx24110_attach (struct dvb_i2c_bus *i2c) static int cx24110_attach (struct dvb_i2c_bus *i2c, void **data)
{ {
u8 sig; u8 sig;
...@@ -651,13 +651,11 @@ static int cx24110_attach (struct dvb_i2c_bus *i2c) ...@@ -651,13 +651,11 @@ static int cx24110_attach (struct dvb_i2c_bus *i2c)
if ( sig != 0x5a && sig != 0x69 ) if ( sig != 0x5a && sig != 0x69 )
return -ENODEV; return -ENODEV;
dvb_register_frontend (cx24110_ioctl, i2c, NULL, &cx24110_info); return dvb_register_frontend (cx24110_ioctl, i2c, NULL, &cx24110_info);
return 0;
} }
static void cx24110_detach (struct dvb_i2c_bus *i2c) static void cx24110_detach (struct dvb_i2c_bus *i2c, void *data)
{ {
dvb_unregister_frontend (cx24110_ioctl, i2c); dvb_unregister_frontend (cx24110_ioctl, i2c);
} }
......
...@@ -173,14 +173,13 @@ static int dvbdummyfe_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *ar ...@@ -173,14 +173,13 @@ static int dvbdummyfe_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *ar
} }
static int dvbdummyfe_attach (struct dvb_i2c_bus *i2c) static int dvbdummyfe_attach (struct dvb_i2c_bus *i2c, void **data)
{ {
dvb_register_frontend (dvbdummyfe_ioctl, i2c, NULL, frontend_info()); return dvb_register_frontend (dvbdummyfe_ioctl, i2c, NULL, frontend_info());
return 0;
} }
static void dvbdummyfe_detach (struct dvb_i2c_bus *i2c) static void dvbdummyfe_detach (struct dvb_i2c_bus *i2c, void *data)
{ {
dvb_unregister_frontend (dvbdummyfe_ioctl, i2c); dvb_unregister_frontend (dvbdummyfe_ioctl, i2c);
} }
...@@ -191,14 +190,12 @@ static int __init init_dvbdummyfe (void) ...@@ -191,14 +190,12 @@ static int __init init_dvbdummyfe (void)
return dvb_register_i2c_device (THIS_MODULE, return dvb_register_i2c_device (THIS_MODULE,
dvbdummyfe_attach, dvbdummyfe_attach,
dvbdummyfe_detach); dvbdummyfe_detach);
return 0;
} }
static void __exit exit_dvbdummyfe (void) static void __exit exit_dvbdummyfe (void)
{ {
dvb_unregister_i2c_device (dvbdummyfe_attach); dvb_unregister_i2c_device (dvbdummyfe_attach);
return;
} }
......
...@@ -415,7 +415,7 @@ int grundig_29504_401_ioctl (struct dvb_frontend *fe, ...@@ -415,7 +415,7 @@ int grundig_29504_401_ioctl (struct dvb_frontend *fe,
} }
static int l64781_attach (struct dvb_i2c_bus *i2c) static int l64781_attach (struct dvb_i2c_bus *i2c, void **data)
{ {
u8 reg0x3e; u8 reg0x3e;
u8 b0 [] = { 0x1a }; u8 b0 [] = { 0x1a };
...@@ -465,9 +465,8 @@ static int l64781_attach (struct dvb_i2c_bus *i2c) ...@@ -465,9 +465,8 @@ static int l64781_attach (struct dvb_i2c_bus *i2c)
goto bailout; goto bailout;
} }
dvb_register_frontend (grundig_29504_401_ioctl, i2c, NULL, return dvb_register_frontend (grundig_29504_401_ioctl, i2c, NULL,
&grundig_29504_401_info); &grundig_29504_401_info);
return 0;
bailout: bailout:
l64781_writereg (i2c, 0x3e, reg0x3e); /* restore reg 0x3e */ l64781_writereg (i2c, 0x3e, reg0x3e); /* restore reg 0x3e */
...@@ -475,7 +474,8 @@ static int l64781_attach (struct dvb_i2c_bus *i2c) ...@@ -475,7 +474,8 @@ static int l64781_attach (struct dvb_i2c_bus *i2c)
} }
static void l64781_detach (struct dvb_i2c_bus *i2c)
static void l64781_detach (struct dvb_i2c_bus *i2c, void *data)
{ {
dvb_unregister_frontend (grundig_29504_401_ioctl, i2c); dvb_unregister_frontend (grundig_29504_401_ioctl, i2c);
} }
......
...@@ -433,19 +433,17 @@ static int grundig_29504_491_ioctl (struct dvb_frontend *fe, unsigned int cmd, ...@@ -433,19 +433,17 @@ static int grundig_29504_491_ioctl (struct dvb_frontend *fe, unsigned int cmd,
} }
static int tda8083_attach (struct dvb_i2c_bus *i2c) static int tda8083_attach (struct dvb_i2c_bus *i2c, void **data)
{ {
if ((tda8083_readreg (i2c, 0x00)) != 0x05) if ((tda8083_readreg (i2c, 0x00)) != 0x05)
return -ENODEV; return -ENODEV;
dvb_register_frontend (grundig_29504_491_ioctl, i2c, NULL, return dvb_register_frontend (grundig_29504_491_ioctl, i2c, NULL,
&grundig_29504_491_info); &grundig_29504_491_info);
return 0;
} }
static void tda8083_detach (struct dvb_i2c_bus *i2c) static void tda8083_detach (struct dvb_i2c_bus *i2c, void *data)
{ {
dvb_unregister_frontend (grundig_29504_491_ioctl, i2c); dvb_unregister_frontend (grundig_29504_491_ioctl, i2c);
} }
......
...@@ -714,7 +714,7 @@ static int mt312_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) ...@@ -714,7 +714,7 @@ static int mt312_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
return 0; return 0;
} }
static int mt312_attach(struct dvb_i2c_bus *i2c) static int mt312_attach(struct dvb_i2c_bus *i2c, void **data)
{ {
int ret; int ret;
u8 id; u8 id;
...@@ -734,7 +734,7 @@ static int mt312_attach(struct dvb_i2c_bus *i2c) ...@@ -734,7 +734,7 @@ static int mt312_attach(struct dvb_i2c_bus *i2c)
return 0; return 0;
} }
static void mt312_detach(struct dvb_i2c_bus *i2c) static void mt312_detach(struct dvb_i2c_bus *i2c, void *data)
{ {
dvb_unregister_frontend(mt312_ioctl, i2c); dvb_unregister_frontend(mt312_ioctl, i2c);
......
...@@ -829,7 +829,7 @@ static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) ...@@ -829,7 +829,7 @@ static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
static u8 demod_addr_tbl[] = {0x14, 0x18, 0x24, 0x28}; static u8 demod_addr_tbl[] = {0x14, 0x18, 0x24, 0x28};
static int nxt6000_attach(struct dvb_i2c_bus *i2c) static int nxt6000_attach(struct dvb_i2c_bus *i2c, void **data)
{ {
u8 addr_nr; u8 addr_nr;
...@@ -881,13 +881,14 @@ static int nxt6000_attach(struct dvb_i2c_bus *i2c) ...@@ -881,13 +881,14 @@ static int nxt6000_attach(struct dvb_i2c_bus *i2c)
dvb_register_frontend(nxt6000_ioctl, i2c, (void *)(*((u32 *)&nxt)), &nxt6000_info); dvb_register_frontend(nxt6000_ioctl, i2c, (void *)(*((u32 *)&nxt)), &nxt6000_info);
fe_count++;
} }
return (fe_count > 0) ? 0 : -ENODEV; return (fe_count > 0) ? 0 : -ENODEV;
} }
static void nxt6000_detach(struct dvb_i2c_bus *i2c) static void nxt6000_detach(struct dvb_i2c_bus *i2c, void *data)
{ {
dprintk("nxt6000: detach\n"); dprintk("nxt6000: detach\n");
......
...@@ -561,7 +561,7 @@ int sp887x_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg) ...@@ -561,7 +561,7 @@ int sp887x_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
static static
int sp887x_attach (struct dvb_i2c_bus *i2c) int sp887x_attach (struct dvb_i2c_bus *i2c, void **data)
{ {
struct i2c_msg msg = { addr: 0x70, flags: 0, buf: NULL, len: 0 }; struct i2c_msg msg = { addr: 0x70, flags: 0, buf: NULL, len: 0 };
...@@ -570,14 +570,12 @@ int sp887x_attach (struct dvb_i2c_bus *i2c) ...@@ -570,14 +570,12 @@ int sp887x_attach (struct dvb_i2c_bus *i2c)
if (i2c->xfer (i2c, &msg, 1) != 1) if (i2c->xfer (i2c, &msg, 1) != 1)
return -ENODEV; return -ENODEV;
dvb_register_frontend (sp887x_ioctl, i2c, NULL, &sp887x_info); return dvb_register_frontend (sp887x_ioctl, i2c, NULL, &sp887x_info);
return 0;
} }
static static
void sp887x_detach (struct dvb_i2c_bus *i2c) void sp887x_detach (struct dvb_i2c_bus *i2c, void *data)
{ {
dprintk ("%s\n", __FUNCTION__); dprintk ("%s\n", __FUNCTION__);
dvb_unregister_frontend (sp887x_ioctl, i2c); dvb_unregister_frontend (sp887x_ioctl, i2c);
......
...@@ -910,7 +910,7 @@ static long probe_tuner (struct dvb_i2c_bus *i2c) ...@@ -910,7 +910,7 @@ static long probe_tuner (struct dvb_i2c_bus *i2c)
} }
static int uni0299_attach (struct dvb_i2c_bus *i2c) static int uni0299_attach (struct dvb_i2c_bus *i2c, void **data)
{ {
long tuner_type; long tuner_type;
u8 id; u8 id;
...@@ -928,17 +928,14 @@ static int uni0299_attach (struct dvb_i2c_bus *i2c) ...@@ -928,17 +928,14 @@ static int uni0299_attach (struct dvb_i2c_bus *i2c)
if ((tuner_type = probe_tuner(i2c)) < 0) if ((tuner_type = probe_tuner(i2c)) < 0)
return -ENODEV; return -ENODEV;
dvb_register_frontend (uni0299_ioctl, i2c, (void*) tuner_type, return dvb_register_frontend (uni0299_ioctl, i2c, (void*) tuner_type,
&uni0299_info); &uni0299_info);
return 0;
} }
static void uni0299_detach (struct dvb_i2c_bus *i2c) static void uni0299_detach (struct dvb_i2c_bus *i2c, void *data)
{ {
dprintk ("%s\n", __FUNCTION__); dprintk ("%s\n", __FUNCTION__);
dvb_unregister_frontend (uni0299_ioctl, i2c); dvb_unregister_frontend (uni0299_ioctl, i2c);
} }
......
...@@ -1055,7 +1055,7 @@ static int tda1004x_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) ...@@ -1055,7 +1055,7 @@ static int tda1004x_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
} }
static int tda1004x_attach(struct dvb_i2c_bus *i2c) static int tda1004x_attach(struct dvb_i2c_bus *i2c, void **data)
{ {
int tda1004x_address = -1; int tda1004x_address = -1;
int tuner_address = -1; int tuner_address = -1;
...@@ -1113,17 +1113,15 @@ static int tda1004x_attach(struct dvb_i2c_bus *i2c) ...@@ -1113,17 +1113,15 @@ static int tda1004x_attach(struct dvb_i2c_bus *i2c)
// register // register
switch(tda_state.tda1004x_address) { switch(tda_state.tda1004x_address) {
case TDA10045H_ADDRESS: case TDA10045H_ADDRESS:
dvb_register_frontend(tda1004x_ioctl, i2c, (void *)(*((u32*) &tda_state)), &tda10045h_info); return dvb_register_frontend(tda1004x_ioctl, i2c, (void *)(*((u32*) &tda_state)), &tda10045h_info);
break; default:
return -ENODEV;
} }
// success
return 0;
} }
static static
void tda1004x_detach(struct dvb_i2c_bus *i2c) void tda1004x_detach(struct dvb_i2c_bus *i2c, void *data)
{ {
dprintk("%s\n", __FUNCTION__); dprintk("%s\n", __FUNCTION__);
......
...@@ -507,9 +507,9 @@ static long probe_demod_addr (struct dvb_i2c_bus *i2c) ...@@ -507,9 +507,9 @@ static long probe_demod_addr (struct dvb_i2c_bus *i2c)
} }
static int ves1820_attach (struct dvb_i2c_bus *i2c) static int ves1820_attach (struct dvb_i2c_bus *i2c, void **data)
{ {
void *data = NULL; void *priv = NULL;
long demod_addr; long demod_addr;
long tuner_type; long tuner_type;
...@@ -522,21 +522,19 @@ static int ves1820_attach (struct dvb_i2c_bus *i2c) ...@@ -522,21 +522,19 @@ static int ves1820_attach (struct dvb_i2c_bus *i2c)
if ((i2c->adapter->num < MAX_UNITS) && pwm[i2c->adapter->num] != -1) { if ((i2c->adapter->num < MAX_UNITS) && pwm[i2c->adapter->num] != -1) {
printk("DVB: VES1820(%d): pwm=0x%02x (user specified)\n", printk("DVB: VES1820(%d): pwm=0x%02x (user specified)\n",
i2c->adapter->num, pwm[i2c->adapter->num]); i2c->adapter->num, pwm[i2c->adapter->num]);
SET_PWM(data, pwm[i2c->adapter->num]); SET_PWM(priv, pwm[i2c->adapter->num]);
} }
else else
SET_PWM(data, read_pwm(i2c)); SET_PWM(priv, read_pwm(i2c));
SET_REG0(data, ves1820_inittab[0]); SET_REG0(priv, ves1820_inittab[0]);
SET_TUNER(data, tuner_type); SET_TUNER(priv, tuner_type);
SET_DEMOD_ADDR(data, demod_addr); SET_DEMOD_ADDR(priv, demod_addr);
dvb_register_frontend (ves1820_ioctl, i2c, data, &ves1820_info); return dvb_register_frontend (ves1820_ioctl, i2c, priv, &ves1820_info);
return 0;
} }
static void ves1820_detach (struct dvb_i2c_bus *i2c) static void ves1820_detach (struct dvb_i2c_bus *i2c, void *data)
{ {
dvb_unregister_frontend (ves1820_ioctl, i2c); dvb_unregister_frontend (ves1820_ioctl, i2c);
} }
......
...@@ -140,17 +140,15 @@ static int dec2000_frontend_ioctl(struct dvb_frontend *fe, unsigned int cmd, ...@@ -140,17 +140,15 @@ static int dec2000_frontend_ioctl(struct dvb_frontend *fe, unsigned int cmd,
return 0; return 0;
} }
static int dec2000_frontend_attach(struct dvb_i2c_bus *i2c) static int dec2000_frontend_attach(struct dvb_i2c_bus *i2c, void **data)
{ {
dprintk("%s\n", __FUNCTION__); dprintk("%s\n", __FUNCTION__);
dvb_register_frontend(dec2000_frontend_ioctl, i2c, NULL, return dvb_register_frontend(dec2000_frontend_ioctl, i2c, NULL,
&dec2000_frontend_info); &dec2000_frontend_info);
return 0;
} }
static void dec2000_frontend_detach(struct dvb_i2c_bus *i2c) static void dec2000_frontend_detach(struct dvb_i2c_bus *i2c, void *data)
{ {
dprintk("%s\n", __FUNCTION__); dprintk("%s\n", __FUNCTION__);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment