aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/ssp.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa/ssp.c')
-rw-r--r--arch/arm/mach-pxa/ssp.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/arch/arm/mach-pxa/ssp.c b/arch/arm/mach-pxa/ssp.c
index a68b30eff4d2..93096befd017 100644
--- a/arch/arm/mach-pxa/ssp.c
+++ b/arch/arm/mach-pxa/ssp.c
@@ -31,6 +31,7 @@
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/ioport.h> 32#include <linux/ioport.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/mutex.h>
34#include <asm/io.h> 35#include <asm/io.h>
35#include <asm/irq.h> 36#include <asm/irq.h>
36#include <asm/hardware.h> 37#include <asm/hardware.h>
@@ -59,7 +60,7 @@ static const struct ssp_info_ ssp_info[PXA_SSP_PORTS] = {
59#endif 60#endif
60}; 61};
61 62
62static DECLARE_MUTEX(sem); 63static DEFINE_MUTEX(mutex);
63static int use_count[PXA_SSP_PORTS] = {0, 0, 0}; 64static int use_count[PXA_SSP_PORTS] = {0, 0, 0};
64 65
65static irqreturn_t ssp_interrupt(int irq, void *dev_id, struct pt_regs *regs) 66static irqreturn_t ssp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
@@ -239,16 +240,16 @@ int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags)
239 if (port > PXA_SSP_PORTS || port == 0) 240 if (port > PXA_SSP_PORTS || port == 0)
240 return -ENODEV; 241 return -ENODEV;
241 242
242 down(&sem); 243 mutex_lock(&mutex);
243 if (use_count[port - 1]) { 244 if (use_count[port - 1]) {
244 up(&sem); 245 mutex_unlock(&mutex);
245 return -EBUSY; 246 return -EBUSY;
246 } 247 }
247 use_count[port - 1]++; 248 use_count[port - 1]++;
248 249
249 if (!request_mem_region(__PREG(SSCR0_P(port)), 0x2c, "SSP")) { 250 if (!request_mem_region(__PREG(SSCR0_P(port)), 0x2c, "SSP")) {
250 use_count[port - 1]--; 251 use_count[port - 1]--;
251 up(&sem); 252 mutex_unlock(&mutex);
252 return -EBUSY; 253 return -EBUSY;
253 } 254 }
254 dev->port = port; 255 dev->port = port;
@@ -265,13 +266,13 @@ int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags)
265 266
266 /* turn on SSP port clock */ 267 /* turn on SSP port clock */
267 pxa_set_cken(ssp_info[port-1].clock, 1); 268 pxa_set_cken(ssp_info[port-1].clock, 1);
268 up(&sem); 269 mutex_unlock(&mutex);
269 return 0; 270 return 0;
270 271
271out_region: 272out_region:
272 release_mem_region(__PREG(SSCR0_P(port)), 0x2c); 273 release_mem_region(__PREG(SSCR0_P(port)), 0x2c);
273 use_count[port - 1]--; 274 use_count[port - 1]--;
274 up(&sem); 275 mutex_unlock(&mutex);
275 return ret; 276 return ret;
276} 277}
277 278
@@ -282,7 +283,7 @@ out_region:
282 */ 283 */
283void ssp_exit(struct ssp_dev *dev) 284void ssp_exit(struct ssp_dev *dev)
284{ 285{
285 down(&sem); 286 mutex_lock(&mutex);
286 SSCR0_P(dev->port) &= ~SSCR0_SSE; 287 SSCR0_P(dev->port) &= ~SSCR0_SSE;
287 288
288 if (dev->port > PXA_SSP_PORTS || dev->port == 0) { 289 if (dev->port > PXA_SSP_PORTS || dev->port == 0) {
@@ -295,7 +296,7 @@ void ssp_exit(struct ssp_dev *dev)
295 free_irq(dev->irq, dev); 296 free_irq(dev->irq, dev);
296 release_mem_region(__PREG(SSCR0_P(dev->port)), 0x2c); 297 release_mem_region(__PREG(SSCR0_P(dev->port)), 0x2c);
297 use_count[dev->port - 1]--; 298 use_count[dev->port - 1]--;
298 up(&sem); 299 mutex_unlock(&mutex);
299} 300}
300 301
301EXPORT_SYMBOL(ssp_write_word); 302EXPORT_SYMBOL(ssp_write_word);