aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/mantis/mantis_i2c.c
diff options
context:
space:
mode:
authorManu Abraham <abraham.manu@gmail.com>2009-12-03 03:42:10 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-01-17 08:55:29 -0500
commite2f67e4fb931b975058b3bd48eaac43780c92c88 (patch)
tree9281b24fa70a0bf53547854b03f260688cea6f14 /drivers/media/dvb/mantis/mantis_i2c.c
parente4deee04ffda9b44f367a40dbad8306ab88cb321 (diff)
V4L/DVB (13712): [Mantis] Add locking for concurrent access
Signed-off-by: Manu Abraham <manu@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/mantis/mantis_i2c.c')
-rw-r--r--drivers/media/dvb/mantis/mantis_i2c.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/media/dvb/mantis/mantis_i2c.c b/drivers/media/dvb/mantis/mantis_i2c.c
index 53c5f88227be..39fabe572c2e 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
125 struct mantis_pci *mantis; 125 struct mantis_pci *mantis;
126 126
127 mantis = i2c_get_adapdata(adapter); 127 mantis = i2c_get_adapdata(adapter);
128 mutex_lock(&mantis->i2c_lock);
128 for (i = 0; i < num; i++) { 129 for (i = 0; i < num; i++) {
129 if (msgs[i].flags & I2C_M_RD) 130 if (msgs[i].flags & I2C_M_RD)
130 ret = mantis_i2c_read(mantis, &msgs[i]); 131 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
134 if (ret < 0) 135 if (ret < 0)
135 return ret; 136 return ret;
136 } 137 }
138 mutex_unlock(&mantis->i2c_lock);
137 139
138 return num; 140 return num;
139} 141}
@@ -160,6 +162,7 @@ int __devinit mantis_i2c_init(struct mantis_pci *mantis)
160{ 162{
161 u32 intstat, intmask; 163 u32 intstat, intmask;
162 164
165 mutex_init(&mantis->i2c_lock);
163 memcpy(&mantis->adapter, &mantis_i2c_adapter, sizeof (mantis_i2c_adapter)); 166 memcpy(&mantis->adapter, &mantis_i2c_adapter, sizeof (mantis_i2c_adapter));
164 i2c_set_adapdata(&mantis->adapter, mantis); 167 i2c_set_adapdata(&mantis->adapter, mantis);
165 mantis->i2c_rc = i2c_add_adapter(&mantis->adapter); 168 mantis->i2c_rc = i2c_add_adapter(&mantis->adapter);