From fcdd8b3dcfb37977dd93730f2ad8e70e867bf881 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 29 Jun 2012 14:43:32 -0300 Subject: [PATCH] --- yaml --- r: 320066 b: refs/heads/master c: 20bfe7ae089076b0af72a6d67f0298621ae90a9d h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/media/dvb/frontends/drxk_hard.c | 29 +++++++++++++++++-- trunk/drivers/media/dvb/frontends/drxk_hard.h | 3 ++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index ad879e78e256..e2cb7efb1e14 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 2a5f6720ff45e7545c3058bc6bfdb498247b4f5c +refs/heads/master: 20bfe7ae089076b0af72a6d67f0298621ae90a9d diff --git a/trunk/drivers/media/dvb/frontends/drxk_hard.c b/trunk/drivers/media/dvb/frontends/drxk_hard.c index 5b3a17ce3d1d..87cb3f02ebc0 100644 --- a/trunk/drivers/media/dvb/frontends/drxk_hard.c +++ b/trunk/drivers/media/dvb/frontends/drxk_hard.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "dvb_frontend.h" @@ -308,10 +309,30 @@ static u32 Log10Times100(u32 x) /* I2C **********************************************************************/ /****************************************************************************/ +static int drxk_i2c_lock(struct drxk_state *state) +{ + i2c_lock_adapter(state->i2c); + state->drxk_i2c_exclusive_lock = true; + + return 0; +} + +static void drxk_i2c_unlock(struct drxk_state *state) +{ + if (!state->drxk_i2c_exclusive_lock) + return; + + i2c_unlock_adapter(state->i2c); + state->drxk_i2c_exclusive_lock = false; +} + static int drxk_i2c_transfer(struct drxk_state *state, struct i2c_msg *msgs, unsigned len) { - return i2c_transfer(state->i2c, msgs, len); + if (state->drxk_i2c_exclusive_lock) + return __i2c_transfer(state->i2c, msgs, len); + else + return i2c_transfer(state->i2c, msgs, len); } static int i2c_read1(struct drxk_state *state, u8 adr, u8 *val) @@ -5982,6 +6003,7 @@ static int init_drxk(struct drxk_state *state) dprintk(1, "\n"); if ((state->m_DrxkState == DRXK_UNINITIALIZED)) { + drxk_i2c_lock(state); status = PowerUpDevice(state); if (status < 0) goto error; @@ -6171,10 +6193,13 @@ static int init_drxk(struct drxk_state *state) strlcat(state->frontend.ops.info.name, " DVB-T", sizeof(state->frontend.ops.info.name)); } + drxk_i2c_unlock(state); } error: - if (status < 0) + if (status < 0) { + drxk_i2c_unlock(state); printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + } return status; } diff --git a/trunk/drivers/media/dvb/frontends/drxk_hard.h b/trunk/drivers/media/dvb/frontends/drxk_hard.h index 36677cdc01d8..c35ab2b37795 100644 --- a/trunk/drivers/media/dvb/frontends/drxk_hard.h +++ b/trunk/drivers/media/dvb/frontends/drxk_hard.h @@ -325,6 +325,9 @@ struct drxk_state { enum DRXPowerMode m_currentPowerMode; + /* when true, avoids other devices to use the I2C bus */ + bool drxk_i2c_exclusive_lock; + /* * Configurable parameters at the driver. They stores the values found * at struct drxk_config.