diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2008-05-10 13:34:09 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-05-14 01:56:46 -0400 |
commit | 48723543aff1f46091840222490ded5fe09c0e37 (patch) | |
tree | ce076b78ecae43f7ae22849277db6d496780cc8b /drivers/media/common | |
parent | 07c87a833e9ef92280ed24ab85cd4eb49cbca9c0 (diff) |
V4L/DVB (7893): xc5000: bug-fix: allow multiple devices in a single system
The current code passes a context pointer in the xc5000_config struct.
This context pointer is used in the tuner_callback function, used to
reset the device after firmware download.
The xc5000_config struct is a static structure, whose .priv member was
being assigned before calling xc5000_attach(). If there are more than
one of the same device type installed on a single system, the last one
to assign xc5000_config.priv will "win", and all others will cease to
function properly.
This patch passes the context pointer in xc5000_attach() rather that
storing it within the static struct xc5000_config.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/common')
-rw-r--r-- | drivers/media/common/tuners/xc5000.c | 9 | ||||
-rw-r--r-- | drivers/media/common/tuners/xc5000.h | 22 | ||||
-rw-r--r-- | drivers/media/common/tuners/xc5000_priv.h | 2 |
3 files changed, 19 insertions, 14 deletions
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c index 43d35bdb221f..ceae6db901ec 100644 --- a/drivers/media/common/tuners/xc5000.c +++ b/drivers/media/common/tuners/xc5000.c | |||
@@ -212,7 +212,7 @@ static void xc5000_TunerReset(struct dvb_frontend *fe) | |||
212 | dprintk(1, "%s()\n", __func__); | 212 | dprintk(1, "%s()\n", __func__); |
213 | 213 | ||
214 | if (priv->cfg->tuner_callback) { | 214 | if (priv->cfg->tuner_callback) { |
215 | ret = priv->cfg->tuner_callback(priv->cfg->priv, | 215 | ret = priv->cfg->tuner_callback(priv->devptr, |
216 | XC5000_TUNER_RESET, 0); | 216 | XC5000_TUNER_RESET, 0); |
217 | if (ret) | 217 | if (ret) |
218 | printk(KERN_ERR "xc5000: reset failed\n"); | 218 | printk(KERN_ERR "xc5000: reset failed\n"); |
@@ -900,9 +900,9 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = { | |||
900 | .get_status = xc5000_get_status | 900 | .get_status = xc5000_get_status |
901 | }; | 901 | }; |
902 | 902 | ||
903 | struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe, | 903 | struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, |
904 | struct i2c_adapter *i2c, | 904 | struct i2c_adapter *i2c, |
905 | struct xc5000_config *cfg) | 905 | struct xc5000_config *cfg, void *devptr) |
906 | { | 906 | { |
907 | struct xc5000_priv *priv = NULL; | 907 | struct xc5000_priv *priv = NULL; |
908 | u16 id = 0; | 908 | u16 id = 0; |
@@ -916,6 +916,7 @@ struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe, | |||
916 | priv->cfg = cfg; | 916 | priv->cfg = cfg; |
917 | priv->bandwidth = BANDWIDTH_6_MHZ; | 917 | priv->bandwidth = BANDWIDTH_6_MHZ; |
918 | priv->i2c = i2c; | 918 | priv->i2c = i2c; |
919 | priv->devptr = devptr; | ||
919 | 920 | ||
920 | /* Check if firmware has been loaded. It is possible that another | 921 | /* Check if firmware has been loaded. It is possible that another |
921 | instance of the driver has loaded the firmware. | 922 | instance of the driver has loaded the firmware. |
diff --git a/drivers/media/common/tuners/xc5000.h b/drivers/media/common/tuners/xc5000.h index 0ee80f9d19b8..c910715addc9 100644 --- a/drivers/media/common/tuners/xc5000.h +++ b/drivers/media/common/tuners/xc5000.h | |||
@@ -31,29 +31,31 @@ struct xc5000_config { | |||
31 | u8 i2c_address; | 31 | u8 i2c_address; |
32 | u32 if_khz; | 32 | u32 if_khz; |
33 | 33 | ||
34 | /* For each bridge framework, when it attaches either analog or digital, | ||
35 | * it has to store a reference back to its _core equivalent structure, | ||
36 | * so that it can service the hardware by steering gpio's etc. | ||
37 | * Each bridge implementation is different so cast priv accordingly. | ||
38 | * The xc5000 driver cares not for this value, other than ensuring | ||
39 | * it's passed back to a bridge during tuner_callback(). | ||
40 | */ | ||
41 | void *priv; | ||
42 | int (*tuner_callback) (void *priv, int command, int arg); | 34 | int (*tuner_callback) (void *priv, int command, int arg); |
43 | }; | 35 | }; |
44 | 36 | ||
45 | /* xc5000 callback command */ | 37 | /* xc5000 callback command */ |
46 | #define XC5000_TUNER_RESET 0 | 38 | #define XC5000_TUNER_RESET 0 |
47 | 39 | ||
40 | /* For each bridge framework, when it attaches either analog or digital, | ||
41 | * it has to store a reference back to its _core equivalent structure, | ||
42 | * so that it can service the hardware by steering gpio's etc. | ||
43 | * Each bridge implementation is different so cast devptr accordingly. | ||
44 | * The xc5000 driver cares not for this value, other than ensuring | ||
45 | * it's passed back to a bridge during tuner_callback(). | ||
46 | */ | ||
47 | |||
48 | #if defined(CONFIG_MEDIA_TUNER_XC5000) || \ | 48 | #if defined(CONFIG_MEDIA_TUNER_XC5000) || \ |
49 | (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) | 49 | (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) |
50 | extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, | 50 | extern 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); | ||
53 | #else | 54 | #else |
54 | static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, | 55 | static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, |
55 | struct i2c_adapter *i2c, | 56 | struct i2c_adapter *i2c, |
56 | struct xc5000_config *cfg) | 57 | struct xc5000_config *cfg, |
58 | void *devptr) | ||
57 | { | 59 | { |
58 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | 60 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
59 | return NULL; | 61 | return NULL; |
diff --git a/drivers/media/common/tuners/xc5000_priv.h b/drivers/media/common/tuners/xc5000_priv.h index 13b2d19341da..ecebfe4745ad 100644 --- a/drivers/media/common/tuners/xc5000_priv.h +++ b/drivers/media/common/tuners/xc5000_priv.h | |||
@@ -31,6 +31,8 @@ struct xc5000_priv { | |||
31 | u8 video_standard; | 31 | u8 video_standard; |
32 | u8 rf_mode; | 32 | u8 rf_mode; |
33 | u8 fwloaded; | 33 | u8 fwloaded; |
34 | |||
35 | void *devptr; | ||
34 | }; | 36 | }; |
35 | 37 | ||
36 | #endif | 38 | #endif |