aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2008-09-06 13:56:58 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 07:37:01 -0400
commit30650961907368b1077cade35455fe931b14da6b (patch)
treea27bbcb9319529b6d13da933adff4c069a12b853 /drivers
parent2a6003c20771ca16fc6386b5fd258df2f2fa8232 (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/common/tuners/xc5000.c9
-rw-r--r--drivers/media/common/tuners/xc5000.h6
-rw-r--r--drivers/media/video/au0828/au0828-dvb.c5
-rw-r--r--drivers/media/video/cx23885/cx23885-dvb.c8
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c12
-rw-r--r--drivers/media/video/tuner-core.c3
6 files changed, 16 insertions, 27 deletions
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c
index 72efc656ad0d..ccc4dae4126a 100644
--- a/drivers/media/common/tuners/xc5000.c
+++ b/drivers/media/common/tuners/xc5000.c
@@ -59,7 +59,6 @@ struct xc5000_priv {
59 u8 video_standard; 59 u8 video_standard;
60 u8 rf_mode; 60 u8 rf_mode;
61 61
62 void *devptr;
63 int (*tuner_callback) (void *priv, int command, int arg); 62 int (*tuner_callback) (void *priv, int command, int arg);
64}; 63};
65 64
@@ -234,7 +233,10 @@ static void xc5000_TunerReset(struct dvb_frontend *fe)
234 dprintk(1, "%s()\n", __func__); 233 dprintk(1, "%s()\n", __func__);
235 234
236 if (priv->tuner_callback) { 235 if (priv->tuner_callback) {
237 ret = priv->tuner_callback(priv->devptr, XC5000_TUNER_RESET, 0); 236 ret = priv->tuner_callback(((fe->dvb) && (fe->dvb->priv)) ?
237 fe->dvb->priv :
238 priv->i2c_props.adap->algo_data,
239 XC5000_TUNER_RESET, 0);
238 if (ret) 240 if (ret)
239 printk(KERN_ERR "xc5000: reset failed\n"); 241 printk(KERN_ERR "xc5000: reset failed\n");
240 } else 242 } else
@@ -950,7 +952,7 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = {
950 952
951struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, 953struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
952 struct i2c_adapter *i2c, 954 struct i2c_adapter *i2c,
953 struct xc5000_config *cfg, void *devptr) 955 struct xc5000_config *cfg)
954{ 956{
955 struct xc5000_priv *priv = NULL; 957 struct xc5000_priv *priv = NULL;
956 int instance; 958 int instance;
@@ -972,7 +974,6 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
972 case 1: 974 case 1:
973 /* new tuner instance */ 975 /* new tuner instance */
974 priv->bandwidth = BANDWIDTH_6_MHZ; 976 priv->bandwidth = BANDWIDTH_6_MHZ;
975 priv->devptr = devptr;
976 priv->if_khz = cfg->if_khz; 977 priv->if_khz = cfg->if_khz;
977 priv->tuner_callback = cfg->tuner_callback; 978 priv->tuner_callback = cfg->tuner_callback;
978 979
diff --git a/drivers/media/common/tuners/xc5000.h b/drivers/media/common/tuners/xc5000.h
index 5389f740945a..fa0321cfd179 100644
--- a/drivers/media/common/tuners/xc5000.h
+++ b/drivers/media/common/tuners/xc5000.h
@@ -49,13 +49,11 @@ struct xc5000_config {
49 (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) 49 (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE))
50extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, 50extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe,
51 struct i2c_adapter *i2c, 51 struct i2c_adapter *i2c,
52 struct xc5000_config *cfg, 52 struct xc5000_config *cfg);
53 void *devptr);
54#else 53#else
55static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, 54static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe,
56 struct i2c_adapter *i2c, 55 struct i2c_adapter *i2c,
57 struct xc5000_config *cfg, 56 struct xc5000_config *cfg)
58 void *devptr)
59{ 57{
60 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 58 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
61 return NULL; 59 return NULL;
diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c
index ba94be7e0ac1..96246959dce1 100644
--- a/drivers/media/video/au0828/au0828-dvb.c
+++ b/drivers/media/video/au0828/au0828-dvb.c
@@ -358,9 +358,8 @@ int au0828_dvb_register(struct au0828_dev *dev)
358 &hauppauge_hvr950q_config, 358 &hauppauge_hvr950q_config,
359 &dev->i2c_adap); 359 &dev->i2c_adap);
360 if (dvb->frontend != NULL) 360 if (dvb->frontend != NULL)
361 dvb_attach(xc5000_attach, dvb->frontend, 361 dvb_attach(xc5000_attach, dvb->frontend, &dev->i2c_adap,
362 &dev->i2c_adap, 362 &hauppauge_hvr950q_tunerconfig);
363 &hauppauge_hvr950q_tunerconfig, dev);
364 break; 363 break;
365 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL: 364 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
366 dvb->frontend = dvb_attach(au8522_attach, 365 dvb->frontend = dvb_attach(au8522_attach,
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
index b85cb39b101d..f462efde72ad 100644
--- a/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/drivers/media/video/cx23885/cx23885-dvb.c
@@ -390,8 +390,8 @@ static int dvb_register(struct cx23885_tsport *port)
390 &dev->i2c_bus[0].i2c_adap); 390 &dev->i2c_bus[0].i2c_adap);
391 if (port->dvb.frontend != NULL) 391 if (port->dvb.frontend != NULL)
392 dvb_attach(xc5000_attach, port->dvb.frontend, 392 dvb_attach(xc5000_attach, port->dvb.frontend,
393 &i2c_bus->i2c_adap, 393 &i2c_bus->i2c_adap,
394 &hauppauge_hvr1500q_tunerconfig, port); 394 &hauppauge_hvr1500q_tunerconfig);
395 break; 395 break;
396 case CX23885_BOARD_HAUPPAUGE_HVR1500: 396 case CX23885_BOARD_HAUPPAUGE_HVR1500:
397 i2c_bus = &dev->i2c_bus[1]; 397 i2c_bus = &dev->i2c_bus[1];
@@ -471,8 +471,8 @@ static int dvb_register(struct cx23885_tsport *port)
471 &i2c_bus->i2c_adap); 471 &i2c_bus->i2c_adap);
472 if (port->dvb.frontend != NULL) 472 if (port->dvb.frontend != NULL)
473 dvb_attach(xc5000_attach, port->dvb.frontend, 473 dvb_attach(xc5000_attach, port->dvb.frontend,
474 &i2c_bus->i2c_adap, 474 &i2c_bus->i2c_adap,
475 &dvico_xc5000_tunerconfig, port); 475 &dvico_xc5000_tunerconfig);
476 break; 476 break;
477 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: { 477 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
478 i2c_bus = &dev->i2c_bus[port->nr - 1]; 478 i2c_bus = &dev->i2c_bus[port->nr - 1];
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index d96173ff1dba..07270b77ed8a 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -813,13 +813,9 @@ static int dvb_register(struct cx8802_dev *dev)
813 &pinnacle_pctv_hd_800i_config, 813 &pinnacle_pctv_hd_800i_config,
814 &core->i2c_adap); 814 &core->i2c_adap);
815 if (dev->dvb.frontend != NULL) { 815 if (dev->dvb.frontend != NULL) {
816 /* tuner_config.video_dev must point to
817 * i2c_adap.algo_data
818 */
819 if (!dvb_attach(xc5000_attach, dev->dvb.frontend, 816 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
820 &core->i2c_adap, 817 &core->i2c_adap,
821 &pinnacle_pctv_hd_800i_tuner_config, 818 &pinnacle_pctv_hd_800i_tuner_config))
822 core->i2c_adap.algo_data))
823 goto frontend_detach; 819 goto frontend_detach;
824 } 820 }
825 break; 821 break;
@@ -874,13 +870,9 @@ static int dvb_register(struct cx8802_dev *dev)
874 &dvico_fusionhdtv7_config, 870 &dvico_fusionhdtv7_config,
875 &core->i2c_adap); 871 &core->i2c_adap);
876 if (dev->dvb.frontend != NULL) { 872 if (dev->dvb.frontend != NULL) {
877 /* tuner_config.video_dev must point to
878 * i2c_adap.algo_data
879 */
880 if (!dvb_attach(xc5000_attach, dev->dvb.frontend, 873 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
881 &core->i2c_adap, 874 &core->i2c_adap,
882 &dvico_fusionhdtv7_tuner_config, 875 &dvico_fusionhdtv7_tuner_config))
883 core->i2c_adap.algo_data))
884 goto frontend_detach; 876 goto frontend_detach;
885 } 877 }
886 break; 878 break;
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index d806a3556eed..39c7b9b835a3 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -452,8 +452,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
452 xc5000_cfg.if_khz = 5380; 452 xc5000_cfg.if_khz = 5380;
453 xc5000_cfg.tuner_callback = t->tuner_callback; 453 xc5000_cfg.tuner_callback = t->tuner_callback;
454 if (!dvb_attach(xc5000_attach, 454 if (!dvb_attach(xc5000_attach,
455 &t->fe, t->i2c->adapter, &xc5000_cfg, 455 &t->fe, t->i2c->adapter, &xc5000_cfg))
456 c->adapter->algo_data))
457 goto attach_failed; 456 goto attach_failed;
458 457
459 xc_tuner_ops = &t->fe.ops.tuner_ops; 458 xc_tuner_ops = &t->fe.ops.tuner_ops;