aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wan/cosa.c
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2008-05-15 11:21:33 -0400
committerJonathan Corbet <corbet@lwn.net>2008-05-18 17:43:40 -0400
commit0911810755fc9f15659cc3cb43912633b90027a0 (patch)
tree3087a4b84aaa59a8961b03c61ed3ca315cdece26 /drivers/net/wan/cosa.c
parent3db633ee352bfe20d4a2b0c3c8a46ce31a6c7149 (diff)
cosa: cdev lock_kernel() pushdown
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'drivers/net/wan/cosa.c')
-rw-r--r--drivers/net/wan/cosa.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index b0fce1387eaf..5827324e9d9f 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -92,6 +92,7 @@
92#include <linux/spinlock.h> 92#include <linux/spinlock.h>
93#include <linux/mutex.h> 93#include <linux/mutex.h>
94#include <linux/device.h> 94#include <linux/device.h>
95#include <linux/smp_lock.h>
95 96
96#undef COSA_SLOW_IO /* for testing purposes only */ 97#undef COSA_SLOW_IO /* for testing purposes only */
97 98
@@ -970,15 +971,21 @@ static int cosa_open(struct inode *inode, struct file *file)
970 struct channel_data *chan; 971 struct channel_data *chan;
971 unsigned long flags; 972 unsigned long flags;
972 int n; 973 int n;
974 int ret = 0;
973 975
976 lock_kernel();
974 if ((n=iminor(file->f_path.dentry->d_inode)>>CARD_MINOR_BITS) 977 if ((n=iminor(file->f_path.dentry->d_inode)>>CARD_MINOR_BITS)
975 >= nr_cards) 978 >= nr_cards) {
976 return -ENODEV; 979 ret = -ENODEV;
980 goto out;
981 }
977 cosa = cosa_cards+n; 982 cosa = cosa_cards+n;
978 983
979 if ((n=iminor(file->f_path.dentry->d_inode) 984 if ((n=iminor(file->f_path.dentry->d_inode)
980 & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels) 985 & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels) {
981 return -ENODEV; 986 ret = -ENODEV;
987 goto out;
988 }
982 chan = cosa->chan + n; 989 chan = cosa->chan + n;
983 990
984 file->private_data = chan; 991 file->private_data = chan;
@@ -987,7 +994,8 @@ static int cosa_open(struct inode *inode, struct file *file)
987 994
988 if (chan->usage < 0) { /* in netdev mode */ 995 if (chan->usage < 0) { /* in netdev mode */
989 spin_unlock_irqrestore(&cosa->lock, flags); 996 spin_unlock_irqrestore(&cosa->lock, flags);
990 return -EBUSY; 997 ret = -EBUSY;
998 goto out;
991 } 999 }
992 cosa->usage++; 1000 cosa->usage++;
993 chan->usage++; 1001 chan->usage++;
@@ -996,7 +1004,9 @@ static int cosa_open(struct inode *inode, struct file *file)
996 chan->setup_rx = chrdev_setup_rx; 1004 chan->setup_rx = chrdev_setup_rx;
997 chan->rx_done = chrdev_rx_done; 1005 chan->rx_done = chrdev_rx_done;
998 spin_unlock_irqrestore(&cosa->lock, flags); 1006 spin_unlock_irqrestore(&cosa->lock, flags);
999 return 0; 1007out:
1008 unlock_kernel();
1009 return ret;
1000} 1010}
1001 1011
1002static int cosa_release(struct inode *inode, struct file *file) 1012static int cosa_release(struct inode *inode, struct file *file)