diff options
Diffstat (limited to 'drivers/char/dsp56k.c')
-rw-r--r-- | drivers/char/dsp56k.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c index 8a1b28a10ef0..052797b32bd3 100644 --- a/drivers/char/dsp56k.c +++ b/drivers/char/dsp56k.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/mm.h> | 32 | #include <linux/mm.h> |
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/device.h> | 34 | #include <linux/device.h> |
35 | #include <linux/smp_lock.h> | 35 | #include <linux/mutex.h> |
36 | #include <linux/firmware.h> | 36 | #include <linux/firmware.h> |
37 | #include <linux/platform_device.h> | 37 | #include <linux/platform_device.h> |
38 | #include <linux/uaccess.h> /* For put_user and get_user */ | 38 | #include <linux/uaccess.h> /* For put_user and get_user */ |
@@ -94,6 +94,7 @@ | |||
94 | } \ | 94 | } \ |
95 | } | 95 | } |
96 | 96 | ||
97 | static DEFINE_MUTEX(dsp56k_mutex); | ||
97 | static struct dsp56k_device { | 98 | static struct dsp56k_device { |
98 | unsigned long in_use; | 99 | unsigned long in_use; |
99 | long maxio, timeout; | 100 | long maxio, timeout; |
@@ -330,9 +331,9 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd, | |||
330 | if (len > DSP56K_MAX_BINARY_LENGTH) { | 331 | if (len > DSP56K_MAX_BINARY_LENGTH) { |
331 | return -EINVAL; | 332 | return -EINVAL; |
332 | } | 333 | } |
333 | lock_kernel(); | 334 | mutex_lock(&dsp56k_mutex); |
334 | r = dsp56k_upload(bin, len); | 335 | r = dsp56k_upload(bin, len); |
335 | unlock_kernel(); | 336 | mutex_unlock(&dsp56k_mutex); |
336 | if (r < 0) { | 337 | if (r < 0) { |
337 | return r; | 338 | return r; |
338 | } | 339 | } |
@@ -342,16 +343,16 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd, | |||
342 | case DSP56K_SET_TX_WSIZE: | 343 | case DSP56K_SET_TX_WSIZE: |
343 | if (arg > 4 || arg < 1) | 344 | if (arg > 4 || arg < 1) |
344 | return -EINVAL; | 345 | return -EINVAL; |
345 | lock_kernel(); | 346 | mutex_lock(&dsp56k_mutex); |
346 | dsp56k.tx_wsize = (int) arg; | 347 | dsp56k.tx_wsize = (int) arg; |
347 | unlock_kernel(); | 348 | mutex_unlock(&dsp56k_mutex); |
348 | break; | 349 | break; |
349 | case DSP56K_SET_RX_WSIZE: | 350 | case DSP56K_SET_RX_WSIZE: |
350 | if (arg > 4 || arg < 1) | 351 | if (arg > 4 || arg < 1) |
351 | return -EINVAL; | 352 | return -EINVAL; |
352 | lock_kernel(); | 353 | mutex_lock(&dsp56k_mutex); |
353 | dsp56k.rx_wsize = (int) arg; | 354 | dsp56k.rx_wsize = (int) arg; |
354 | unlock_kernel(); | 355 | mutex_unlock(&dsp56k_mutex); |
355 | break; | 356 | break; |
356 | case DSP56K_HOST_FLAGS: | 357 | case DSP56K_HOST_FLAGS: |
357 | { | 358 | { |
@@ -363,7 +364,7 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd, | |||
363 | if(get_user(out, &hf->out) < 0) | 364 | if(get_user(out, &hf->out) < 0) |
364 | return -EFAULT; | 365 | return -EFAULT; |
365 | 366 | ||
366 | lock_kernel(); | 367 | mutex_lock(&dsp56k_mutex); |
367 | if ((dir & 0x1) && (out & 0x1)) | 368 | if ((dir & 0x1) && (out & 0x1)) |
368 | dsp56k_host_interface.icr |= DSP56K_ICR_HF0; | 369 | dsp56k_host_interface.icr |= DSP56K_ICR_HF0; |
369 | else if (dir & 0x1) | 370 | else if (dir & 0x1) |
@@ -378,16 +379,16 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd, | |||
378 | if (dsp56k_host_interface.icr & DSP56K_ICR_HF1) status |= 0x2; | 379 | if (dsp56k_host_interface.icr & DSP56K_ICR_HF1) status |= 0x2; |
379 | if (dsp56k_host_interface.isr & DSP56K_ISR_HF2) status |= 0x4; | 380 | if (dsp56k_host_interface.isr & DSP56K_ISR_HF2) status |= 0x4; |
380 | if (dsp56k_host_interface.isr & DSP56K_ISR_HF3) status |= 0x8; | 381 | if (dsp56k_host_interface.isr & DSP56K_ISR_HF3) status |= 0x8; |
381 | unlock_kernel(); | 382 | mutex_unlock(&dsp56k_mutex); |
382 | return put_user(status, &hf->status); | 383 | return put_user(status, &hf->status); |
383 | } | 384 | } |
384 | case DSP56K_HOST_CMD: | 385 | case DSP56K_HOST_CMD: |
385 | if (arg > 31 || arg < 0) | 386 | if (arg > 31 || arg < 0) |
386 | return -EINVAL; | 387 | return -EINVAL; |
387 | lock_kernel(); | 388 | mutex_lock(&dsp56k_mutex); |
388 | dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) | | 389 | dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) | |
389 | DSP56K_CVR_HC); | 390 | DSP56K_CVR_HC); |
390 | unlock_kernel(); | 391 | mutex_unlock(&dsp56k_mutex); |
391 | break; | 392 | break; |
392 | default: | 393 | default: |
393 | return -EINVAL; | 394 | return -EINVAL; |
@@ -427,7 +428,7 @@ static int dsp56k_open(struct inode *inode, struct file *file) | |||
427 | int dev = iminor(inode) & 0x0f; | 428 | int dev = iminor(inode) & 0x0f; |
428 | int ret = 0; | 429 | int ret = 0; |
429 | 430 | ||
430 | lock_kernel(); | 431 | mutex_lock(&dsp56k_mutex); |
431 | switch(dev) | 432 | switch(dev) |
432 | { | 433 | { |
433 | case DSP56K_DEV_56001: | 434 | case DSP56K_DEV_56001: |
@@ -454,7 +455,7 @@ static int dsp56k_open(struct inode *inode, struct file *file) | |||
454 | ret = -ENODEV; | 455 | ret = -ENODEV; |
455 | } | 456 | } |
456 | out: | 457 | out: |
457 | unlock_kernel(); | 458 | mutex_unlock(&dsp56k_mutex); |
458 | return ret; | 459 | return ret; |
459 | } | 460 | } |
460 | 461 | ||
@@ -482,6 +483,7 @@ static const struct file_operations dsp56k_fops = { | |||
482 | .unlocked_ioctl = dsp56k_ioctl, | 483 | .unlocked_ioctl = dsp56k_ioctl, |
483 | .open = dsp56k_open, | 484 | .open = dsp56k_open, |
484 | .release = dsp56k_release, | 485 | .release = dsp56k_release, |
486 | .llseek = noop_llseek, | ||
485 | }; | 487 | }; |
486 | 488 | ||
487 | 489 | ||