diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2008-01-06 13:31:35 -0500 |
---|---|---|
committer | Michael Krufky <mkrufky@linuxtv.org> | 2008-01-06 13:31:35 -0500 |
commit | ef15cd3c577cdc80d27bbd6ee72c2a9c991cd270 (patch) | |
tree | dbd00ca94191319ec2870480598ada94b182d791 /linux | |
parent | 407b62c662853ae567acabbecf5712d00f5b8fd2 (diff) | |
download | mediapointer-dvb-s2-ef15cd3c577cdc80d27bbd6ee72c2a9c991cd270.tar.gz mediapointer-dvb-s2-ef15cd3c577cdc80d27bbd6ee72c2a9c991cd270.tar.bz2 |
tda18271: use a mutex to protect state in critical sections
From: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Diffstat (limited to 'linux')
-rw-r--r-- | linux/drivers/media/dvb/frontends/tda18271-fe.c | 20 | ||||
-rw-r--r-- | linux/drivers/media/dvb/frontends/tda18271-priv.h | 12 |
2 files changed, 32 insertions, 0 deletions
diff --git a/linux/drivers/media/dvb/frontends/tda18271-fe.c b/linux/drivers/media/dvb/frontends/tda18271-fe.c index 3af6ddb1b..26352716a 100644 --- a/linux/drivers/media/dvb/frontends/tda18271-fe.c +++ b/linux/drivers/media/dvb/frontends/tda18271-fe.c @@ -622,26 +622,36 @@ static int tda18271_init(struct dvb_frontend *fe) { struct tda18271_priv *priv = fe->tuner_priv; + mutex_lock(&priv->lock); + /* initialization */ tda18271_ir_cal_init(fe); if (priv->id == TDA18271HDC2) tda18271_rf_cal_init(fe); + mutex_unlock(&priv->lock); + return 0; } static int tda18271c2_tune(struct dvb_frontend *fe, u32 ifc, u32 freq, u32 bw, u8 std) { + struct tda18271_priv *priv = fe->tuner_priv; + tda_dbg("freq = %d, ifc = %d\n", freq, ifc); tda18271_init(fe); + mutex_lock(&priv->lock); + tda18271_rf_tracking_filters_correction(fe, freq); tda18271_channel_configuration(fe, ifc, freq, bw, std); + mutex_unlock(&priv->lock); + return 0; } @@ -655,6 +665,8 @@ static int tda18271c1_tune(struct dvb_frontend *fe, u32 N = 0; tda18271_init(fe); + + mutex_lock(&priv->lock); #if 0 /* FIXME: FM Radio support */ if (t->mode == V4L2_TUNER_RADIO) @@ -795,6 +807,7 @@ static int tda18271c1_tune(struct dvb_frontend *fe, tda18271_write_regs(fe, R_TM, 15); msleep(5); + mutex_unlock(&priv->lock); return 0; } @@ -1051,7 +1064,9 @@ static int tda18271_get_id(struct dvb_frontend *fe) char *name; int ret = 0; + mutex_lock(&priv->lock); tda18271_read_regs(fe); + mutex_unlock(&priv->lock); switch (regs[R_ID] & 0x7f) { case 3: @@ -1104,6 +1119,7 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, priv->i2c_adap = i2c; priv->gate = (cfg) ? cfg->gate : TDA18271_GATE_AUTO; priv->cal_initialized = false; + mutex_init(&priv->lock); fe->tuner_priv = priv; @@ -1123,8 +1139,12 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, if (tda18271_debug & DBG_MAP) tda18271_dump_std_map(fe); + mutex_lock(&priv->lock); + tda18271_init_regs(fe); + mutex_unlock(&priv->lock); + return fe; fail: tda18271_release(fe); diff --git a/linux/drivers/media/dvb/frontends/tda18271-priv.h b/linux/drivers/media/dvb/frontends/tda18271-priv.h index b4d1ab770..5eaa0462b 100644 --- a/linux/drivers/media/dvb/frontends/tda18271-priv.h +++ b/linux/drivers/media/dvb/frontends/tda18271-priv.h @@ -23,6 +23,12 @@ #include <linux/kernel.h> #include <linux/types.h> +#include "compat.h" +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#include <linux/mutex.h> +#else +#include <asm/semaphore.h> +#endif #include "tda18271.h" #define R_ID 0x00 /* ID byte */ @@ -112,6 +118,12 @@ struct tda18271_priv { struct tda18271_std_map std; struct tda18271_rf_tracking_filter_cal rf_cal_state[8]; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + struct mutex lock; +#else + struct semaphore lock; +#endif + u32 frequency; u32 bandwidth; }; |