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

From: Thadeu Lima de Souza Cascardo
Date: Tue Mar 09 2010 - 14:20:37 EST


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@xxxxxxxxxxxxxx>
---
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@xxxxxxx>");
@@ -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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/