diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-10-09 14:31:02 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2009-10-14 11:36:49 -0400 |
commit | 205153aa40b7fb36dc7fe76c1798584ace55b288 (patch) | |
tree | 27493306d3fe3660e11af86f437da0c573db15f2 /drivers/char | |
parent | 4c2aedc2543248c3fdc8c06c662b589d36c93bbb (diff) |
mem_class: Drop the bkl from memory_open()
The generic open callback for the mem class devices is "protected" by
the bkl.
Let's look at the datas manipulated inside memory_open:
- inode and file: safe
- the devlist: safe because it is constant
- the memdev classes inside this array are safe too (constant)
After we find out which memdev file operation we need to use, we call
its open callback. Depending on the targeted memdev, we call either
open_port() that doesn't manipulate any racy data (just a capable()
check), or we call nothing.
So it's safe to remove the big kernel lock there.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <1255113062-5835-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/mem.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index a074fceb67d3..ad82ec92ebd4 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/bootmem.h> | 26 | #include <linux/bootmem.h> |
27 | #include <linux/splice.h> | 27 | #include <linux/splice.h> |
28 | #include <linux/pfn.h> | 28 | #include <linux/pfn.h> |
29 | #include <linux/smp_lock.h> | ||
30 | 29 | ||
31 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
32 | #include <asm/io.h> | 31 | #include <asm/io.h> |
@@ -892,29 +891,23 @@ static int memory_open(struct inode *inode, struct file *filp) | |||
892 | { | 891 | { |
893 | int minor; | 892 | int minor; |
894 | const struct memdev *dev; | 893 | const struct memdev *dev; |
895 | int ret = -ENXIO; | ||
896 | |||
897 | lock_kernel(); | ||
898 | 894 | ||
899 | minor = iminor(inode); | 895 | minor = iminor(inode); |
900 | if (minor >= ARRAY_SIZE(devlist)) | 896 | if (minor >= ARRAY_SIZE(devlist)) |
901 | goto out; | 897 | return -ENXIO; |
902 | 898 | ||
903 | dev = &devlist[minor]; | 899 | dev = &devlist[minor]; |
904 | if (!dev->fops) | 900 | if (!dev->fops) |
905 | goto out; | 901 | return -ENXIO; |
906 | 902 | ||
907 | filp->f_op = dev->fops; | 903 | filp->f_op = dev->fops; |
908 | if (dev->dev_info) | 904 | if (dev->dev_info) |
909 | filp->f_mapping->backing_dev_info = dev->dev_info; | 905 | filp->f_mapping->backing_dev_info = dev->dev_info; |
910 | 906 | ||
911 | if (dev->fops->open) | 907 | if (dev->fops->open) |
912 | ret = dev->fops->open(inode, filp); | 908 | return dev->fops->open(inode, filp); |
913 | else | 909 | |
914 | ret = 0; | 910 | return 0; |
915 | out: | ||
916 | unlock_kernel(); | ||
917 | return ret; | ||
918 | } | 911 | } |
919 | 912 | ||
920 | static const struct file_operations memory_fops = { | 913 | static const struct file_operations memory_fops = { |