aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2012-06-29 13:43:32 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-06-29 18:04:21 -0400
commit20bfe7ae089076b0af72a6d67f0298621ae90a9d (patch)
tree27c5aab38bcc6c34917098004055a0db70b54142 /drivers
parent2a5f6720ff45e7545c3058bc6bfdb498247b4f5c (diff)
[media] drxk: Lock I2C bus during firmware load
Don't allow other devices at the same I2C bus to use it during firmware load, in order to prevent using the device while it is not on a sane state. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/dvb/frontends/drxk_hard.c29
-rw-r--r--drivers/media/dvb/frontends/drxk_hard.h3
2 files changed, 30 insertions, 2 deletions
diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c
index 5b3a17ce3d1d..87cb3f02ebc0 100644
--- a/drivers/media/dvb/frontends/drxk_hard.c
+++ b/drivers/media/dvb/frontends/drxk_hard.c
@@ -28,6 +28,7 @@
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/firmware.h> 29#include <linux/firmware.h>
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/hardirq.h>
31#include <asm/div64.h> 32#include <asm/div64.h>
32 33
33#include "dvb_frontend.h" 34#include "dvb_frontend.h"
@@ -308,10 +309,30 @@ static u32 Log10Times100(u32 x)
308/* I2C **********************************************************************/ 309/* I2C **********************************************************************/
309/****************************************************************************/ 310/****************************************************************************/
310 311
312static int drxk_i2c_lock(struct drxk_state *state)
313{
314 i2c_lock_adapter(state->i2c);
315 state->drxk_i2c_exclusive_lock = true;
316
317 return 0;
318}
319
320static void drxk_i2c_unlock(struct drxk_state *state)
321{
322 if (!state->drxk_i2c_exclusive_lock)
323 return;
324
325 i2c_unlock_adapter(state->i2c);
326 state->drxk_i2c_exclusive_lock = false;
327}
328
311static int drxk_i2c_transfer(struct drxk_state *state, struct i2c_msg *msgs, 329static int drxk_i2c_transfer(struct drxk_state *state, struct i2c_msg *msgs,
312 unsigned len) 330 unsigned len)
313{ 331{
314 return i2c_transfer(state->i2c, msgs, len); 332 if (state->drxk_i2c_exclusive_lock)
333 return __i2c_transfer(state->i2c, msgs, len);
334 else
335 return i2c_transfer(state->i2c, msgs, len);
315} 336}
316 337
317static int i2c_read1(struct drxk_state *state, u8 adr, u8 *val) 338static int i2c_read1(struct drxk_state *state, u8 adr, u8 *val)
@@ -5982,6 +6003,7 @@ static int init_drxk(struct drxk_state *state)
5982 6003
5983 dprintk(1, "\n"); 6004 dprintk(1, "\n");
5984 if ((state->m_DrxkState == DRXK_UNINITIALIZED)) { 6005 if ((state->m_DrxkState == DRXK_UNINITIALIZED)) {
6006 drxk_i2c_lock(state);
5985 status = PowerUpDevice(state); 6007 status = PowerUpDevice(state);
5986 if (status < 0) 6008 if (status < 0)
5987 goto error; 6009 goto error;
@@ -6171,10 +6193,13 @@ static int init_drxk(struct drxk_state *state)
6171 strlcat(state->frontend.ops.info.name, " DVB-T", 6193 strlcat(state->frontend.ops.info.name, " DVB-T",
6172 sizeof(state->frontend.ops.info.name)); 6194 sizeof(state->frontend.ops.info.name));
6173 } 6195 }
6196 drxk_i2c_unlock(state);
6174 } 6197 }
6175error: 6198error:
6176 if (status < 0) 6199 if (status < 0) {
6200 drxk_i2c_unlock(state);
6177 printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); 6201 printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__);
6202 }
6178 6203
6179 return status; 6204 return status;
6180} 6205}
diff --git a/drivers/media/dvb/frontends/drxk_hard.h b/drivers/media/dvb/frontends/drxk_hard.h
index 36677cdc01d8..c35ab2b37795 100644
--- a/drivers/media/dvb/frontends/drxk_hard.h
+++ b/drivers/media/dvb/frontends/drxk_hard.h
@@ -325,6 +325,9 @@ struct drxk_state {
325 325
326 enum DRXPowerMode m_currentPowerMode; 326 enum DRXPowerMode m_currentPowerMode;
327 327
328 /* when true, avoids other devices to use the I2C bus */
329 bool drxk_i2c_exclusive_lock;
330
328 /* 331 /*
329 * Configurable parameters at the driver. They stores the values found 332 * Configurable parameters at the driver. They stores the values found
330 * at struct drxk_config. 333 * at struct drxk_config.