diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-06-02 08:28:52 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2010-10-05 09:01:04 -0400 |
commit | 613655fa39ff6957754fa8ceb8559980920eb8ee (patch) | |
tree | ad19600cb81207b24188683d7fc4ae88013339d1 /drivers/pci | |
parent | 609146fdb319cebce93be550938ab852f7bade90 (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/pci')
-rw-r--r-- | drivers/pci/hotplug/cpqphp_sysfs.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c index 56215322930a..4cb30447a486 100644 --- a/drivers/pci/hotplug/cpqphp_sysfs.c +++ b/drivers/pci/hotplug/cpqphp_sysfs.c | |||
@@ -34,10 +34,11 @@ | |||
34 | #include <linux/workqueue.h> | 34 | #include <linux/workqueue.h> |
35 | #include <linux/pci.h> | 35 | #include <linux/pci.h> |
36 | #include <linux/pci_hotplug.h> | 36 | #include <linux/pci_hotplug.h> |
37 | #include <linux/smp_lock.h> | 37 | #include <linux/mutex.h> |
38 | #include <linux/debugfs.h> | 38 | #include <linux/debugfs.h> |
39 | #include "cpqphp.h" | 39 | #include "cpqphp.h" |
40 | 40 | ||
41 | static DEFINE_MUTEX(cpqphp_mutex); | ||
41 | static int show_ctrl (struct controller *ctrl, char *buf) | 42 | static int show_ctrl (struct controller *ctrl, char *buf) |
42 | { | 43 | { |
43 | char *out = buf; | 44 | char *out = buf; |
@@ -147,7 +148,7 @@ static int open(struct inode *inode, struct file *file) | |||
147 | struct ctrl_dbg *dbg; | 148 | struct ctrl_dbg *dbg; |
148 | int retval = -ENOMEM; | 149 | int retval = -ENOMEM; |
149 | 150 | ||
150 | lock_kernel(); | 151 | mutex_lock(&cpqphp_mutex); |
151 | dbg = kmalloc(sizeof(*dbg), GFP_KERNEL); | 152 | dbg = kmalloc(sizeof(*dbg), GFP_KERNEL); |
152 | if (!dbg) | 153 | if (!dbg) |
153 | goto exit; | 154 | goto exit; |
@@ -160,7 +161,7 @@ static int open(struct inode *inode, struct file *file) | |||
160 | file->private_data = dbg; | 161 | file->private_data = dbg; |
161 | retval = 0; | 162 | retval = 0; |
162 | exit: | 163 | exit: |
163 | unlock_kernel(); | 164 | mutex_unlock(&cpqphp_mutex); |
164 | return retval; | 165 | return retval; |
165 | } | 166 | } |
166 | 167 | ||
@@ -169,7 +170,7 @@ static loff_t lseek(struct file *file, loff_t off, int whence) | |||
169 | struct ctrl_dbg *dbg; | 170 | struct ctrl_dbg *dbg; |
170 | loff_t new = -1; | 171 | loff_t new = -1; |
171 | 172 | ||
172 | lock_kernel(); | 173 | mutex_lock(&cpqphp_mutex); |
173 | dbg = file->private_data; | 174 | dbg = file->private_data; |
174 | 175 | ||
175 | switch (whence) { | 176 | switch (whence) { |
@@ -181,10 +182,10 @@ static loff_t lseek(struct file *file, loff_t off, int whence) | |||
181 | break; | 182 | break; |
182 | } | 183 | } |
183 | if (new < 0 || new > dbg->size) { | 184 | if (new < 0 || new > dbg->size) { |
184 | unlock_kernel(); | 185 | mutex_unlock(&cpqphp_mutex); |
185 | return -EINVAL; | 186 | return -EINVAL; |
186 | } | 187 | } |
187 | unlock_kernel(); | 188 | mutex_unlock(&cpqphp_mutex); |
188 | return (file->f_pos = new); | 189 | return (file->f_pos = new); |
189 | } | 190 | } |
190 | 191 | ||