aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/dsp56k.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-06-02 08:28:52 -0400
committerArnd Bergmann <arnd@arndb.de>2010-10-05 09:01:04 -0400
commit613655fa39ff6957754fa8ceb8559980920eb8ee (patch)
treead19600cb81207b24188683d7fc4ae88013339d1 /drivers/char/dsp56k.c
parent609146fdb319cebce93be550938ab852f7bade90 (diff)
drivers: autoconvert trivial BKL users to private mutex
All these files use the big kernel lock in a trivial way to serialize their private file operations, typically resulting from an earlier semi-automatic pushdown from VFS. None of these drivers appears to want to lock against other code, and they all use the BKL as the top-level lock in their file operations, meaning that there is no lock-order inversion problem. Consequently, we can remove the BKL completely, replacing it with a per-file mutex in every case. Using a scripted approach means we can avoid typos. These drivers do not seem to be under active maintainance from my brief investigation. Apologies to those maintainers that I have missed. file=$1 name=$2 if grep -q lock_kernel ${file} ; then if grep -q 'include.*linux.mutex.h' ${file} ; then sed -i '/include.*<linux\/smp_lock.h>/d' ${file} else sed -i 's/include.*<linux\/smp_lock.h>.*$/include <linux\/mutex.h>/g' ${file} fi sed -i ${file} \ -e "/^#include.*linux.mutex.h/,$ { 1,/^\(static\|int\|long\)/ { /^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex); } }" \ -e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \ -e '/[ ]*cycle_kernel_lock();/d' else sed -i -e '/include.*\<smp_lock.h\>/d' ${file} \ -e '/cycle_kernel_lock()/d' fi Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/char/dsp56k.c')
-rw-r--r--drivers/char/dsp56k.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index 8a1b28a10ef0..b3c756227e39 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
97static DEFINE_MUTEX(dsp56k_mutex);
97static struct dsp56k_device { 98static 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 }
456out: 457out:
457 unlock_kernel(); 458 mutex_unlock(&dsp56k_mutex);
458 return ret; 459 return ret;
459} 460}
460 461