aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/ppdev.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-06-02 08:28:52 -0400
committerArnd Bergmann <arnd@arndb.de>2010-10-05 09:01:04 -0400
commit613655fa39ff6957754fa8ceb8559980920eb8ee (patch)
treead19600cb81207b24188683d7fc4ae88013339d1 /drivers/char/ppdev.c
parent609146fdb319cebce93be550938ab852f7bade90 (diff)
drivers: autoconvert trivial BKL users to private mutex
All these files use the big kernel lock in a trivial way to serialize their private file operations, typically resulting from an earlier semi-automatic pushdown from VFS. None of these drivers appears to want to lock against other code, and they all use the BKL as the top-level lock in their file operations, meaning that there is no lock-order inversion problem. Consequently, we can remove the BKL completely, replacing it with a per-file mutex in every case. Using a scripted approach means we can avoid typos. These drivers do not seem to be under active maintainance from my brief investigation. Apologies to those maintainers that I have missed. file=$1 name=$2 if grep -q lock_kernel ${file} ; then if grep -q 'include.*linux.mutex.h' ${file} ; then sed -i '/include.*<linux\/smp_lock.h>/d' ${file} else sed -i 's/include.*<linux\/smp_lock.h>.*$/include <linux\/mutex.h>/g' ${file} fi sed -i ${file} \ -e "/^#include.*linux.mutex.h/,$ { 1,/^\(static\|int\|long\)/ { /^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex); } }" \ -e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \ -e '/[ ]*cycle_kernel_lock();/d' else sed -i -e '/include.*\<smp_lock.h\>/d' ${file} \ -e '/cycle_kernel_lock()/d' fi Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/char/ppdev.c')
-rw-r--r--drivers/char/ppdev.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 02abfddce45a..723152d978a9 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -67,7 +67,7 @@
67#include <linux/slab.h> 67#include <linux/slab.h>
68#include <linux/major.h> 68#include <linux/major.h>
69#include <linux/ppdev.h> 69#include <linux/ppdev.h>
70#include <linux/smp_lock.h> 70#include <linux/mutex.h>
71#include <linux/uaccess.h> 71#include <linux/uaccess.h>
72 72
73#define PP_VERSION "ppdev: user-space parallel port driver" 73#define PP_VERSION "ppdev: user-space parallel port driver"
@@ -97,6 +97,7 @@ struct pp_struct {
97/* ROUND_UP macro from fs/select.c */ 97/* ROUND_UP macro from fs/select.c */
98#define ROUND_UP(x,y) (((x)+(y)-1)/(y)) 98#define ROUND_UP(x,y) (((x)+(y)-1)/(y))
99 99
100static DEFINE_MUTEX(pp_do_mutex);
100static inline void pp_enable_irq (struct pp_struct *pp) 101static inline void pp_enable_irq (struct pp_struct *pp)
101{ 102{
102 struct parport *port = pp->pdev->port; 103 struct parport *port = pp->pdev->port;
@@ -630,9 +631,9 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
630static long pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 631static long pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
631{ 632{
632 long ret; 633 long ret;
633 lock_kernel(); 634 mutex_lock(&pp_do_mutex);
634 ret = pp_do_ioctl(file, cmd, arg); 635 ret = pp_do_ioctl(file, cmd, arg);
635 unlock_kernel(); 636 mutex_unlock(&pp_do_mutex);
636 return ret; 637 return ret;
637} 638}
638 639
@@ -641,7 +642,6 @@ static int pp_open (struct inode * inode, struct file * file)
641 unsigned int minor = iminor(inode); 642 unsigned int minor = iminor(inode);
642 struct pp_struct *pp; 643 struct pp_struct *pp;
643 644
644 cycle_kernel_lock();
645 if (minor >= PARPORT_MAX) 645 if (minor >= PARPORT_MAX)
646 return -ENXIO; 646 return -ENXIO;
647 647