70 lines
2.3 KiB
Diff
70 lines
2.3 KiB
Diff
From 18bf84a35a0b9ea89c4262125457c2938b37f149 Mon Sep 17 00:00:00 2001
|
|
From: Manu Abraham <abraham.manu@gmail.com>
|
|
Date: Thu, 3 Dec 2009 05:42:10 -0300
|
|
Subject: [PATCH 014/120] V4L/DVB (13712): [Mantis] Add locking for concurrent access
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Signed-off-by: Manu Abraham <manu@linuxtv.org>
|
|
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
|
|
(cherry picked from commit e2f67e4fb931b975058b3bd48eaac43780c92c88)
|
|
|
|
Signed-off-by: Bjørn Mork <bjorn@mork.no>
|
|
---
|
|
drivers/media/dvb/mantis/mantis_common.h | 2 ++
|
|
drivers/media/dvb/mantis/mantis_i2c.c | 3 +++
|
|
2 files changed, 5 insertions(+), 0 deletions(-)
|
|
|
|
diff --git a/drivers/media/dvb/mantis/mantis_common.h b/drivers/media/dvb/mantis/mantis_common.h
|
|
index 197393e..e354e76 100644
|
|
--- a/drivers/media/dvb/mantis/mantis_common.h
|
|
+++ b/drivers/media/dvb/mantis/mantis_common.h
|
|
@@ -25,6 +25,7 @@
|
|
#include <linux/moduleparam.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/pci.h>
|
|
+#include <linux/mutex.h>
|
|
|
|
#include "dvbdev.h"
|
|
#include "dvb_demux.h"
|
|
@@ -109,6 +110,7 @@ struct mantis_pci {
|
|
struct i2c_adapter adapter;
|
|
int i2c_rc;
|
|
wait_queue_head_t i2c_wq;
|
|
+ struct mutex i2c_lock;
|
|
|
|
/* DVB stuff */
|
|
struct dvb_adapter dvb_adapter;
|
|
diff --git a/drivers/media/dvb/mantis/mantis_i2c.c b/drivers/media/dvb/mantis/mantis_i2c.c
|
|
index 53c5f88..39fabe5 100644
|
|
--- a/drivers/media/dvb/mantis/mantis_i2c.c
|
|
+++ b/drivers/media/dvb/mantis/mantis_i2c.c
|
|
@@ -125,6 +125,7 @@ static int mantis_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, in
|
|
struct mantis_pci *mantis;
|
|
|
|
mantis = i2c_get_adapdata(adapter);
|
|
+ mutex_lock(&mantis->i2c_lock);
|
|
for (i = 0; i < num; i++) {
|
|
if (msgs[i].flags & I2C_M_RD)
|
|
ret = mantis_i2c_read(mantis, &msgs[i]);
|
|
@@ -134,6 +135,7 @@ static int mantis_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, in
|
|
if (ret < 0)
|
|
return ret;
|
|
}
|
|
+ mutex_unlock(&mantis->i2c_lock);
|
|
|
|
return num;
|
|
}
|
|
@@ -160,6 +162,7 @@ int __devinit mantis_i2c_init(struct mantis_pci *mantis)
|
|
{
|
|
u32 intstat, intmask;
|
|
|
|
+ mutex_init(&mantis->i2c_lock);
|
|
memcpy(&mantis->adapter, &mantis_i2c_adapter, sizeof (mantis_i2c_adapter));
|
|
i2c_set_adapdata(&mantis->adapter, mantis);
|
|
mantis->i2c_rc = i2c_add_adapter(&mantis->adapter);
|
|
--
|
|
1.7.1
|
|
|