aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/i4l
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-07-11 07:18:53 -0400
committerDavid S. Miller <davem@davemloft.net>2010-07-12 23:21:47 -0400
commit76a64921dad9acd76270dc74249f0dfe11c84bb8 (patch)
tree42eaa62b3c886e46b29bbae354fe87bf8475d970 /drivers/isdn/i4l
parentd361fd599a991ff6c1d522a599c635b35d61ef30 (diff)
isdn: 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. 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> Cc: Karsten Keil <isdn@linux-pingi.de> Cc: netdev@vger.kernel.org Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/i4l')
-rw-r--r--drivers/isdn/i4l/isdn_common.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index a44cdb492ea9..15632bd2f643 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -17,7 +17,7 @@
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/vmalloc.h> 18#include <linux/vmalloc.h>
19#include <linux/isdn.h> 19#include <linux/isdn.h>
20#include <linux/smp_lock.h> 20#include <linux/mutex.h>
21#include "isdn_common.h" 21#include "isdn_common.h"
22#include "isdn_tty.h" 22#include "isdn_tty.h"
23#include "isdn_net.h" 23#include "isdn_net.h"
@@ -42,6 +42,7 @@ MODULE_LICENSE("GPL");
42 42
43isdn_dev *dev; 43isdn_dev *dev;
44 44
45static DEFINE_MUTEX(isdn_mutex);
45static char *isdn_revision = "$Revision: 1.1.2.3 $"; 46static char *isdn_revision = "$Revision: 1.1.2.3 $";
46 47
47extern char *isdn_net_revision; 48extern char *isdn_net_revision;
@@ -1070,7 +1071,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
1070 int retval; 1071 int retval;
1071 char *p; 1072 char *p;
1072 1073
1073 lock_kernel(); 1074 mutex_lock(&isdn_mutex);
1074 if (minor == ISDN_MINOR_STATUS) { 1075 if (minor == ISDN_MINOR_STATUS) {
1075 if (!file->private_data) { 1076 if (!file->private_data) {
1076 if (file->f_flags & O_NONBLOCK) { 1077 if (file->f_flags & O_NONBLOCK) {
@@ -1163,7 +1164,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
1163#endif 1164#endif
1164 retval = -ENODEV; 1165 retval = -ENODEV;
1165 out: 1166 out:
1166 unlock_kernel(); 1167 mutex_unlock(&isdn_mutex);
1167 return retval; 1168 return retval;
1168} 1169}
1169 1170
@@ -1180,7 +1181,7 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off
1180 if (!dev->drivers) 1181 if (!dev->drivers)
1181 return -ENODEV; 1182 return -ENODEV;
1182 1183
1183 lock_kernel(); 1184 mutex_lock(&isdn_mutex);
1184 if (minor <= ISDN_MINOR_BMAX) { 1185 if (minor <= ISDN_MINOR_BMAX) {
1185 printk(KERN_WARNING "isdn_write minor %d obsolete!\n", minor); 1186 printk(KERN_WARNING "isdn_write minor %d obsolete!\n", minor);
1186 drvidx = isdn_minor2drv(minor); 1187 drvidx = isdn_minor2drv(minor);
@@ -1225,7 +1226,7 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off
1225#endif 1226#endif
1226 retval = -ENODEV; 1227 retval = -ENODEV;
1227 out: 1228 out:
1228 unlock_kernel(); 1229 mutex_unlock(&isdn_mutex);
1229 return retval; 1230 return retval;
1230} 1231}
1231 1232
@@ -1236,7 +1237,7 @@ isdn_poll(struct file *file, poll_table * wait)
1236 unsigned int minor = iminor(file->f_path.dentry->d_inode); 1237 unsigned int minor = iminor(file->f_path.dentry->d_inode);
1237 int drvidx = isdn_minor2drv(minor - ISDN_MINOR_CTRL); 1238 int drvidx = isdn_minor2drv(minor - ISDN_MINOR_CTRL);
1238 1239
1239 lock_kernel(); 1240 mutex_lock(&isdn_mutex);
1240 if (minor == ISDN_MINOR_STATUS) { 1241 if (minor == ISDN_MINOR_STATUS) {
1241 poll_wait(file, &(dev->info_waitq), wait); 1242 poll_wait(file, &(dev->info_waitq), wait);
1242 /* mask = POLLOUT | POLLWRNORM; */ 1243 /* mask = POLLOUT | POLLWRNORM; */
@@ -1266,7 +1267,7 @@ isdn_poll(struct file *file, poll_table * wait)
1266#endif 1267#endif
1267 mask = POLLERR; 1268 mask = POLLERR;
1268 out: 1269 out:
1269 unlock_kernel(); 1270 mutex_unlock(&isdn_mutex);
1270 return mask; 1271 return mask;
1271} 1272}
1272 1273
@@ -1727,9 +1728,9 @@ isdn_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1727{ 1728{
1728 int ret; 1729 int ret;
1729 1730
1730 lock_kernel(); 1731 mutex_lock(&isdn_mutex);
1731 ret = isdn_ioctl(file, cmd, arg); 1732 ret = isdn_ioctl(file, cmd, arg);
1732 unlock_kernel(); 1733 mutex_unlock(&isdn_mutex);
1733 1734
1734 return ret; 1735 return ret;
1735} 1736}
@@ -1745,7 +1746,7 @@ isdn_open(struct inode *ino, struct file *filep)
1745 int chidx; 1746 int chidx;
1746 int retval = -ENODEV; 1747 int retval = -ENODEV;
1747 1748
1748 lock_kernel(); 1749 mutex_lock(&isdn_mutex);
1749 if (minor == ISDN_MINOR_STATUS) { 1750 if (minor == ISDN_MINOR_STATUS) {
1750 infostruct *p; 1751 infostruct *p;
1751 1752
@@ -1796,7 +1797,7 @@ isdn_open(struct inode *ino, struct file *filep)
1796#endif 1797#endif
1797 out: 1798 out:
1798 nonseekable_open(ino, filep); 1799 nonseekable_open(ino, filep);
1799 unlock_kernel(); 1800 mutex_unlock(&isdn_mutex);
1800 return retval; 1801 return retval;
1801} 1802}
1802 1803
@@ -1805,7 +1806,7 @@ isdn_close(struct inode *ino, struct file *filep)
1805{ 1806{
1806 uint minor = iminor(ino); 1807 uint minor = iminor(ino);
1807 1808
1808 lock_kernel(); 1809 mutex_lock(&isdn_mutex);
1809 if (minor == ISDN_MINOR_STATUS) { 1810 if (minor == ISDN_MINOR_STATUS) {
1810 infostruct *p = dev->infochain; 1811 infostruct *p = dev->infochain;
1811 infostruct *q = NULL; 1812 infostruct *q = NULL;
@@ -1839,7 +1840,7 @@ isdn_close(struct inode *ino, struct file *filep)
1839#endif 1840#endif
1840 1841
1841 out: 1842 out:
1842 unlock_kernel(); 1843 mutex_unlock(&isdn_mutex);
1843 return 0; 1844 return 0;
1844} 1845}
1845 1846