Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=8d316bf54b2a1965f9460d0ad9d80850d2c7afb3
Commit:     8d316bf54b2a1965f9460d0ad9d80850d2c7afb3
Parent:     ccbac9bb174db457181f5f58fecf9cbc3020ea1d
Author:     Michael Krufky <[EMAIL PROTECTED]>
AuthorDate: Sun Jan 6 15:31:35 2008 -0300
Committer:  Mauro Carvalho Chehab <[EMAIL PROTECTED]>
CommitDate: Fri Jan 25 19:04:43 2008 -0200

    V4L/DVB (6979): tda18271: use a mutex to protect state in critical sections
    
    Signed-off-by: Michael Krufky <[EMAIL PROTECTED]>
    Signed-off-by: Mauro Carvalho Chehab <[EMAIL PROTECTED]>
---
 drivers/media/dvb/frontends/tda18271-fe.c   |   20 ++++++++++++++++++++
 drivers/media/dvb/frontends/tda18271-priv.h |    3 +++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/media/dvb/frontends/tda18271-fe.c 
b/drivers/media/dvb/frontends/tda18271-fe.c
index c1da16a..e860f4c 100644
--- a/drivers/media/dvb/frontends/tda18271-fe.c
+++ b/drivers/media/dvb/frontends/tda18271-fe.c
@@ -598,26 +598,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;
 }
 
@@ -632,6 +642,8 @@ static int tda18271c1_tune(struct dvb_frontend *fe,
 
        tda18271_init(fe);
 
+       mutex_lock(&priv->lock);
+
        tda_dbg("freq = %d, ifc = %d\n", freq, ifc);
 
        /* RF tracking filter calibration */
@@ -766,6 +778,7 @@ static int tda18271c1_tune(struct dvb_frontend *fe,
 
        tda18271_write_regs(fe, R_TM, 15);
        msleep(5);
+       mutex_unlock(&priv->lock);
 
        return 0;
 }
@@ -1012,7 +1025,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:
@@ -1065,6 +1080,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;
 
@@ -1084,8 +1100,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/drivers/media/dvb/frontends/tda18271-priv.h 
b/drivers/media/dvb/frontends/tda18271-priv.h
index b4d1ab7..af89cfa 100644
--- a/drivers/media/dvb/frontends/tda18271-priv.h
+++ b/drivers/media/dvb/frontends/tda18271-priv.h
@@ -23,6 +23,7 @@
 
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <linux/mutex.h>
 #include "tda18271.h"
 
 #define R_ID     0x00  /* ID byte                */
@@ -112,6 +113,8 @@ struct tda18271_priv {
        struct tda18271_std_map std;
        struct tda18271_rf_tracking_filter_cal rf_cal_state[8];
 
+       struct mutex lock;
+
        u32 frequency;
        u32 bandwidth;
 };
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to