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/char/mwave | |
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/char/mwave')
-rw-r--r-- | drivers/char/mwave/mwavedd.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c index a4ec50c95072..e5df26b56d59 100644 --- a/drivers/char/mwave/mwavedd.c +++ b/drivers/char/mwave/mwavedd.c | |||
@@ -56,7 +56,7 @@ | |||
56 | #include <linux/serial.h> | 56 | #include <linux/serial.h> |
57 | #include <linux/sched.h> | 57 | #include <linux/sched.h> |
58 | #include <linux/spinlock.h> | 58 | #include <linux/spinlock.h> |
59 | #include <linux/smp_lock.h> | 59 | #include <linux/mutex.h> |
60 | #include <linux/delay.h> | 60 | #include <linux/delay.h> |
61 | #include <linux/serial_8250.h> | 61 | #include <linux/serial_8250.h> |
62 | #include "smapi.h" | 62 | #include "smapi.h" |
@@ -73,6 +73,7 @@ MODULE_LICENSE("GPL"); | |||
73 | * checks are made against other devices (ie. superio) for conflicts. | 73 | * checks are made against other devices (ie. superio) for conflicts. |
74 | * We'll depend on users using the tpctl utility to do that for now | 74 | * We'll depend on users using the tpctl utility to do that for now |
75 | */ | 75 | */ |
76 | static DEFINE_MUTEX(mwave_mutex); | ||
76 | int mwave_debug = 0; | 77 | int mwave_debug = 0; |
77 | int mwave_3780i_irq = 0; | 78 | int mwave_3780i_irq = 0; |
78 | int mwave_3780i_io = 0; | 79 | int mwave_3780i_io = 0; |
@@ -101,7 +102,6 @@ static int mwave_open(struct inode *inode, struct file *file) | |||
101 | PRINTK_2(TRACE_MWAVE, | 102 | PRINTK_2(TRACE_MWAVE, |
102 | "mwavedd::mwave_open, exit return retval %x\n", retval); | 103 | "mwavedd::mwave_open, exit return retval %x\n", retval); |
103 | 104 | ||
104 | cycle_kernel_lock(); | ||
105 | return retval; | 105 | return retval; |
106 | } | 106 | } |
107 | 107 | ||
@@ -136,9 +136,9 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, | |||
136 | PRINTK_1(TRACE_MWAVE, | 136 | PRINTK_1(TRACE_MWAVE, |
137 | "mwavedd::mwave_ioctl, IOCTL_MW_RESET" | 137 | "mwavedd::mwave_ioctl, IOCTL_MW_RESET" |
138 | " calling tp3780I_ResetDSP\n"); | 138 | " calling tp3780I_ResetDSP\n"); |
139 | lock_kernel(); | 139 | mutex_lock(&mwave_mutex); |
140 | retval = tp3780I_ResetDSP(&pDrvData->rBDData); | 140 | retval = tp3780I_ResetDSP(&pDrvData->rBDData); |
141 | unlock_kernel(); | 141 | mutex_unlock(&mwave_mutex); |
142 | PRINTK_2(TRACE_MWAVE, | 142 | PRINTK_2(TRACE_MWAVE, |
143 | "mwavedd::mwave_ioctl, IOCTL_MW_RESET" | 143 | "mwavedd::mwave_ioctl, IOCTL_MW_RESET" |
144 | " retval %x from tp3780I_ResetDSP\n", | 144 | " retval %x from tp3780I_ResetDSP\n", |
@@ -149,9 +149,9 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, | |||
149 | PRINTK_1(TRACE_MWAVE, | 149 | PRINTK_1(TRACE_MWAVE, |
150 | "mwavedd::mwave_ioctl, IOCTL_MW_RUN" | 150 | "mwavedd::mwave_ioctl, IOCTL_MW_RUN" |
151 | " calling tp3780I_StartDSP\n"); | 151 | " calling tp3780I_StartDSP\n"); |
152 | lock_kernel(); | 152 | mutex_lock(&mwave_mutex); |
153 | retval = tp3780I_StartDSP(&pDrvData->rBDData); | 153 | retval = tp3780I_StartDSP(&pDrvData->rBDData); |
154 | unlock_kernel(); | 154 | mutex_unlock(&mwave_mutex); |
155 | PRINTK_2(TRACE_MWAVE, | 155 | PRINTK_2(TRACE_MWAVE, |
156 | "mwavedd::mwave_ioctl, IOCTL_MW_RUN" | 156 | "mwavedd::mwave_ioctl, IOCTL_MW_RUN" |
157 | " retval %x from tp3780I_StartDSP\n", | 157 | " retval %x from tp3780I_StartDSP\n", |
@@ -165,10 +165,10 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, | |||
165 | "mwavedd::mwave_ioctl," | 165 | "mwavedd::mwave_ioctl," |
166 | " IOCTL_MW_DSP_ABILITIES calling" | 166 | " IOCTL_MW_DSP_ABILITIES calling" |
167 | " tp3780I_QueryAbilities\n"); | 167 | " tp3780I_QueryAbilities\n"); |
168 | lock_kernel(); | 168 | mutex_lock(&mwave_mutex); |
169 | retval = tp3780I_QueryAbilities(&pDrvData->rBDData, | 169 | retval = tp3780I_QueryAbilities(&pDrvData->rBDData, |
170 | &rAbilities); | 170 | &rAbilities); |
171 | unlock_kernel(); | 171 | mutex_unlock(&mwave_mutex); |
172 | PRINTK_2(TRACE_MWAVE, | 172 | PRINTK_2(TRACE_MWAVE, |
173 | "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" | 173 | "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" |
174 | " retval %x from tp3780I_QueryAbilities\n", | 174 | " retval %x from tp3780I_QueryAbilities\n", |
@@ -199,13 +199,13 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, | |||
199 | "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," | 199 | "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," |
200 | " size %lx, ioarg %lx pusBuffer %p\n", | 200 | " size %lx, ioarg %lx pusBuffer %p\n", |
201 | rReadData.ulDataLength, ioarg, pusBuffer); | 201 | rReadData.ulDataLength, ioarg, pusBuffer); |
202 | lock_kernel(); | 202 | mutex_lock(&mwave_mutex); |
203 | retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, | 203 | retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, |
204 | iocmd, | 204 | iocmd, |
205 | pusBuffer, | 205 | pusBuffer, |
206 | rReadData.ulDataLength, | 206 | rReadData.ulDataLength, |
207 | rReadData.usDspAddress); | 207 | rReadData.usDspAddress); |
208 | unlock_kernel(); | 208 | mutex_unlock(&mwave_mutex); |
209 | } | 209 | } |
210 | break; | 210 | break; |
211 | 211 | ||
@@ -223,12 +223,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, | |||
223 | " size %lx, ioarg %lx pusBuffer %p\n", | 223 | " size %lx, ioarg %lx pusBuffer %p\n", |
224 | rReadData.ulDataLength / 2, ioarg, | 224 | rReadData.ulDataLength / 2, ioarg, |
225 | pusBuffer); | 225 | pusBuffer); |
226 | lock_kernel(); | 226 | mutex_lock(&mwave_mutex); |
227 | retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, | 227 | retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, |
228 | iocmd, pusBuffer, | 228 | iocmd, pusBuffer, |
229 | rReadData.ulDataLength / 2, | 229 | rReadData.ulDataLength / 2, |
230 | rReadData.usDspAddress); | 230 | rReadData.usDspAddress); |
231 | unlock_kernel(); | 231 | mutex_unlock(&mwave_mutex); |
232 | } | 232 | } |
233 | break; | 233 | break; |
234 | 234 | ||
@@ -246,12 +246,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, | |||
246 | " size %lx, ioarg %lx pusBuffer %p\n", | 246 | " size %lx, ioarg %lx pusBuffer %p\n", |
247 | rWriteData.ulDataLength, ioarg, | 247 | rWriteData.ulDataLength, ioarg, |
248 | pusBuffer); | 248 | pusBuffer); |
249 | lock_kernel(); | 249 | mutex_lock(&mwave_mutex); |
250 | retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, | 250 | retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, |
251 | iocmd, pusBuffer, | 251 | iocmd, pusBuffer, |
252 | rWriteData.ulDataLength, | 252 | rWriteData.ulDataLength, |
253 | rWriteData.usDspAddress); | 253 | rWriteData.usDspAddress); |
254 | unlock_kernel(); | 254 | mutex_unlock(&mwave_mutex); |
255 | } | 255 | } |
256 | break; | 256 | break; |
257 | 257 | ||
@@ -269,12 +269,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, | |||
269 | " size %lx, ioarg %lx pusBuffer %p\n", | 269 | " size %lx, ioarg %lx pusBuffer %p\n", |
270 | rWriteData.ulDataLength, ioarg, | 270 | rWriteData.ulDataLength, ioarg, |
271 | pusBuffer); | 271 | pusBuffer); |
272 | lock_kernel(); | 272 | mutex_lock(&mwave_mutex); |
273 | retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, | 273 | retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, |
274 | iocmd, pusBuffer, | 274 | iocmd, pusBuffer, |
275 | rWriteData.ulDataLength, | 275 | rWriteData.ulDataLength, |
276 | rWriteData.usDspAddress); | 276 | rWriteData.usDspAddress); |
277 | unlock_kernel(); | 277 | mutex_unlock(&mwave_mutex); |
278 | } | 278 | } |
279 | break; | 279 | break; |
280 | 280 | ||
@@ -295,10 +295,10 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, | |||
295 | ipcnum, | 295 | ipcnum, |
296 | pDrvData->IPCs[ipcnum].usIntCount); | 296 | pDrvData->IPCs[ipcnum].usIntCount); |
297 | 297 | ||
298 | lock_kernel(); | 298 | mutex_lock(&mwave_mutex); |
299 | pDrvData->IPCs[ipcnum].bIsHere = FALSE; | 299 | pDrvData->IPCs[ipcnum].bIsHere = FALSE; |
300 | pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; | 300 | pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; |
301 | unlock_kernel(); | 301 | mutex_unlock(&mwave_mutex); |
302 | 302 | ||
303 | PRINTK_2(TRACE_MWAVE, | 303 | PRINTK_2(TRACE_MWAVE, |
304 | "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" | 304 | "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" |
@@ -323,7 +323,7 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, | |||
323 | ipcnum, | 323 | ipcnum, |
324 | pDrvData->IPCs[ipcnum].usIntCount); | 324 | pDrvData->IPCs[ipcnum].usIntCount); |
325 | 325 | ||
326 | lock_kernel(); | 326 | mutex_lock(&mwave_mutex); |
327 | if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { | 327 | if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { |
328 | DECLARE_WAITQUEUE(wait, current); | 328 | DECLARE_WAITQUEUE(wait, current); |
329 | 329 | ||
@@ -364,7 +364,7 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, | |||
364 | " processing\n", | 364 | " processing\n", |
365 | ipcnum); | 365 | ipcnum); |
366 | } | 366 | } |
367 | unlock_kernel(); | 367 | mutex_unlock(&mwave_mutex); |
368 | } | 368 | } |
369 | break; | 369 | break; |
370 | 370 | ||
@@ -383,14 +383,14 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, | |||
383 | ipcnum); | 383 | ipcnum); |
384 | return -EINVAL; | 384 | return -EINVAL; |
385 | } | 385 | } |
386 | lock_kernel(); | 386 | mutex_lock(&mwave_mutex); |
387 | if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { | 387 | if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { |
388 | pDrvData->IPCs[ipcnum].bIsEnabled = FALSE; | 388 | pDrvData->IPCs[ipcnum].bIsEnabled = FALSE; |
389 | if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) { | 389 | if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) { |
390 | wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue); | 390 | wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue); |
391 | } | 391 | } |
392 | } | 392 | } |
393 | unlock_kernel(); | 393 | mutex_unlock(&mwave_mutex); |
394 | } | 394 | } |
395 | break; | 395 | break; |
396 | 396 | ||