V4L/DVB (8951): xc5000: dont pass devptr in xc5000_attach()
Dont pass devptr in xc5000_attach, dont store it in xc5000_priv. This pointer is passed into the tuner_callback function, which always expects a pointer to fe->dvb->priv or i2c_adapter->algo_data. This prevents future possible bugs in new drivers, such as using a "devptr" other that the standard fe->dvb->priv in a DVB driver. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
2a6003c207
commit
3065096190
|
@ -59,7 +59,6 @@ struct xc5000_priv {
|
||||||
u8 video_standard;
|
u8 video_standard;
|
||||||
u8 rf_mode;
|
u8 rf_mode;
|
||||||
|
|
||||||
void *devptr;
|
|
||||||
int (*tuner_callback) (void *priv, int command, int arg);
|
int (*tuner_callback) (void *priv, int command, int arg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -234,7 +233,10 @@ static void xc5000_TunerReset(struct dvb_frontend *fe)
|
||||||
dprintk(1, "%s()\n", __func__);
|
dprintk(1, "%s()\n", __func__);
|
||||||
|
|
||||||
if (priv->tuner_callback) {
|
if (priv->tuner_callback) {
|
||||||
ret = priv->tuner_callback(priv->devptr, XC5000_TUNER_RESET, 0);
|
ret = priv->tuner_callback(((fe->dvb) && (fe->dvb->priv)) ?
|
||||||
|
fe->dvb->priv :
|
||||||
|
priv->i2c_props.adap->algo_data,
|
||||||
|
XC5000_TUNER_RESET, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
printk(KERN_ERR "xc5000: reset failed\n");
|
printk(KERN_ERR "xc5000: reset failed\n");
|
||||||
} else
|
} else
|
||||||
|
@ -950,7 +952,7 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = {
|
||||||
|
|
||||||
struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
|
struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
|
||||||
struct i2c_adapter *i2c,
|
struct i2c_adapter *i2c,
|
||||||
struct xc5000_config *cfg, void *devptr)
|
struct xc5000_config *cfg)
|
||||||
{
|
{
|
||||||
struct xc5000_priv *priv = NULL;
|
struct xc5000_priv *priv = NULL;
|
||||||
int instance;
|
int instance;
|
||||||
|
@ -972,7 +974,6 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
|
||||||
case 1:
|
case 1:
|
||||||
/* new tuner instance */
|
/* new tuner instance */
|
||||||
priv->bandwidth = BANDWIDTH_6_MHZ;
|
priv->bandwidth = BANDWIDTH_6_MHZ;
|
||||||
priv->devptr = devptr;
|
|
||||||
priv->if_khz = cfg->if_khz;
|
priv->if_khz = cfg->if_khz;
|
||||||
priv->tuner_callback = cfg->tuner_callback;
|
priv->tuner_callback = cfg->tuner_callback;
|
||||||
|
|
||||||
|
|
|
@ -49,13 +49,11 @@ struct xc5000_config {
|
||||||
(defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE))
|
(defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE))
|
||||||
extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe,
|
extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe,
|
||||||
struct i2c_adapter *i2c,
|
struct i2c_adapter *i2c,
|
||||||
struct xc5000_config *cfg,
|
struct xc5000_config *cfg);
|
||||||
void *devptr);
|
|
||||||
#else
|
#else
|
||||||
static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe,
|
static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe,
|
||||||
struct i2c_adapter *i2c,
|
struct i2c_adapter *i2c,
|
||||||
struct xc5000_config *cfg,
|
struct xc5000_config *cfg)
|
||||||
void *devptr)
|
|
||||||
{
|
{
|
||||||
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
|
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -358,9 +358,8 @@ int au0828_dvb_register(struct au0828_dev *dev)
|
||||||
&hauppauge_hvr950q_config,
|
&hauppauge_hvr950q_config,
|
||||||
&dev->i2c_adap);
|
&dev->i2c_adap);
|
||||||
if (dvb->frontend != NULL)
|
if (dvb->frontend != NULL)
|
||||||
dvb_attach(xc5000_attach, dvb->frontend,
|
dvb_attach(xc5000_attach, dvb->frontend, &dev->i2c_adap,
|
||||||
&dev->i2c_adap,
|
&hauppauge_hvr950q_tunerconfig);
|
||||||
&hauppauge_hvr950q_tunerconfig, dev);
|
|
||||||
break;
|
break;
|
||||||
case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
|
case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
|
||||||
dvb->frontend = dvb_attach(au8522_attach,
|
dvb->frontend = dvb_attach(au8522_attach,
|
||||||
|
|
|
@ -390,8 +390,8 @@ static int dvb_register(struct cx23885_tsport *port)
|
||||||
&dev->i2c_bus[0].i2c_adap);
|
&dev->i2c_bus[0].i2c_adap);
|
||||||
if (port->dvb.frontend != NULL)
|
if (port->dvb.frontend != NULL)
|
||||||
dvb_attach(xc5000_attach, port->dvb.frontend,
|
dvb_attach(xc5000_attach, port->dvb.frontend,
|
||||||
&i2c_bus->i2c_adap,
|
&i2c_bus->i2c_adap,
|
||||||
&hauppauge_hvr1500q_tunerconfig, port);
|
&hauppauge_hvr1500q_tunerconfig);
|
||||||
break;
|
break;
|
||||||
case CX23885_BOARD_HAUPPAUGE_HVR1500:
|
case CX23885_BOARD_HAUPPAUGE_HVR1500:
|
||||||
i2c_bus = &dev->i2c_bus[1];
|
i2c_bus = &dev->i2c_bus[1];
|
||||||
|
@ -471,8 +471,8 @@ static int dvb_register(struct cx23885_tsport *port)
|
||||||
&i2c_bus->i2c_adap);
|
&i2c_bus->i2c_adap);
|
||||||
if (port->dvb.frontend != NULL)
|
if (port->dvb.frontend != NULL)
|
||||||
dvb_attach(xc5000_attach, port->dvb.frontend,
|
dvb_attach(xc5000_attach, port->dvb.frontend,
|
||||||
&i2c_bus->i2c_adap,
|
&i2c_bus->i2c_adap,
|
||||||
&dvico_xc5000_tunerconfig, port);
|
&dvico_xc5000_tunerconfig);
|
||||||
break;
|
break;
|
||||||
case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
|
case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
|
||||||
i2c_bus = &dev->i2c_bus[port->nr - 1];
|
i2c_bus = &dev->i2c_bus[port->nr - 1];
|
||||||
|
|
|
@ -813,13 +813,9 @@ static int dvb_register(struct cx8802_dev *dev)
|
||||||
&pinnacle_pctv_hd_800i_config,
|
&pinnacle_pctv_hd_800i_config,
|
||||||
&core->i2c_adap);
|
&core->i2c_adap);
|
||||||
if (dev->dvb.frontend != NULL) {
|
if (dev->dvb.frontend != NULL) {
|
||||||
/* tuner_config.video_dev must point to
|
|
||||||
* i2c_adap.algo_data
|
|
||||||
*/
|
|
||||||
if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
|
if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
|
||||||
&core->i2c_adap,
|
&core->i2c_adap,
|
||||||
&pinnacle_pctv_hd_800i_tuner_config,
|
&pinnacle_pctv_hd_800i_tuner_config))
|
||||||
core->i2c_adap.algo_data))
|
|
||||||
goto frontend_detach;
|
goto frontend_detach;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -874,13 +870,9 @@ static int dvb_register(struct cx8802_dev *dev)
|
||||||
&dvico_fusionhdtv7_config,
|
&dvico_fusionhdtv7_config,
|
||||||
&core->i2c_adap);
|
&core->i2c_adap);
|
||||||
if (dev->dvb.frontend != NULL) {
|
if (dev->dvb.frontend != NULL) {
|
||||||
/* tuner_config.video_dev must point to
|
|
||||||
* i2c_adap.algo_data
|
|
||||||
*/
|
|
||||||
if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
|
if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
|
||||||
&core->i2c_adap,
|
&core->i2c_adap,
|
||||||
&dvico_fusionhdtv7_tuner_config,
|
&dvico_fusionhdtv7_tuner_config))
|
||||||
core->i2c_adap.algo_data))
|
|
||||||
goto frontend_detach;
|
goto frontend_detach;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -452,8 +452,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
|
||||||
xc5000_cfg.if_khz = 5380;
|
xc5000_cfg.if_khz = 5380;
|
||||||
xc5000_cfg.tuner_callback = t->tuner_callback;
|
xc5000_cfg.tuner_callback = t->tuner_callback;
|
||||||
if (!dvb_attach(xc5000_attach,
|
if (!dvb_attach(xc5000_attach,
|
||||||
&t->fe, t->i2c->adapter, &xc5000_cfg,
|
&t->fe, t->i2c->adapter, &xc5000_cfg))
|
||||||
c->adapter->algo_data))
|
|
||||||
goto attach_failed;
|
goto attach_failed;
|
||||||
|
|
||||||
xc_tuner_ops = &t->fe.ops.tuner_ops;
|
xc_tuner_ops = &t->fe.ops.tuner_ops;
|
||||||
|
|
Loading…
Reference in New Issue