aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorManu Abraham <abraham.manu@gmail.com>2009-12-04 03:34:19 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-01-17 08:55:41 -0500
commitf684336bba673b6656cb98144130ab52dafc3240 (patch)
treed50afc70a0350c74250fcd48a3993bb3856348ca /drivers/media
parent616f75e1979f5bd1f3241581c720349c2c31f6e7 (diff)
V4L/DVB (13788): [Mantis CA] use a lock for the relevant CI Read/Write operations
Signed-off-by: Manu Abraham <manu@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/dvb/mantis/mantis_hif.c16
-rw-r--r--drivers/media/dvb/mantis/mantis_link.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/drivers/media/dvb/mantis/mantis_hif.c b/drivers/media/dvb/mantis/mantis_hif.c
index 3368253aea6c..b1e1aa0f5c12 100644
--- a/drivers/media/dvb/mantis/mantis_hif.c
+++ b/drivers/media/dvb/mantis/mantis_hif.c
@@ -92,6 +92,7 @@ int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr)
92 u32 hif_addr = 0, data, count = 4; 92 u32 hif_addr = 0, data, count = 4;
93 93
94 dprintk(verbose, MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF Mem Read", mantis->num); 94 dprintk(verbose, MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF Mem Read", mantis->num);
95 mutex_lock(&ca->ca_lock);
95 hif_addr &= ~MANTIS_GPIF_PCMCIAREG; 96 hif_addr &= ~MANTIS_GPIF_PCMCIAREG;
96 hif_addr &= ~MANTIS_GPIF_PCMCIAIOM; 97 hif_addr &= ~MANTIS_GPIF_PCMCIAIOM;
97 hif_addr |= MANTIS_HIF_STATUS; 98 hif_addr |= MANTIS_HIF_STATUS;
@@ -104,9 +105,11 @@ int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr)
104 105
105 if (mantis_hif_sbuf_opdone_wait(ca) != 0) { 106 if (mantis_hif_sbuf_opdone_wait(ca) != 0) {
106 dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): GPIF Smart Buffer operation failed", mantis->num); 107 dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): GPIF Smart Buffer operation failed", mantis->num);
108 mutex_unlock(&ca->ca_lock);
107 return -EREMOTEIO; 109 return -EREMOTEIO;
108 } 110 }
109 data = mmread(MANTIS_GPIF_DIN); 111 data = mmread(MANTIS_GPIF_DIN);
112 mutex_unlock(&ca->ca_lock);
110 dprintk(verbose, MANTIS_DEBUG, 1, "Mem Read: 0x%02x", data); 113 dprintk(verbose, MANTIS_DEBUG, 1, "Mem Read: 0x%02x", data);
111 return (data >> 24) & 0xff; 114 return (data >> 24) & 0xff;
112} 115}
@@ -118,6 +121,7 @@ int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data)
118 u32 hif_addr = 0; 121 u32 hif_addr = 0;
119 122
120 dprintk(verbose, MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF Mem Write", mantis->num); 123 dprintk(verbose, MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF Mem Write", mantis->num);
124 mutex_lock(&ca->ca_lock);
121 hif_addr &= ~MANTIS_GPIF_HIFRDWRN; 125 hif_addr &= ~MANTIS_GPIF_HIFRDWRN;
122 hif_addr &= ~MANTIS_GPIF_PCMCIAREG; 126 hif_addr &= ~MANTIS_GPIF_PCMCIAREG;
123 hif_addr &= ~MANTIS_GPIF_PCMCIAIOM; 127 hif_addr &= ~MANTIS_GPIF_PCMCIAIOM;
@@ -130,9 +134,11 @@ int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data)
130 134
131 if (mantis_hif_write_wait(ca) != 0) { 135 if (mantis_hif_write_wait(ca) != 0) {
132 dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num); 136 dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num);
137 mutex_unlock(&ca->ca_lock);
133 return -EREMOTEIO; 138 return -EREMOTEIO;
134 } 139 }
135 dprintk(verbose, MANTIS_DEBUG, 1, "Mem Write: (0x%02x to 0x%02x)", data, addr); 140 dprintk(verbose, MANTIS_DEBUG, 1, "Mem Write: (0x%02x to 0x%02x)", data, addr);
141 mutex_unlock(&ca->ca_lock);
136 142
137 return 0; 143 return 0;
138} 144}
@@ -143,6 +149,7 @@ int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr)
143 u32 data, hif_addr = 0; 149 u32 data, hif_addr = 0;
144 150
145 dprintk(verbose, MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF I/O Read", mantis->num); 151 dprintk(verbose, MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF I/O Read", mantis->num);
152 mutex_lock(&ca->ca_lock);
146 hif_addr &= ~MANTIS_GPIF_PCMCIAREG; 153 hif_addr &= ~MANTIS_GPIF_PCMCIAREG;
147 hif_addr |= MANTIS_GPIF_PCMCIAIOM; 154 hif_addr |= MANTIS_GPIF_PCMCIAIOM;
148 hif_addr |= MANTIS_HIF_STATUS; 155 hif_addr |= MANTIS_HIF_STATUS;
@@ -155,11 +162,13 @@ int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr)
155 162
156 if (mantis_hif_sbuf_opdone_wait(ca) != 0) { 163 if (mantis_hif_sbuf_opdone_wait(ca) != 0) {
157 dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num); 164 dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num);
165 mutex_unlock(&ca->ca_lock);
158 return -EREMOTEIO; 166 return -EREMOTEIO;
159 } 167 }
160 data = mmread(MANTIS_GPIF_DIN); 168 data = mmread(MANTIS_GPIF_DIN);
161 dprintk(verbose, MANTIS_DEBUG, 1, "I/O Read: 0x%02x", data); 169 dprintk(verbose, MANTIS_DEBUG, 1, "I/O Read: 0x%02x", data);
162 udelay(50); 170 udelay(50);
171 mutex_unlock(&ca->ca_lock);
163 172
164 return (u8) data; 173 return (u8) data;
165} 174}
@@ -170,6 +179,7 @@ int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data)
170 u32 hif_addr = 0; 179 u32 hif_addr = 0;
171 180
172 dprintk(verbose, MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF I/O Write", mantis->num); 181 dprintk(verbose, MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF I/O Write", mantis->num);
182 mutex_lock(&ca->ca_lock);
173 hif_addr &= ~MANTIS_GPIF_PCMCIAREG; 183 hif_addr &= ~MANTIS_GPIF_PCMCIAREG;
174 hif_addr &= ~MANTIS_GPIF_HIFRDWRN; 184 hif_addr &= ~MANTIS_GPIF_HIFRDWRN;
175 hif_addr |= MANTIS_GPIF_PCMCIAIOM; 185 hif_addr |= MANTIS_GPIF_PCMCIAIOM;
@@ -181,9 +191,11 @@ int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data)
181 191
182 if (mantis_hif_write_wait(ca) != 0) { 192 if (mantis_hif_write_wait(ca) != 0) {
183 dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num); 193 dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num);
194 mutex_unlock(&ca->ca_lock);
184 return -EREMOTEIO; 195 return -EREMOTEIO;
185 } 196 }
186 dprintk(verbose, MANTIS_DEBUG, 1, "I/O Write: (0x%02x to 0x%02x)", data, addr); 197 dprintk(verbose, MANTIS_DEBUG, 1, "I/O Write: (0x%02x to 0x%02x)", data, addr);
198 mutex_unlock(&ca->ca_lock);
187 udelay(50); 199 udelay(50);
188 200
189 return 0; 201 return 0;
@@ -201,6 +213,7 @@ int mantis_hif_init(struct mantis_ca *ca)
201 init_waitqueue_head(&ca->hif_opdone_wq); 213 init_waitqueue_head(&ca->hif_opdone_wq);
202 init_waitqueue_head(&ca->hif_write_wq); 214 init_waitqueue_head(&ca->hif_write_wq);
203 215
216 mutex_lock(&ca->ca_lock);
204 irqcfg = mmread(MANTIS_GPIF_IRQCFG); 217 irqcfg = mmread(MANTIS_GPIF_IRQCFG);
205 irqcfg = MANTIS_MASK_BRRDY | 218 irqcfg = MANTIS_MASK_BRRDY |
206 MANTIS_MASK_WRACK | 219 MANTIS_MASK_WRACK |
@@ -210,6 +223,7 @@ int mantis_hif_init(struct mantis_ca *ca)
210 MANTIS_MASK_OVFLW; 223 MANTIS_MASK_OVFLW;
211 224
212 mmwrite(irqcfg, MANTIS_GPIF_IRQCFG); 225 mmwrite(irqcfg, MANTIS_GPIF_IRQCFG);
226 mutex_unlock(&ca->ca_lock);
213 227
214 return 0; 228 return 0;
215} 229}
@@ -220,7 +234,9 @@ void mantis_hif_exit(struct mantis_ca *ca)
220 u32 irqcfg; 234 u32 irqcfg;
221 235
222 dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Exiting Mantis Host Interface", mantis->num); 236 dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Exiting Mantis Host Interface", mantis->num);
237 mutex_lock(&ca->ca_lock);
223 irqcfg = mmread(MANTIS_GPIF_IRQCFG); 238 irqcfg = mmread(MANTIS_GPIF_IRQCFG);
224 irqcfg &= ~MANTIS_MASK_BRRDY; 239 irqcfg &= ~MANTIS_MASK_BRRDY;
225 mmwrite(irqcfg, MANTIS_GPIF_IRQCFG); 240 mmwrite(irqcfg, MANTIS_GPIF_IRQCFG);
241 mutex_unlock(&ca->ca_lock);
226} 242}
diff --git a/drivers/media/dvb/mantis/mantis_link.h b/drivers/media/dvb/mantis/mantis_link.h
index 599ff1b57e48..f9aaaa52f52c 100644
--- a/drivers/media/dvb/mantis/mantis_link.h
+++ b/drivers/media/dvb/mantis/mantis_link.h
@@ -21,6 +21,7 @@
21#ifndef __MANTIS_LINK_H 21#ifndef __MANTIS_LINK_H
22#define __MANTIS_LINK_H 22#define __MANTIS_LINK_H
23 23
24#include <linux/mutex.h>
24#include <linux/workqueue.h> 25#include <linux/workqueue.h>
25#include "dvb_ca_en50221.h" 26#include "dvb_ca_en50221.h"
26 27
@@ -61,6 +62,7 @@ struct mantis_ca {
61 void *ca_priv; 62 void *ca_priv;
62 63
63 struct dvb_ca_en50221 en50221; 64 struct dvb_ca_en50221 en50221;
65 struct mutex ca_lock;
64}; 66};
65 67
66/* CA */ 68/* CA */