[PATCH 2/3] input: use input_mutex instead of BKL when opening input device

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Thadeu Lima de Souza Cascardo
Date: Tuesday, March 9, 2010 - 12:19 pm

There are three types of input character devices: mousedev, joydev and
evdev. They all use the same major device and, then, their opening is
multiplexed in input_open_file.

After the BKL pushdown, this multiplexing is protected by the BKL. But
there's already a mutex used for adding and removing to the table
indexed by input_open_file.

So, we use this mutex instead of the BKL. Since it will call the
handlers' open function under the mutex, I've checked that the current
functions do not call input_{un,}register_{handler,device}, which are
the only other functions to take the mutex.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
---
 drivers/input/input.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 41168d5..af9c246 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -23,7 +23,6 @@
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/rcupdate.h>
-#include <linux/smp_lock.h>
 #include "input-compat.h"
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
@@ -1881,7 +1880,7 @@ static int input_open_file(struct inode *inode, struct file *file)
 	const struct file_operations *old_fops, *new_fops = NULL;
 	int err;
 
-	lock_kernel();
+	mutex_lock(&input_mutex);
 	/* No load-on-demand here? */
 	handler = input_table[iminor(inode) >> 5];
 	if (!handler || !(new_fops = fops_get(handler->fops))) {
@@ -1909,7 +1908,7 @@ static int input_open_file(struct inode *inode, struct file *file)
 	}
 	fops_put(old_fops);
 out:
-	unlock_kernel();
+	mutex_unlock(&input_mutex);
 	return err;
 }
 
-- 
1.6.6.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/3] input: remove BKL from mousedev, Thadeu Lima de Souza ..., (Tue Mar 9, 12:19 pm)
[PATCH 2/3] input: use input_mutex instead of BKL when ope ..., Thadeu Lima de Souza ..., (Tue Mar 9, 12:19 pm)
[PATCH 3/3] input: remove BKL from serio_raw, Thadeu Lima de Souza ..., (Tue Mar 9, 12:19 pm)
Re: [PATCH 1/3] input: remove BKL from mousedev, Arnd Bergmann, (Tue Mar 9, 1:05 pm)
Re: [PATCH 3/3] input: remove BKL from serio_raw, Arnd Bergmann, (Tue Mar 9, 1:06 pm)
Re: [PATCH 2/3] input: use input_mutex instead of BKL when ..., Thadeu Lima de Souza ..., (Tue Mar 9, 1:59 pm)