Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 205153aa authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Thomas Gleixner
Browse files

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: default avatarFrederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <1255113062-5835-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 4c2aedc2
Loading
Loading
Loading
Loading
+5 −12
Original line number Original line Diff line number Diff line
@@ -26,7 +26,6 @@
#include <linux/bootmem.h>
#include <linux/bootmem.h>
#include <linux/splice.h>
#include <linux/splice.h>
#include <linux/pfn.h>
#include <linux/pfn.h>
#include <linux/smp_lock.h>


#include <asm/uaccess.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <asm/io.h>
@@ -892,29 +891,23 @@ static int memory_open(struct inode *inode, struct file *filp)
{
{
	int minor;
	int minor;
	const struct memdev *dev;
	const struct memdev *dev;
	int ret = -ENXIO;

	lock_kernel();


	minor = iminor(inode);
	minor = iminor(inode);
	if (minor >= ARRAY_SIZE(devlist))
	if (minor >= ARRAY_SIZE(devlist))
		goto out;
		return -ENXIO;


	dev = &devlist[minor];
	dev = &devlist[minor];
	if (!dev->fops)
	if (!dev->fops)
		goto out;
		return -ENXIO;


	filp->f_op = dev->fops;
	filp->f_op = dev->fops;
	if (dev->dev_info)
	if (dev->dev_info)
		filp->f_mapping->backing_dev_info = dev->dev_info;
		filp->f_mapping->backing_dev_info = dev->dev_info;


	if (dev->fops->open)
	if (dev->fops->open)
		ret = dev->fops->open(inode, filp);
		return dev->fops->open(inode, filp);
	else

		ret = 0;
	return 0;
out:
	unlock_kernel();
	return ret;
}
}


static const struct file_operations memory_fops = {
static const struct file_operations memory_fops = {