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>

+216 -190
+4 -3
drivers/block/paride/pg.c
··· 162 #include <linux/pg.h> 163 #include <linux/device.h> 164 #include <linux/sched.h> /* current, TASK_* */ 165 - #include <linux/smp_lock.h> 166 #include <linux/jiffies.h> 167 168 #include <asm/uaccess.h> ··· 193 194 #define ATAPI_IDENTIFY 0x12 195 196 static int pg_open(struct inode *inode, struct file *file); 197 static int pg_release(struct inode *inode, struct file *file); 198 static ssize_t pg_read(struct file *filp, char __user *buf, ··· 519 struct pg *dev = &devices[unit]; 520 int ret = 0; 521 522 - lock_kernel(); 523 if ((unit >= PG_UNITS) || (!dev->present)) { 524 ret = -ENODEV; 525 goto out; ··· 548 file->private_data = dev; 549 550 out: 551 - unlock_kernel(); 552 return ret; 553 } 554
··· 162 #include <linux/pg.h> 163 #include <linux/device.h> 164 #include <linux/sched.h> /* current, TASK_* */ 165 + #include <linux/mutex.h> 166 #include <linux/jiffies.h> 167 168 #include <asm/uaccess.h> ··· 193 194 #define ATAPI_IDENTIFY 0x12 195 196 + static DEFINE_MUTEX(pg_mutex); 197 static int pg_open(struct inode *inode, struct file *file); 198 static int pg_release(struct inode *inode, struct file *file); 199 static ssize_t pg_read(struct file *filp, char __user *buf, ··· 518 struct pg *dev = &devices[unit]; 519 int ret = 0; 520 521 + mutex_lock(&pg_mutex); 522 if ((unit >= PG_UNITS) || (!dev->present)) { 523 ret = -ENODEV; 524 goto out; ··· 547 file->private_data = dev; 548 549 out: 550 + mutex_unlock(&pg_mutex); 551 return ret; 552 } 553
+10 -9
drivers/block/paride/pt.c
··· 146 #include <linux/mtio.h> 147 #include <linux/device.h> 148 #include <linux/sched.h> /* current, TASK_*, schedule_timeout() */ 149 - #include <linux/smp_lock.h> 150 151 #include <asm/uaccess.h> 152 ··· 189 #define ATAPI_MODE_SENSE 0x1a 190 #define ATAPI_LOG_SENSE 0x4d 191 192 static int pt_open(struct inode *inode, struct file *file); 193 static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 194 static int pt_release(struct inode *inode, struct file *file); ··· 651 struct pt_unit *tape = pt + unit; 652 int err; 653 654 - lock_kernel(); 655 if (unit >= PT_UNITS || (!tape->present)) { 656 - unlock_kernel(); 657 return -ENODEV; 658 } 659 ··· 682 } 683 684 file->private_data = tape; 685 - unlock_kernel(); 686 return 0; 687 688 out: 689 atomic_inc(&tape->available); 690 - unlock_kernel(); 691 return err; 692 } 693 ··· 705 switch (mtop.mt_op) { 706 707 case MTREW: 708 - lock_kernel(); 709 pt_rewind(tape); 710 - unlock_kernel(); 711 return 0; 712 713 case MTWEOF: 714 - lock_kernel(); 715 pt_write_fm(tape); 716 - unlock_kernel(); 717 return 0; 718 719 default:
··· 146 #include <linux/mtio.h> 147 #include <linux/device.h> 148 #include <linux/sched.h> /* current, TASK_*, schedule_timeout() */ 149 + #include <linux/mutex.h> 150 151 #include <asm/uaccess.h> 152 ··· 189 #define ATAPI_MODE_SENSE 0x1a 190 #define ATAPI_LOG_SENSE 0x4d 191 192 + static DEFINE_MUTEX(pt_mutex); 193 static int pt_open(struct inode *inode, struct file *file); 194 static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 195 static int pt_release(struct inode *inode, struct file *file); ··· 650 struct pt_unit *tape = pt + unit; 651 int err; 652 653 + mutex_lock(&pt_mutex); 654 if (unit >= PT_UNITS || (!tape->present)) { 655 + mutex_unlock(&pt_mutex); 656 return -ENODEV; 657 } 658 ··· 681 } 682 683 file->private_data = tape; 684 + mutex_unlock(&pt_mutex); 685 return 0; 686 687 out: 688 atomic_inc(&tape->available); 689 + mutex_unlock(&pt_mutex); 690 return err; 691 } 692 ··· 704 switch (mtop.mt_op) { 705 706 case MTREW: 707 + mutex_lock(&pt_mutex); 708 pt_rewind(tape); 709 + mutex_unlock(&pt_mutex); 710 return 0; 711 712 case MTWEOF: 713 + mutex_lock(&pt_mutex); 714 pt_write_fm(tape); 715 + mutex_unlock(&pt_mutex); 716 return 0; 717 718 default:
+6 -5
drivers/char/apm-emulation.c
··· 13 #include <linux/module.h> 14 #include <linux/poll.h> 15 #include <linux/slab.h> 16 - #include <linux/smp_lock.h> 17 #include <linux/proc_fs.h> 18 #include <linux/seq_file.h> 19 #include <linux/miscdevice.h> ··· 126 /* 127 * Local variables 128 */ 129 static atomic_t suspend_acks_pending = ATOMIC_INIT(0); 130 static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0); 131 static int apm_disabled; ··· 275 if (!as->suser || !as->writer) 276 return -EPERM; 277 278 - lock_kernel(); 279 switch (cmd) { 280 case APM_IOC_SUSPEND: 281 mutex_lock(&state_lock); ··· 336 mutex_unlock(&state_lock); 337 break; 338 } 339 - unlock_kernel(); 340 341 return err; 342 } ··· 371 { 372 struct apm_user *as; 373 374 - lock_kernel(); 375 as = kzalloc(sizeof(*as), GFP_KERNEL); 376 if (as) { 377 /* ··· 391 392 filp->private_data = as; 393 } 394 - unlock_kernel(); 395 396 return as ? 0 : -ENOMEM; 397 }
··· 13 #include <linux/module.h> 14 #include <linux/poll.h> 15 #include <linux/slab.h> 16 + #include <linux/mutex.h> 17 #include <linux/proc_fs.h> 18 #include <linux/seq_file.h> 19 #include <linux/miscdevice.h> ··· 126 /* 127 * Local variables 128 */ 129 + static DEFINE_MUTEX(apm_mutex); 130 static atomic_t suspend_acks_pending = ATOMIC_INIT(0); 131 static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0); 132 static int apm_disabled; ··· 274 if (!as->suser || !as->writer) 275 return -EPERM; 276 277 + mutex_lock(&apm_mutex); 278 switch (cmd) { 279 case APM_IOC_SUSPEND: 280 mutex_lock(&state_lock); ··· 335 mutex_unlock(&state_lock); 336 break; 337 } 338 + mutex_unlock(&apm_mutex); 339 340 return err; 341 } ··· 370 { 371 struct apm_user *as; 372 373 + mutex_lock(&apm_mutex); 374 as = kzalloc(sizeof(*as), GFP_KERNEL); 375 if (as) { 376 /* ··· 390 391 filp->private_data = as; 392 } 393 + mutex_unlock(&apm_mutex); 394 395 return as ? 0 : -ENOMEM; 396 }
+5 -4
drivers/char/applicom.c
··· 26 #include <linux/sched.h> 27 #include <linux/slab.h> 28 #include <linux/errno.h> 29 - #include <linux/smp_lock.h> 30 #include <linux/miscdevice.h> 31 #include <linux/pci.h> 32 #include <linux/wait.h> ··· 60 #define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003 61 #endif 62 63 static char *applicom_pci_devnames[] = { 64 "PCI board", 65 "PCI2000IBS / PCI2000CAN", ··· 708 if (IS_ERR(adgl)) 709 return PTR_ERR(adgl); 710 711 - lock_kernel(); 712 IndexCard = adgl->num_card-1; 713 714 if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) { ··· 718 warncount--; 719 } 720 kfree(adgl); 721 - unlock_kernel(); 722 return -EINVAL; 723 } 724 ··· 836 } 837 Dummy = readb(apbs[IndexCard].RamIO + VERS); 838 kfree(adgl); 839 - unlock_kernel(); 840 return 0; 841 } 842
··· 26 #include <linux/sched.h> 27 #include <linux/slab.h> 28 #include <linux/errno.h> 29 + #include <linux/mutex.h> 30 #include <linux/miscdevice.h> 31 #include <linux/pci.h> 32 #include <linux/wait.h> ··· 60 #define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003 61 #endif 62 63 + static DEFINE_MUTEX(ac_mutex); 64 static char *applicom_pci_devnames[] = { 65 "PCI board", 66 "PCI2000IBS / PCI2000CAN", ··· 707 if (IS_ERR(adgl)) 708 return PTR_ERR(adgl); 709 710 + mutex_lock(&ac_mutex); 711 IndexCard = adgl->num_card-1; 712 713 if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) { ··· 717 warncount--; 718 } 719 kfree(adgl); 720 + mutex_unlock(&ac_mutex); 721 return -EINVAL; 722 } 723 ··· 835 } 836 Dummy = readb(apbs[IndexCard].RamIO + VERS); 837 kfree(adgl); 838 + mutex_unlock(&ac_mutex); 839 return 0; 840 } 841
+8 -7
drivers/char/ds1302.c
··· 20 #include <linux/miscdevice.h> 21 #include <linux/delay.h> 22 #include <linux/bcd.h> 23 - #include <linux/smp_lock.h> 24 #include <linux/uaccess.h> 25 #include <linux/io.h> 26 ··· 32 33 #define RTC_MAJOR_NR 121 /* local major, change later */ 34 35 static const char ds1302_name[] = "ds1302"; 36 37 /* Send 8 bits. */ ··· 165 struct rtc_time rtc_tm; 166 167 memset(&rtc_tm, 0, sizeof (struct rtc_time)); 168 - lock_kernel(); 169 get_rtc_time(&rtc_tm); 170 - unlock_kernel(); 171 if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time))) 172 return -EFAULT; 173 return 0; ··· 219 mon = bin2bcd(mon); 220 yrs = bin2bcd(yrs); 221 222 - lock_kernel(); 223 local_irq_save(flags); 224 CMOS_WRITE(yrs, RTC_YEAR); 225 CMOS_WRITE(mon, RTC_MONTH); ··· 228 CMOS_WRITE(min, RTC_MINUTES); 229 CMOS_WRITE(sec, RTC_SECONDS); 230 local_irq_restore(flags); 231 - unlock_kernel(); 232 233 /* Notice that at this point, the RTC is updated but 234 * the kernel is still running with the old time. ··· 248 if(copy_from_user(&tcs_val, (int*)arg, sizeof(int))) 249 return -EFAULT; 250 251 - lock_kernel(); 252 tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F); 253 ds1302_writereg(RTC_TRICKLECHARGER, tcs_val); 254 - unlock_kernel(); 255 return 0; 256 } 257 default:
··· 20 #include <linux/miscdevice.h> 21 #include <linux/delay.h> 22 #include <linux/bcd.h> 23 + #include <linux/mutex.h> 24 #include <linux/uaccess.h> 25 #include <linux/io.h> 26 ··· 32 33 #define RTC_MAJOR_NR 121 /* local major, change later */ 34 35 + static DEFINE_MUTEX(rtc_mutex); 36 static const char ds1302_name[] = "ds1302"; 37 38 /* Send 8 bits. */ ··· 164 struct rtc_time rtc_tm; 165 166 memset(&rtc_tm, 0, sizeof (struct rtc_time)); 167 + mutex_lock(&rtc_mutex); 168 get_rtc_time(&rtc_tm); 169 + mutex_unlock(&rtc_mutex); 170 if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time))) 171 return -EFAULT; 172 return 0; ··· 218 mon = bin2bcd(mon); 219 yrs = bin2bcd(yrs); 220 221 + mutex_lock(&rtc_mutex); 222 local_irq_save(flags); 223 CMOS_WRITE(yrs, RTC_YEAR); 224 CMOS_WRITE(mon, RTC_MONTH); ··· 227 CMOS_WRITE(min, RTC_MINUTES); 228 CMOS_WRITE(sec, RTC_SECONDS); 229 local_irq_restore(flags); 230 + mutex_unlock(&rtc_mutex); 231 232 /* Notice that at this point, the RTC is updated but 233 * the kernel is still running with the old time. ··· 247 if(copy_from_user(&tcs_val, (int*)arg, sizeof(int))) 248 return -EFAULT; 249 250 + mutex_lock(&rtc_mutex); 251 tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F); 252 ds1302_writereg(RTC_TRICKLECHARGER, tcs_val); 253 + mutex_unlock(&rtc_mutex); 254 return 0; 255 } 256 default:
+4 -4
drivers/char/ds1620.c
··· 8 #include <linux/proc_fs.h> 9 #include <linux/capability.h> 10 #include <linux/init.h> 11 - #include <linux/smp_lock.h> 12 13 #include <mach/hardware.h> 14 #include <asm/mach-types.h> ··· 34 #define CFG_CPU 2 35 #define CFG_1SHOT 1 36 37 static const char *fan_state[] = { "off", "on", "on (hardwired)" }; 38 39 /* ··· 211 212 static int ds1620_open(struct inode *inode, struct file *file) 213 { 214 - cycle_kernel_lock(); 215 return nonseekable_open(inode, file); 216 } 217 ··· 321 { 322 int ret; 323 324 - lock_kernel(); 325 ret = ds1620_ioctl(file, cmd, arg); 326 - unlock_kernel(); 327 328 return ret; 329 }
··· 8 #include <linux/proc_fs.h> 9 #include <linux/capability.h> 10 #include <linux/init.h> 11 + #include <linux/mutex.h> 12 13 #include <mach/hardware.h> 14 #include <asm/mach-types.h> ··· 34 #define CFG_CPU 2 35 #define CFG_1SHOT 1 36 37 + static DEFINE_MUTEX(ds1620_mutex); 38 static const char *fan_state[] = { "off", "on", "on (hardwired)" }; 39 40 /* ··· 210 211 static int ds1620_open(struct inode *inode, struct file *file) 212 { 213 return nonseekable_open(inode, file); 214 } 215 ··· 321 { 322 int ret; 323 324 + mutex_lock(&ds1620_mutex); 325 ret = ds1620_ioctl(file, cmd, arg); 326 + mutex_unlock(&ds1620_mutex); 327 328 return ret; 329 }
+14 -13
drivers/char/dsp56k.c
··· 32 #include <linux/mm.h> 33 #include <linux/init.h> 34 #include <linux/device.h> 35 - #include <linux/smp_lock.h> 36 #include <linux/firmware.h> 37 #include <linux/platform_device.h> 38 #include <linux/uaccess.h> /* For put_user and get_user */ ··· 94 } \ 95 } 96 97 static struct dsp56k_device { 98 unsigned long in_use; 99 long maxio, timeout; ··· 331 if (len > DSP56K_MAX_BINARY_LENGTH) { 332 return -EINVAL; 333 } 334 - lock_kernel(); 335 r = dsp56k_upload(bin, len); 336 - unlock_kernel(); 337 if (r < 0) { 338 return r; 339 } ··· 343 case DSP56K_SET_TX_WSIZE: 344 if (arg > 4 || arg < 1) 345 return -EINVAL; 346 - lock_kernel(); 347 dsp56k.tx_wsize = (int) arg; 348 - unlock_kernel(); 349 break; 350 case DSP56K_SET_RX_WSIZE: 351 if (arg > 4 || arg < 1) 352 return -EINVAL; 353 - lock_kernel(); 354 dsp56k.rx_wsize = (int) arg; 355 - unlock_kernel(); 356 break; 357 case DSP56K_HOST_FLAGS: 358 { ··· 364 if(get_user(out, &hf->out) < 0) 365 return -EFAULT; 366 367 - lock_kernel(); 368 if ((dir & 0x1) && (out & 0x1)) 369 dsp56k_host_interface.icr |= DSP56K_ICR_HF0; 370 else if (dir & 0x1) ··· 379 if (dsp56k_host_interface.icr & DSP56K_ICR_HF1) status |= 0x2; 380 if (dsp56k_host_interface.isr & DSP56K_ISR_HF2) status |= 0x4; 381 if (dsp56k_host_interface.isr & DSP56K_ISR_HF3) status |= 0x8; 382 - unlock_kernel(); 383 return put_user(status, &hf->status); 384 } 385 case DSP56K_HOST_CMD: 386 if (arg > 31 || arg < 0) 387 return -EINVAL; 388 - lock_kernel(); 389 dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) | 390 DSP56K_CVR_HC); 391 - unlock_kernel(); 392 break; 393 default: 394 return -EINVAL; ··· 428 int dev = iminor(inode) & 0x0f; 429 int ret = 0; 430 431 - lock_kernel(); 432 switch(dev) 433 { 434 case DSP56K_DEV_56001: ··· 455 ret = -ENODEV; 456 } 457 out: 458 - unlock_kernel(); 459 return ret; 460 } 461
··· 32 #include <linux/mm.h> 33 #include <linux/init.h> 34 #include <linux/device.h> 35 + #include <linux/mutex.h> 36 #include <linux/firmware.h> 37 #include <linux/platform_device.h> 38 #include <linux/uaccess.h> /* For put_user and get_user */ ··· 94 } \ 95 } 96 97 + static DEFINE_MUTEX(dsp56k_mutex); 98 static struct dsp56k_device { 99 unsigned long in_use; 100 long maxio, timeout; ··· 330 if (len > DSP56K_MAX_BINARY_LENGTH) { 331 return -EINVAL; 332 } 333 + mutex_lock(&dsp56k_mutex); 334 r = dsp56k_upload(bin, len); 335 + mutex_unlock(&dsp56k_mutex); 336 if (r < 0) { 337 return r; 338 } ··· 342 case DSP56K_SET_TX_WSIZE: 343 if (arg > 4 || arg < 1) 344 return -EINVAL; 345 + mutex_lock(&dsp56k_mutex); 346 dsp56k.tx_wsize = (int) arg; 347 + mutex_unlock(&dsp56k_mutex); 348 break; 349 case DSP56K_SET_RX_WSIZE: 350 if (arg > 4 || arg < 1) 351 return -EINVAL; 352 + mutex_lock(&dsp56k_mutex); 353 dsp56k.rx_wsize = (int) arg; 354 + mutex_unlock(&dsp56k_mutex); 355 break; 356 case DSP56K_HOST_FLAGS: 357 { ··· 363 if(get_user(out, &hf->out) < 0) 364 return -EFAULT; 365 366 + mutex_lock(&dsp56k_mutex); 367 if ((dir & 0x1) && (out & 0x1)) 368 dsp56k_host_interface.icr |= DSP56K_ICR_HF0; 369 else if (dir & 0x1) ··· 378 if (dsp56k_host_interface.icr & DSP56K_ICR_HF1) status |= 0x2; 379 if (dsp56k_host_interface.isr & DSP56K_ISR_HF2) status |= 0x4; 380 if (dsp56k_host_interface.isr & DSP56K_ISR_HF3) status |= 0x8; 381 + mutex_unlock(&dsp56k_mutex); 382 return put_user(status, &hf->status); 383 } 384 case DSP56K_HOST_CMD: 385 if (arg > 31 || arg < 0) 386 return -EINVAL; 387 + mutex_lock(&dsp56k_mutex); 388 dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) | 389 DSP56K_CVR_HC); 390 + mutex_unlock(&dsp56k_mutex); 391 break; 392 default: 393 return -EINVAL; ··· 427 int dev = iminor(inode) & 0x0f; 428 int ret = 0; 429 430 + mutex_lock(&dsp56k_mutex); 431 switch(dev) 432 { 433 case DSP56K_DEV_56001: ··· 454 ret = -ENODEV; 455 } 456 out: 457 + mutex_unlock(&dsp56k_mutex); 458 return ret; 459 } 460
+4 -4
drivers/char/dtlk.c
··· 57 #include <linux/ioport.h> /* for request_region */ 58 #include <linux/delay.h> /* for loops_per_jiffy */ 59 #include <linux/sched.h> 60 - #include <linux/smp_lock.h> /* cycle_kernel_lock() */ 61 #include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */ 62 #include <asm/uaccess.h> /* for get_user, etc. */ 63 #include <linux/wait.h> /* for wait_queue */ ··· 73 #define TRACE_RET ((void) 0) 74 #endif /* TRACING */ 75 76 static void dtlk_timer_tick(unsigned long data); 77 78 static int dtlk_major; ··· 276 switch (cmd) { 277 278 case DTLK_INTERROGATE: 279 - lock_kernel(); 280 sp = dtlk_interrogate(); 281 - unlock_kernel(); 282 if (copy_to_user(argp, sp, sizeof(struct dtlk_settings))) 283 return -EINVAL; 284 return 0; ··· 297 { 298 TRACE_TEXT("(dtlk_open"); 299 300 - cycle_kernel_lock(); 301 nonseekable_open(inode, file); 302 switch (iminor(inode)) { 303 case DTLK_MINOR:
··· 57 #include <linux/ioport.h> /* for request_region */ 58 #include <linux/delay.h> /* for loops_per_jiffy */ 59 #include <linux/sched.h> 60 + #include <linux/mutex.h> 61 #include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */ 62 #include <asm/uaccess.h> /* for get_user, etc. */ 63 #include <linux/wait.h> /* for wait_queue */ ··· 73 #define TRACE_RET ((void) 0) 74 #endif /* TRACING */ 75 76 + static DEFINE_MUTEX(dtlk_mutex); 77 static void dtlk_timer_tick(unsigned long data); 78 79 static int dtlk_major; ··· 275 switch (cmd) { 276 277 case DTLK_INTERROGATE: 278 + mutex_lock(&dtlk_mutex); 279 sp = dtlk_interrogate(); 280 + mutex_unlock(&dtlk_mutex); 281 if (copy_to_user(argp, sp, sizeof(struct dtlk_settings))) 282 return -EINVAL; 283 return 0; ··· 296 { 297 TRACE_TEXT("(dtlk_open"); 298 299 nonseekable_open(inode, file); 300 switch (iminor(inode)) { 301 case DTLK_MINOR:
+4 -3
drivers/char/generic_nvram.c
··· 19 #include <linux/miscdevice.h> 20 #include <linux/fcntl.h> 21 #include <linux/init.h> 22 - #include <linux/smp_lock.h> 23 #include <asm/uaccess.h> 24 #include <asm/nvram.h> 25 #ifdef CONFIG_PPC_PMAC ··· 28 29 #define NVRAM_SIZE 8192 30 31 static ssize_t nvram_len; 32 33 static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) ··· 121 { 122 int ret; 123 124 - lock_kernel(); 125 ret = nvram_ioctl(file, cmd, arg); 126 - unlock_kernel(); 127 128 return ret; 129 }
··· 19 #include <linux/miscdevice.h> 20 #include <linux/fcntl.h> 21 #include <linux/init.h> 22 + #include <linux/mutex.h> 23 #include <asm/uaccess.h> 24 #include <asm/nvram.h> 25 #ifdef CONFIG_PPC_PMAC ··· 28 29 #define NVRAM_SIZE 8192 30 31 + static DEFINE_MUTEX(nvram_mutex); 32 static ssize_t nvram_len; 33 34 static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) ··· 120 { 121 int ret; 122 123 + mutex_lock(&nvram_mutex); 124 ret = nvram_ioctl(file, cmd, arg); 125 + mutex_unlock(&nvram_mutex); 126 127 return ret; 128 }
+7 -6
drivers/char/genrtc.c
··· 52 #include <linux/init.h> 53 #include <linux/poll.h> 54 #include <linux/proc_fs.h> 55 - #include <linux/smp_lock.h> 56 #include <linux/workqueue.h> 57 58 #include <asm/uaccess.h> ··· 66 * ioctls. 67 */ 68 69 static DECLARE_WAIT_QUEUE_HEAD(gen_rtc_wait); 70 71 /* ··· 338 { 339 int ret; 340 341 - lock_kernel(); 342 ret = gen_rtc_ioctl(file, cmd, arg); 343 - unlock_kernel(); 344 345 return ret; 346 } ··· 353 354 static int gen_rtc_open(struct inode *inode, struct file *file) 355 { 356 - lock_kernel(); 357 if (gen_rtc_status & RTC_IS_OPEN) { 358 - unlock_kernel(); 359 return -EBUSY; 360 } 361 362 gen_rtc_status |= RTC_IS_OPEN; 363 gen_rtc_irq_data = 0; 364 irq_active = 0; 365 - unlock_kernel(); 366 367 return 0; 368 }
··· 52 #include <linux/init.h> 53 #include <linux/poll.h> 54 #include <linux/proc_fs.h> 55 + #include <linux/mutex.h> 56 #include <linux/workqueue.h> 57 58 #include <asm/uaccess.h> ··· 66 * ioctls. 67 */ 68 69 + static DEFINE_MUTEX(gen_rtc_mutex); 70 static DECLARE_WAIT_QUEUE_HEAD(gen_rtc_wait); 71 72 /* ··· 337 { 338 int ret; 339 340 + mutex_lock(&gen_rtc_mutex); 341 ret = gen_rtc_ioctl(file, cmd, arg); 342 + mutex_unlock(&gen_rtc_mutex); 343 344 return ret; 345 } ··· 352 353 static int gen_rtc_open(struct inode *inode, struct file *file) 354 { 355 + mutex_lock(&gen_rtc_mutex); 356 if (gen_rtc_status & RTC_IS_OPEN) { 357 + mutex_unlock(&gen_rtc_mutex); 358 return -EBUSY; 359 } 360 361 gen_rtc_status |= RTC_IS_OPEN; 362 gen_rtc_irq_data = 0; 363 irq_active = 0; 364 + mutex_unlock(&gen_rtc_mutex); 365 366 return 0; 367 }
+4 -3
drivers/char/i8k.c
··· 23 #include <linux/seq_file.h> 24 #include <linux/dmi.h> 25 #include <linux/capability.h> 26 - #include <linux/smp_lock.h> 27 #include <asm/uaccess.h> 28 #include <asm/io.h> 29 ··· 56 57 #define I8K_TEMPERATURE_BUG 1 58 59 static char bios_version[4]; 60 61 MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)"); ··· 400 { 401 long ret; 402 403 - lock_kernel(); 404 ret = i8k_ioctl_unlocked(fp, cmd, arg); 405 - unlock_kernel(); 406 407 return ret; 408 }
··· 23 #include <linux/seq_file.h> 24 #include <linux/dmi.h> 25 #include <linux/capability.h> 26 + #include <linux/mutex.h> 27 #include <asm/uaccess.h> 28 #include <asm/io.h> 29 ··· 56 57 #define I8K_TEMPERATURE_BUG 1 58 59 + static DEFINE_MUTEX(i8k_mutex); 60 static char bios_version[4]; 61 62 MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)"); ··· 399 { 400 long ret; 401 402 + mutex_lock(&i8k_mutex); 403 ret = i8k_ioctl_unlocked(fp, cmd, arg); 404 + mutex_unlock(&i8k_mutex); 405 406 return ret; 407 }
+4 -4
drivers/char/ip2/ip2main.c
··· 98 #include <linux/major.h> 99 #include <linux/wait.h> 100 #include <linux/device.h> 101 - #include <linux/smp_lock.h> 102 #include <linux/firmware.h> 103 #include <linux/platform_device.h> 104 ··· 138 #include <linux/proc_fs.h> 139 #include <linux/seq_file.h> 140 141 static const struct file_operations ip2mem_proc_fops; 142 static const struct file_operations ip2_proc_fops; 143 ··· 2898 printk (KERN_DEBUG "IP2IPL: ioctl cmd %d, arg %ld\n", cmd, arg ); 2899 #endif 2900 2901 - lock_kernel(); 2902 2903 switch ( iplminor ) { 2904 case 0: // IPL device ··· 2962 rc = -ENODEV; 2963 break; 2964 } 2965 - unlock_kernel(); 2966 return rc; 2967 } 2968 ··· 2983 #ifdef IP2DEBUG_IPL 2984 printk (KERN_DEBUG "IP2IPL: open\n" ); 2985 #endif 2986 - cycle_kernel_lock(); 2987 return 0; 2988 } 2989
··· 98 #include <linux/major.h> 99 #include <linux/wait.h> 100 #include <linux/device.h> 101 + #include <linux/mutex.h> 102 #include <linux/firmware.h> 103 #include <linux/platform_device.h> 104 ··· 138 #include <linux/proc_fs.h> 139 #include <linux/seq_file.h> 140 141 + static DEFINE_MUTEX(ip2_mutex); 142 static const struct file_operations ip2mem_proc_fops; 143 static const struct file_operations ip2_proc_fops; 144 ··· 2897 printk (KERN_DEBUG "IP2IPL: ioctl cmd %d, arg %ld\n", cmd, arg ); 2898 #endif 2899 2900 + mutex_lock(&ip2_mutex); 2901 2902 switch ( iplminor ) { 2903 case 0: // IPL device ··· 2961 rc = -ENODEV; 2962 break; 2963 } 2964 + mutex_unlock(&ip2_mutex); 2965 return rc; 2966 } 2967 ··· 2982 #ifdef IP2DEBUG_IPL 2983 printk (KERN_DEBUG "IP2IPL: open\n" ); 2984 #endif 2985 return 0; 2986 } 2987
+8 -7
drivers/char/lp.c
··· 126 #include <linux/device.h> 127 #include <linux/wait.h> 128 #include <linux/jiffies.h> 129 - #include <linux/smp_lock.h> 130 #include <linux/compat.h> 131 132 #include <linux/parport.h> ··· 140 /* if you have more than 8 printers, remember to increase LP_NO */ 141 #define LP_NO 8 142 143 static struct lp_struct lp_table[LP_NO]; 144 145 static unsigned int lp_count = 0; ··· 494 unsigned int minor = iminor(inode); 495 int ret = 0; 496 497 - lock_kernel(); 498 if (minor >= LP_NO) { 499 ret = -ENXIO; 500 goto out; ··· 555 lp_release_parport (&lp_table[minor]); 556 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; 557 out: 558 - unlock_kernel(); 559 return ret; 560 } 561 ··· 681 int ret; 682 683 minor = iminor(file->f_path.dentry->d_inode); 684 - lock_kernel(); 685 switch (cmd) { 686 case LPSETTIMEOUT: 687 if (copy_from_user(&par_timeout, (void __user *)arg, ··· 695 ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg); 696 break; 697 } 698 - unlock_kernel(); 699 700 return ret; 701 } ··· 710 int ret; 711 712 minor = iminor(file->f_path.dentry->d_inode); 713 - lock_kernel(); 714 switch (cmd) { 715 case LPSETTIMEOUT: 716 tc = compat_ptr(arg); ··· 731 ret = lp_do_ioctl(minor, cmd, arg, compat_ptr(arg)); 732 break; 733 } 734 - unlock_kernel(); 735 736 return ret; 737 }
··· 126 #include <linux/device.h> 127 #include <linux/wait.h> 128 #include <linux/jiffies.h> 129 + #include <linux/mutex.h> 130 #include <linux/compat.h> 131 132 #include <linux/parport.h> ··· 140 /* if you have more than 8 printers, remember to increase LP_NO */ 141 #define LP_NO 8 142 143 + static DEFINE_MUTEX(lp_mutex); 144 static struct lp_struct lp_table[LP_NO]; 145 146 static unsigned int lp_count = 0; ··· 493 unsigned int minor = iminor(inode); 494 int ret = 0; 495 496 + mutex_lock(&lp_mutex); 497 if (minor >= LP_NO) { 498 ret = -ENXIO; 499 goto out; ··· 554 lp_release_parport (&lp_table[minor]); 555 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; 556 out: 557 + mutex_unlock(&lp_mutex); 558 return ret; 559 } 560 ··· 680 int ret; 681 682 minor = iminor(file->f_path.dentry->d_inode); 683 + mutex_lock(&lp_mutex); 684 switch (cmd) { 685 case LPSETTIMEOUT: 686 if (copy_from_user(&par_timeout, (void __user *)arg, ··· 694 ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg); 695 break; 696 } 697 + mutex_unlock(&lp_mutex); 698 699 return ret; 700 } ··· 709 int ret; 710 711 minor = iminor(file->f_path.dentry->d_inode); 712 + mutex_lock(&lp_mutex); 713 switch (cmd) { 714 case LPSETTIMEOUT: 715 tc = compat_ptr(arg); ··· 730 ret = lp_do_ioctl(minor, cmd, arg, compat_ptr(arg)); 731 break; 732 } 733 + mutex_unlock(&lp_mutex); 734 735 return ret; 736 }
+4 -4
drivers/char/mbcs.c
··· 25 #include <linux/mm.h> 26 #include <linux/uio.h> 27 #include <linux/mutex.h> 28 - #include <linux/smp_lock.h> 29 #include <linux/slab.h> 30 #include <asm/io.h> 31 #include <asm/uaccess.h> ··· 41 #else 42 #define DBG(fmt...) 43 #endif 44 static int mbcs_major; 45 46 static LIST_HEAD(soft_list); ··· 385 struct mbcs_soft *soft; 386 int minor; 387 388 - lock_kernel(); 389 minor = iminor(ip); 390 391 /* Nothing protects access to this list... */ 392 list_for_each_entry(soft, &soft_list, list) { 393 if (soft->nasid == minor) { 394 fp->private_data = soft->cxdev; 395 - unlock_kernel(); 396 return 0; 397 } 398 } 399 400 - unlock_kernel(); 401 return -ENODEV; 402 } 403
··· 25 #include <linux/mm.h> 26 #include <linux/uio.h> 27 #include <linux/mutex.h> 28 #include <linux/slab.h> 29 #include <asm/io.h> 30 #include <asm/uaccess.h> ··· 42 #else 43 #define DBG(fmt...) 44 #endif 45 + static DEFINE_MUTEX(mbcs_mutex); 46 static int mbcs_major; 47 48 static LIST_HEAD(soft_list); ··· 385 struct mbcs_soft *soft; 386 int minor; 387 388 + mutex_lock(&mbcs_mutex); 389 minor = iminor(ip); 390 391 /* Nothing protects access to this list... */ 392 list_for_each_entry(soft, &soft_list, list) { 393 if (soft->nasid == minor) { 394 fp->private_data = soft->cxdev; 395 + mutex_unlock(&mbcs_mutex); 396 return 0; 397 } 398 } 399 400 + mutex_unlock(&mbcs_mutex); 401 return -ENODEV; 402 } 403
+4 -3
drivers/char/mmtimer.c
··· 32 #include <linux/interrupt.h> 33 #include <linux/time.h> 34 #include <linux/math64.h> 35 - #include <linux/smp_lock.h> 36 #include <linux/slab.h> 37 38 #include <asm/uaccess.h> ··· 59 60 #define rtc_time() (*RTC_COUNTER_ADDR) 61 62 static long mmtimer_ioctl(struct file *file, unsigned int cmd, 63 unsigned long arg); 64 static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma); ··· 372 { 373 int ret = 0; 374 375 - lock_kernel(); 376 377 switch (cmd) { 378 case MMTIMER_GETOFFSET: /* offset of the counter */ ··· 415 ret = -ENOTTY; 416 break; 417 } 418 - unlock_kernel(); 419 return ret; 420 } 421
··· 32 #include <linux/interrupt.h> 33 #include <linux/time.h> 34 #include <linux/math64.h> 35 + #include <linux/mutex.h> 36 #include <linux/slab.h> 37 38 #include <asm/uaccess.h> ··· 59 60 #define rtc_time() (*RTC_COUNTER_ADDR) 61 62 + static DEFINE_MUTEX(mmtimer_mutex); 63 static long mmtimer_ioctl(struct file *file, unsigned int cmd, 64 unsigned long arg); 65 static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma); ··· 371 { 372 int ret = 0; 373 374 + mutex_lock(&mmtimer_mutex); 375 376 switch (cmd) { 377 case MMTIMER_GETOFFSET: /* offset of the counter */ ··· 414 ret = -ENOTTY; 415 break; 416 } 417 + mutex_unlock(&mmtimer_mutex); 418 return ret; 419 } 420
+22 -22
drivers/char/mwave/mwavedd.c
··· 56 #include <linux/serial.h> 57 #include <linux/sched.h> 58 #include <linux/spinlock.h> 59 - #include <linux/smp_lock.h> 60 #include <linux/delay.h> 61 #include <linux/serial_8250.h> 62 #include "smapi.h" ··· 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 75 */ 76 int mwave_debug = 0; 77 int mwave_3780i_irq = 0; 78 int mwave_3780i_io = 0; ··· 102 PRINTK_2(TRACE_MWAVE, 103 "mwavedd::mwave_open, exit return retval %x\n", retval); 104 105 - cycle_kernel_lock(); 106 return retval; 107 } 108 ··· 136 PRINTK_1(TRACE_MWAVE, 137 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 138 " calling tp3780I_ResetDSP\n"); 139 - lock_kernel(); 140 retval = tp3780I_ResetDSP(&pDrvData->rBDData); 141 - unlock_kernel(); 142 PRINTK_2(TRACE_MWAVE, 143 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 144 " retval %x from tp3780I_ResetDSP\n", ··· 149 PRINTK_1(TRACE_MWAVE, 150 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 151 " calling tp3780I_StartDSP\n"); 152 - lock_kernel(); 153 retval = tp3780I_StartDSP(&pDrvData->rBDData); 154 - unlock_kernel(); 155 PRINTK_2(TRACE_MWAVE, 156 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 157 " retval %x from tp3780I_StartDSP\n", ··· 165 "mwavedd::mwave_ioctl," 166 " IOCTL_MW_DSP_ABILITIES calling" 167 " tp3780I_QueryAbilities\n"); 168 - lock_kernel(); 169 retval = tp3780I_QueryAbilities(&pDrvData->rBDData, 170 &rAbilities); 171 - unlock_kernel(); 172 PRINTK_2(TRACE_MWAVE, 173 "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" 174 " retval %x from tp3780I_QueryAbilities\n", ··· 199 "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," 200 " size %lx, ioarg %lx pusBuffer %p\n", 201 rReadData.ulDataLength, ioarg, pusBuffer); 202 - lock_kernel(); 203 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 204 iocmd, 205 pusBuffer, 206 rReadData.ulDataLength, 207 rReadData.usDspAddress); 208 - unlock_kernel(); 209 } 210 break; 211 ··· 223 " size %lx, ioarg %lx pusBuffer %p\n", 224 rReadData.ulDataLength / 2, ioarg, 225 pusBuffer); 226 - lock_kernel(); 227 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 228 iocmd, pusBuffer, 229 rReadData.ulDataLength / 2, 230 rReadData.usDspAddress); 231 - unlock_kernel(); 232 } 233 break; 234 ··· 246 " size %lx, ioarg %lx pusBuffer %p\n", 247 rWriteData.ulDataLength, ioarg, 248 pusBuffer); 249 - lock_kernel(); 250 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 251 iocmd, pusBuffer, 252 rWriteData.ulDataLength, 253 rWriteData.usDspAddress); 254 - unlock_kernel(); 255 } 256 break; 257 ··· 269 " size %lx, ioarg %lx pusBuffer %p\n", 270 rWriteData.ulDataLength, ioarg, 271 pusBuffer); 272 - lock_kernel(); 273 retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, 274 iocmd, pusBuffer, 275 rWriteData.ulDataLength, 276 rWriteData.usDspAddress); 277 - unlock_kernel(); 278 } 279 break; 280 ··· 295 ipcnum, 296 pDrvData->IPCs[ipcnum].usIntCount); 297 298 - lock_kernel(); 299 pDrvData->IPCs[ipcnum].bIsHere = FALSE; 300 pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; 301 - unlock_kernel(); 302 303 PRINTK_2(TRACE_MWAVE, 304 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" ··· 323 ipcnum, 324 pDrvData->IPCs[ipcnum].usIntCount); 325 326 - lock_kernel(); 327 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 328 DECLARE_WAITQUEUE(wait, current); 329 ··· 364 " processing\n", 365 ipcnum); 366 } 367 - unlock_kernel(); 368 } 369 break; 370 ··· 383 ipcnum); 384 return -EINVAL; 385 } 386 - lock_kernel(); 387 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 388 pDrvData->IPCs[ipcnum].bIsEnabled = FALSE; 389 if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) { 390 wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue); 391 } 392 } 393 - unlock_kernel(); 394 } 395 break; 396
··· 56 #include <linux/serial.h> 57 #include <linux/sched.h> 58 #include <linux/spinlock.h> 59 + #include <linux/mutex.h> 60 #include <linux/delay.h> 61 #include <linux/serial_8250.h> 62 #include "smapi.h" ··· 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 75 */ 76 + static DEFINE_MUTEX(mwave_mutex); 77 int mwave_debug = 0; 78 int mwave_3780i_irq = 0; 79 int mwave_3780i_io = 0; ··· 101 PRINTK_2(TRACE_MWAVE, 102 "mwavedd::mwave_open, exit return retval %x\n", retval); 103 104 return retval; 105 } 106 ··· 136 PRINTK_1(TRACE_MWAVE, 137 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 138 " calling tp3780I_ResetDSP\n"); 139 + mutex_lock(&mwave_mutex); 140 retval = tp3780I_ResetDSP(&pDrvData->rBDData); 141 + mutex_unlock(&mwave_mutex); 142 PRINTK_2(TRACE_MWAVE, 143 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 144 " retval %x from tp3780I_ResetDSP\n", ··· 149 PRINTK_1(TRACE_MWAVE, 150 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 151 " calling tp3780I_StartDSP\n"); 152 + mutex_lock(&mwave_mutex); 153 retval = tp3780I_StartDSP(&pDrvData->rBDData); 154 + mutex_unlock(&mwave_mutex); 155 PRINTK_2(TRACE_MWAVE, 156 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 157 " retval %x from tp3780I_StartDSP\n", ··· 165 "mwavedd::mwave_ioctl," 166 " IOCTL_MW_DSP_ABILITIES calling" 167 " tp3780I_QueryAbilities\n"); 168 + mutex_lock(&mwave_mutex); 169 retval = tp3780I_QueryAbilities(&pDrvData->rBDData, 170 &rAbilities); 171 + mutex_unlock(&mwave_mutex); 172 PRINTK_2(TRACE_MWAVE, 173 "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" 174 " retval %x from tp3780I_QueryAbilities\n", ··· 199 "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," 200 " size %lx, ioarg %lx pusBuffer %p\n", 201 rReadData.ulDataLength, ioarg, pusBuffer); 202 + mutex_lock(&mwave_mutex); 203 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 204 iocmd, 205 pusBuffer, 206 rReadData.ulDataLength, 207 rReadData.usDspAddress); 208 + mutex_unlock(&mwave_mutex); 209 } 210 break; 211 ··· 223 " size %lx, ioarg %lx pusBuffer %p\n", 224 rReadData.ulDataLength / 2, ioarg, 225 pusBuffer); 226 + mutex_lock(&mwave_mutex); 227 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 228 iocmd, pusBuffer, 229 rReadData.ulDataLength / 2, 230 rReadData.usDspAddress); 231 + mutex_unlock(&mwave_mutex); 232 } 233 break; 234 ··· 246 " size %lx, ioarg %lx pusBuffer %p\n", 247 rWriteData.ulDataLength, ioarg, 248 pusBuffer); 249 + mutex_lock(&mwave_mutex); 250 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 251 iocmd, pusBuffer, 252 rWriteData.ulDataLength, 253 rWriteData.usDspAddress); 254 + mutex_unlock(&mwave_mutex); 255 } 256 break; 257 ··· 269 " size %lx, ioarg %lx pusBuffer %p\n", 270 rWriteData.ulDataLength, ioarg, 271 pusBuffer); 272 + mutex_lock(&mwave_mutex); 273 retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, 274 iocmd, pusBuffer, 275 rWriteData.ulDataLength, 276 rWriteData.usDspAddress); 277 + mutex_unlock(&mwave_mutex); 278 } 279 break; 280 ··· 295 ipcnum, 296 pDrvData->IPCs[ipcnum].usIntCount); 297 298 + mutex_lock(&mwave_mutex); 299 pDrvData->IPCs[ipcnum].bIsHere = FALSE; 300 pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; 301 + mutex_unlock(&mwave_mutex); 302 303 PRINTK_2(TRACE_MWAVE, 304 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" ··· 323 ipcnum, 324 pDrvData->IPCs[ipcnum].usIntCount); 325 326 + mutex_lock(&mwave_mutex); 327 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 328 DECLARE_WAITQUEUE(wait, current); 329 ··· 364 " processing\n", 365 ipcnum); 366 } 367 + mutex_unlock(&mwave_mutex); 368 } 369 break; 370 ··· 383 ipcnum); 384 return -EINVAL; 385 } 386 + mutex_lock(&mwave_mutex); 387 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 388 pDrvData->IPCs[ipcnum].bIsEnabled = FALSE; 389 if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) { 390 wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue); 391 } 392 } 393 + mutex_unlock(&mwave_mutex); 394 } 395 break; 396
+6 -5
drivers/char/nvram.c
··· 109 #include <linux/spinlock.h> 110 #include <linux/io.h> 111 #include <linux/uaccess.h> 112 - #include <linux/smp_lock.h> 113 114 #include <asm/system.h> 115 116 static DEFINE_SPINLOCK(nvram_state_lock); 117 static int nvram_open_cnt; /* #times opened */ 118 static int nvram_open_mode; /* special open modes */ ··· 309 if (!capable(CAP_SYS_ADMIN)) 310 return -EACCES; 311 312 - lock_kernel(); 313 spin_lock_irq(&rtc_lock); 314 315 for (i = 0; i < NVRAM_BYTES; ++i) ··· 317 __nvram_set_checksum(); 318 319 spin_unlock_irq(&rtc_lock); 320 - unlock_kernel(); 321 return 0; 322 323 case NVRAM_SETCKS: ··· 326 if (!capable(CAP_SYS_ADMIN)) 327 return -EACCES; 328 329 - lock_kernel(); 330 spin_lock_irq(&rtc_lock); 331 __nvram_set_checksum(); 332 spin_unlock_irq(&rtc_lock); 333 - unlock_kernel(); 334 return 0; 335 336 default:
··· 109 #include <linux/spinlock.h> 110 #include <linux/io.h> 111 #include <linux/uaccess.h> 112 + #include <linux/mutex.h> 113 114 #include <asm/system.h> 115 116 + static DEFINE_MUTEX(nvram_mutex); 117 static DEFINE_SPINLOCK(nvram_state_lock); 118 static int nvram_open_cnt; /* #times opened */ 119 static int nvram_open_mode; /* special open modes */ ··· 308 if (!capable(CAP_SYS_ADMIN)) 309 return -EACCES; 310 311 + mutex_lock(&nvram_mutex); 312 spin_lock_irq(&rtc_lock); 313 314 for (i = 0; i < NVRAM_BYTES; ++i) ··· 316 __nvram_set_checksum(); 317 318 spin_unlock_irq(&rtc_lock); 319 + mutex_unlock(&nvram_mutex); 320 return 0; 321 322 case NVRAM_SETCKS: ··· 325 if (!capable(CAP_SYS_ADMIN)) 326 return -EACCES; 327 328 + mutex_lock(&nvram_mutex); 329 spin_lock_irq(&rtc_lock); 330 __nvram_set_checksum(); 331 spin_unlock_irq(&rtc_lock); 332 + mutex_unlock(&nvram_mutex); 333 return 0; 334 335 default:
+6 -6
drivers/char/nwflash.c
··· 25 #include <linux/spinlock.h> 26 #include <linux/rwsem.h> 27 #include <linux/init.h> 28 - #include <linux/smp_lock.h> 29 #include <linux/mutex.h> 30 #include <linux/jiffies.h> 31 ··· 40 41 #define NWFLASH_VERSION "6.4" 42 43 static void kick_open(void); 44 static int get_flash_id(void); 45 static int erase_block(int nBlock); ··· 96 97 static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) 98 { 99 - lock_kernel(); 100 switch (cmd) { 101 case CMD_WRITE_DISABLE: 102 gbWriteBase64Enable = 0; ··· 114 default: 115 gbWriteBase64Enable = 0; 116 gbWriteEnable = 0; 117 - unlock_kernel(); 118 return -EINVAL; 119 } 120 - unlock_kernel(); 121 return 0; 122 } 123 ··· 282 { 283 loff_t ret; 284 285 - lock_kernel(); 286 if (flashdebug) 287 printk(KERN_DEBUG "flash_llseek: offset=0x%X, orig=0x%X.\n", 288 (unsigned int) offset, orig); ··· 317 default: 318 ret = -EINVAL; 319 } 320 - unlock_kernel(); 321 return ret; 322 } 323
··· 25 #include <linux/spinlock.h> 26 #include <linux/rwsem.h> 27 #include <linux/init.h> 28 #include <linux/mutex.h> 29 #include <linux/jiffies.h> 30 ··· 41 42 #define NWFLASH_VERSION "6.4" 43 44 + static DEFINE_MUTEX(flash_mutex); 45 static void kick_open(void); 46 static int get_flash_id(void); 47 static int erase_block(int nBlock); ··· 96 97 static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) 98 { 99 + mutex_lock(&flash_mutex); 100 switch (cmd) { 101 case CMD_WRITE_DISABLE: 102 gbWriteBase64Enable = 0; ··· 114 default: 115 gbWriteBase64Enable = 0; 116 gbWriteEnable = 0; 117 + mutex_unlock(&flash_mutex); 118 return -EINVAL; 119 } 120 + mutex_unlock(&flash_mutex); 121 return 0; 122 } 123 ··· 282 { 283 loff_t ret; 284 285 + mutex_lock(&flash_mutex); 286 if (flashdebug) 287 printk(KERN_DEBUG "flash_llseek: offset=0x%X, orig=0x%X.\n", 288 (unsigned int) offset, orig); ··· 317 default: 318 ret = -EINVAL; 319 } 320 + mutex_unlock(&flash_mutex); 321 return ret; 322 } 323
+6 -5
drivers/char/pcmcia/cm4000_cs.c
··· 30 #include <linux/fs.h> 31 #include <linux/delay.h> 32 #include <linux/bitrev.h> 33 - #include <linux/smp_lock.h> 34 #include <linux/uaccess.h> 35 #include <linux/io.h> 36 ··· 55 __func__ , ## args); \ 56 } while (0) 57 58 static char *version = "cm4000_cs.c v2.4.0gm6 - All bugs added by Harald Welte"; 59 60 #define T_1SEC (HZ) ··· 1419 iminor(inode), ioctl_names[_IOC_NR(cmd)]); 1420 #endif 1421 1422 - lock_kernel(); 1423 rc = -ENODEV; 1424 link = dev_table[iminor(inode)]; 1425 if (!pcmcia_dev_present(link)) { ··· 1627 rc = -ENOTTY; 1628 } 1629 out: 1630 - unlock_kernel(); 1631 return rc; 1632 } 1633 ··· 1641 if (minor >= CM4000_MAX_DEV) 1642 return -ENODEV; 1643 1644 - lock_kernel(); 1645 link = dev_table[minor]; 1646 if (link == NULL || !pcmcia_dev_present(link)) { 1647 ret = -ENODEV; ··· 1686 DEBUGP(2, dev, "<- cmm_open\n"); 1687 ret = nonseekable_open(inode, filp); 1688 out: 1689 - unlock_kernel(); 1690 return ret; 1691 } 1692
··· 30 #include <linux/fs.h> 31 #include <linux/delay.h> 32 #include <linux/bitrev.h> 33 + #include <linux/mutex.h> 34 #include <linux/uaccess.h> 35 #include <linux/io.h> 36 ··· 55 __func__ , ## args); \ 56 } while (0) 57 58 + static DEFINE_MUTEX(cmm_mutex); 59 static char *version = "cm4000_cs.c v2.4.0gm6 - All bugs added by Harald Welte"; 60 61 #define T_1SEC (HZ) ··· 1418 iminor(inode), ioctl_names[_IOC_NR(cmd)]); 1419 #endif 1420 1421 + mutex_lock(&cmm_mutex); 1422 rc = -ENODEV; 1423 link = dev_table[iminor(inode)]; 1424 if (!pcmcia_dev_present(link)) { ··· 1626 rc = -ENOTTY; 1627 } 1628 out: 1629 + mutex_unlock(&cmm_mutex); 1630 return rc; 1631 } 1632 ··· 1640 if (minor >= CM4000_MAX_DEV) 1641 return -ENODEV; 1642 1643 + mutex_lock(&cmm_mutex); 1644 link = dev_table[minor]; 1645 if (link == NULL || !pcmcia_dev_present(link)) { 1646 ret = -ENODEV; ··· 1685 DEBUGP(2, dev, "<- cmm_open\n"); 1686 ret = nonseekable_open(inode, filp); 1687 out: 1688 + mutex_unlock(&cmm_mutex); 1689 return ret; 1690 } 1691
+4 -3
drivers/char/pcmcia/cm4040_cs.c
··· 24 #include <linux/fs.h> 25 #include <linux/delay.h> 26 #include <linux/poll.h> 27 - #include <linux/smp_lock.h> 28 #include <linux/wait.h> 29 #include <asm/uaccess.h> 30 #include <asm/io.h> ··· 49 __func__ , ## args); \ 50 } while (0) 51 52 static char *version = 53 "OMNIKEY CardMan 4040 v1.1.0gm5 - All bugs added by Harald Welte"; 54 ··· 445 if (minor >= CM_MAX_DEV) 446 return -ENODEV; 447 448 - lock_kernel(); 449 link = dev_table[minor]; 450 if (link == NULL || !pcmcia_dev_present(link)) { 451 ret = -ENODEV; ··· 474 DEBUGP(2, dev, "<- cm4040_open (successfully)\n"); 475 ret = nonseekable_open(inode, filp); 476 out: 477 - unlock_kernel(); 478 return ret; 479 } 480
··· 24 #include <linux/fs.h> 25 #include <linux/delay.h> 26 #include <linux/poll.h> 27 + #include <linux/mutex.h> 28 #include <linux/wait.h> 29 #include <asm/uaccess.h> 30 #include <asm/io.h> ··· 49 __func__ , ## args); \ 50 } while (0) 51 52 + static DEFINE_MUTEX(cm4040_mutex); 53 static char *version = 54 "OMNIKEY CardMan 4040 v1.1.0gm5 - All bugs added by Harald Welte"; 55 ··· 444 if (minor >= CM_MAX_DEV) 445 return -ENODEV; 446 447 + mutex_lock(&cm4040_mutex); 448 link = dev_table[minor]; 449 if (link == NULL || !pcmcia_dev_present(link)) { 450 ret = -ENODEV; ··· 473 DEBUGP(2, dev, "<- cm4040_open (successfully)\n"); 474 ret = nonseekable_open(inode, filp); 475 out: 476 + mutex_unlock(&cm4040_mutex); 477 return ret; 478 } 479
+4 -4
drivers/char/ppdev.c
··· 67 #include <linux/slab.h> 68 #include <linux/major.h> 69 #include <linux/ppdev.h> 70 - #include <linux/smp_lock.h> 71 #include <linux/uaccess.h> 72 73 #define PP_VERSION "ppdev: user-space parallel port driver" ··· 97 /* ROUND_UP macro from fs/select.c */ 98 #define ROUND_UP(x,y) (((x)+(y)-1)/(y)) 99 100 static inline void pp_enable_irq (struct pp_struct *pp) 101 { 102 struct parport *port = pp->pdev->port; ··· 631 static long pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 632 { 633 long ret; 634 - lock_kernel(); 635 ret = pp_do_ioctl(file, cmd, arg); 636 - unlock_kernel(); 637 return ret; 638 } 639 ··· 642 unsigned int minor = iminor(inode); 643 struct pp_struct *pp; 644 645 - cycle_kernel_lock(); 646 if (minor >= PARPORT_MAX) 647 return -ENXIO; 648
··· 67 #include <linux/slab.h> 68 #include <linux/major.h> 69 #include <linux/ppdev.h> 70 + #include <linux/mutex.h> 71 #include <linux/uaccess.h> 72 73 #define PP_VERSION "ppdev: user-space parallel port driver" ··· 97 /* ROUND_UP macro from fs/select.c */ 98 #define ROUND_UP(x,y) (((x)+(y)-1)/(y)) 99 100 + static DEFINE_MUTEX(pp_do_mutex); 101 static inline void pp_enable_irq (struct pp_struct *pp) 102 { 103 struct parport *port = pp->pdev->port; ··· 630 static long pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 631 { 632 long ret; 633 + mutex_lock(&pp_do_mutex); 634 ret = pp_do_ioctl(file, cmd, arg); 635 + mutex_unlock(&pp_do_mutex); 636 return ret; 637 } 638 ··· 641 unsigned int minor = iminor(inode); 642 struct pp_struct *pp; 643 644 if (minor >= PARPORT_MAX) 645 return -ENXIO; 646
+4 -3
drivers/char/rio/rio_linux.c
··· 44 #include <linux/delay.h> 45 #include <linux/pci.h> 46 #include <linux/slab.h> 47 - #include <linux/smp_lock.h> 48 #include <linux/miscdevice.h> 49 #include <linux/init.h> 50 ··· 122 123 124 /* These constants are derived from SCO Source */ 125 static struct Conf 126 RIOConf = { 127 /* locator */ "RIO Config here", ··· 567 func_enter(); 568 569 /* The "dev" argument isn't used. */ 570 - lock_kernel(); 571 rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN)); 572 - unlock_kernel(); 573 574 func_exit(); 575 return rc;
··· 44 #include <linux/delay.h> 45 #include <linux/pci.h> 46 #include <linux/slab.h> 47 + #include <linux/mutex.h> 48 #include <linux/miscdevice.h> 49 #include <linux/init.h> 50 ··· 122 123 124 /* These constants are derived from SCO Source */ 125 + static DEFINE_MUTEX(rio_fw_mutex); 126 static struct Conf 127 RIOConf = { 128 /* locator */ "RIO Config here", ··· 566 func_enter(); 567 568 /* The "dev" argument isn't used. */ 569 + mutex_lock(&rio_fw_mutex); 570 rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN)); 571 + mutex_unlock(&rio_fw_mutex); 572 573 func_exit(); 574 return rc;
+5 -4
drivers/char/snsc.c
··· 21 #include <linux/poll.h> 22 #include <linux/module.h> 23 #include <linux/slab.h> 24 - #include <linux/smp_lock.h> 25 #include <asm/sn/io.h> 26 #include <asm/sn/sn_sal.h> 27 #include <asm/sn/module.h> ··· 34 #define SCDRV_BUFSZ 2048 35 #define SCDRV_TIMEOUT 1000 36 37 static irqreturn_t 38 scdrv_interrupt(int irq, void *subch_data) 39 { ··· 106 file->private_data = sd; 107 108 /* hook this subchannel up to the system controller interrupt */ 109 - lock_kernel(); 110 rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt, 111 IRQF_SHARED | IRQF_DISABLED, 112 SYSCTL_BASENAME, sd); ··· 114 ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch); 115 kfree(sd); 116 printk("%s: irq request failed (%d)\n", __func__, rv); 117 - unlock_kernel(); 118 return -EBUSY; 119 } 120 - unlock_kernel(); 121 return 0; 122 } 123
··· 21 #include <linux/poll.h> 22 #include <linux/module.h> 23 #include <linux/slab.h> 24 + #include <linux/mutex.h> 25 #include <asm/sn/io.h> 26 #include <asm/sn/sn_sal.h> 27 #include <asm/sn/module.h> ··· 34 #define SCDRV_BUFSZ 2048 35 #define SCDRV_TIMEOUT 1000 36 37 + static DEFINE_MUTEX(scdrv_mutex); 38 static irqreturn_t 39 scdrv_interrupt(int irq, void *subch_data) 40 { ··· 105 file->private_data = sd; 106 107 /* hook this subchannel up to the system controller interrupt */ 108 + mutex_lock(&scdrv_mutex); 109 rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt, 110 IRQF_SHARED | IRQF_DISABLED, 111 SYSCTL_BASENAME, sd); ··· 113 ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch); 114 kfree(sd); 115 printk("%s: irq request failed (%d)\n", __func__, rv); 116 + mutex_unlock(&scdrv_mutex); 117 return -EBUSY; 118 } 119 + mutex_unlock(&scdrv_mutex); 120 return 0; 121 } 122
+5 -4
drivers/char/toshiba.c
··· 68 #include <linux/stat.h> 69 #include <linux/proc_fs.h> 70 #include <linux/seq_file.h> 71 - #include <linux/smp_lock.h> 72 #include <linux/toshiba.h> 73 74 #define TOSH_MINOR_DEV 181 ··· 78 MODULE_DESCRIPTION("Toshiba laptop SMM driver"); 79 MODULE_SUPPORTED_DEVICE("toshiba"); 80 81 static int tosh_fn; 82 module_param_named(fn, tosh_fn, int, 0); 83 MODULE_PARM_DESC(fn, "User specified Fn key detection port"); ··· 275 return -EINVAL; 276 277 /* do we need to emulate the fan ? */ 278 - lock_kernel(); 279 if (tosh_fan==1) { 280 if (((ax==0xf300) || (ax==0xf400)) && (bx==0x0004)) { 281 err = tosh_emulate_fan(&regs); 282 - unlock_kernel(); 283 break; 284 } 285 } 286 err = tosh_smm(&regs); 287 - unlock_kernel(); 288 break; 289 default: 290 return -EINVAL;
··· 68 #include <linux/stat.h> 69 #include <linux/proc_fs.h> 70 #include <linux/seq_file.h> 71 + #include <linux/mutex.h> 72 #include <linux/toshiba.h> 73 74 #define TOSH_MINOR_DEV 181 ··· 78 MODULE_DESCRIPTION("Toshiba laptop SMM driver"); 79 MODULE_SUPPORTED_DEVICE("toshiba"); 80 81 + static DEFINE_MUTEX(tosh_mutex); 82 static int tosh_fn; 83 module_param_named(fn, tosh_fn, int, 0); 84 MODULE_PARM_DESC(fn, "User specified Fn key detection port"); ··· 274 return -EINVAL; 275 276 /* do we need to emulate the fan ? */ 277 + mutex_lock(&tosh_mutex); 278 if (tosh_fan==1) { 279 if (((ax==0xf300) || (ax==0xf400)) && (bx==0x0004)) { 280 err = tosh_emulate_fan(&regs); 281 + mutex_unlock(&tosh_mutex); 282 break; 283 } 284 } 285 err = tosh_smm(&regs); 286 + mutex_unlock(&tosh_mutex); 287 break; 288 default: 289 return -EINVAL;
+6 -5
drivers/char/viotape.c
··· 46 #include <linux/completion.h> 47 #include <linux/proc_fs.h> 48 #include <linux/seq_file.h> 49 - #include <linux/smp_lock.h> 50 #include <linux/slab.h> 51 52 #include <asm/uaccess.h> ··· 64 #define VIOTAPE_KERN_WARN KERN_WARNING "viotape: " 65 #define VIOTAPE_KERN_INFO KERN_INFO "viotape: " 66 67 static int viotape_numdev; 68 69 /* ··· 685 { 686 long rc; 687 688 - lock_kernel(); 689 rc = viotap_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); 690 - unlock_kernel(); 691 return rc; 692 } 693 ··· 701 if (op == NULL) 702 return -ENOMEM; 703 704 - lock_kernel(); 705 get_dev_info(file->f_path.dentry->d_inode, &devi); 706 707 /* Note: We currently only support one mode! */ ··· 732 733 free_op: 734 free_op_struct(op); 735 - unlock_kernel(); 736 return ret; 737 } 738
··· 46 #include <linux/completion.h> 47 #include <linux/proc_fs.h> 48 #include <linux/seq_file.h> 49 + #include <linux/mutex.h> 50 #include <linux/slab.h> 51 52 #include <asm/uaccess.h> ··· 64 #define VIOTAPE_KERN_WARN KERN_WARNING "viotape: " 65 #define VIOTAPE_KERN_INFO KERN_INFO "viotape: " 66 67 + static DEFINE_MUTEX(proc_viotape_mutex); 68 static int viotape_numdev; 69 70 /* ··· 684 { 685 long rc; 686 687 + mutex_lock(&proc_viotape_mutex); 688 rc = viotap_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); 689 + mutex_unlock(&proc_viotape_mutex); 690 return rc; 691 } 692 ··· 700 if (op == NULL) 701 return -ENOMEM; 702 703 + mutex_lock(&proc_viotape_mutex); 704 get_dev_info(file->f_path.dentry->d_inode, &devi); 705 706 /* Note: We currently only support one mode! */ ··· 731 732 free_op: 733 free_op_struct(op); 734 + mutex_unlock(&proc_viotape_mutex); 735 return ret; 736 } 737
+3 -3
drivers/char/xilinx_hwicap/xilinx_hwicap.c
··· 81 #include <linux/poll.h> 82 #include <linux/proc_fs.h> 83 #include <linux/mutex.h> 84 - #include <linux/smp_lock.h> 85 #include <linux/sysctl.h> 86 #include <linux/fs.h> 87 #include <linux/cdev.h> ··· 111 #define HWICAP_DEVICES 1 112 113 /* An array, which is set to true when the device is registered. */ 114 static bool probed_devices[HWICAP_DEVICES]; 115 static struct mutex icap_sem; 116 ··· 502 struct hwicap_drvdata *drvdata; 503 int status; 504 505 - lock_kernel(); 506 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev); 507 508 status = mutex_lock_interruptible(&drvdata->sem); ··· 528 error: 529 mutex_unlock(&drvdata->sem); 530 out: 531 - unlock_kernel(); 532 return status; 533 } 534
··· 81 #include <linux/poll.h> 82 #include <linux/proc_fs.h> 83 #include <linux/mutex.h> 84 #include <linux/sysctl.h> 85 #include <linux/fs.h> 86 #include <linux/cdev.h> ··· 112 #define HWICAP_DEVICES 1 113 114 /* An array, which is set to true when the device is registered. */ 115 + static DEFINE_MUTEX(hwicap_mutex); 116 static bool probed_devices[HWICAP_DEVICES]; 117 static struct mutex icap_sem; 118 ··· 502 struct hwicap_drvdata *drvdata; 503 int status; 504 505 + mutex_lock(&hwicap_mutex); 506 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev); 507 508 status = mutex_lock_interruptible(&drvdata->sem); ··· 528 error: 529 mutex_unlock(&drvdata->sem); 530 out: 531 + mutex_unlock(&hwicap_mutex); 532 return status; 533 } 534
+3 -3
drivers/hwmon/fschmd.c
··· 38 #include <linux/i2c.h> 39 #include <linux/hwmon.h> 40 #include <linux/hwmon-sysfs.h> 41 - #include <linux/smp_lock.h> 42 #include <linux/err.h> 43 #include <linux/mutex.h> 44 #include <linux/sysfs.h> ··· 49 #include <linux/kref.h> 50 51 /* Addresses to scan */ 52 static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; 53 54 /* Insmod parameters */ ··· 858 int i, ret = 0; 859 struct fschmd_data *data = filp->private_data; 860 861 - lock_kernel(); 862 switch (cmd) { 863 case WDIOC_GETSUPPORT: 864 ident.firmware_version = data->revision; ··· 915 default: 916 ret = -ENOTTY; 917 } 918 - unlock_kernel(); 919 return ret; 920 } 921
··· 38 #include <linux/i2c.h> 39 #include <linux/hwmon.h> 40 #include <linux/hwmon-sysfs.h> 41 #include <linux/err.h> 42 #include <linux/mutex.h> 43 #include <linux/sysfs.h> ··· 50 #include <linux/kref.h> 51 52 /* Addresses to scan */ 53 + static DEFINE_MUTEX(watchdog_mutex); 54 static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; 55 56 /* Insmod parameters */ ··· 858 int i, ret = 0; 859 struct fschmd_data *data = filp->private_data; 860 861 + mutex_lock(&watchdog_mutex); 862 switch (cmd) { 863 case WDIOC_GETSUPPORT: 864 ident.firmware_version = data->revision; ··· 915 default: 916 ret = -ENOTTY; 917 } 918 + mutex_unlock(&watchdog_mutex); 919 return ret; 920 } 921
+3 -3
drivers/hwmon/w83793.c
··· 35 #include <linux/slab.h> 36 #include <linux/i2c.h> 37 #include <linux/hwmon.h> 38 - #include <linux/smp_lock.h> 39 #include <linux/hwmon-vid.h> 40 #include <linux/hwmon-sysfs.h> 41 #include <linux/err.h> ··· 51 #define WATCHDOG_TIMEOUT 2 /* 2 minute default timeout */ 52 53 /* Addresses to scan */ 54 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, 55 I2C_CLIENT_END }; 56 ··· 1333 int val, ret = 0; 1334 struct w83793_data *data = filp->private_data; 1335 1336 - lock_kernel(); 1337 switch (cmd) { 1338 case WDIOC_GETSUPPORT: 1339 if (!nowayout) ··· 1387 default: 1388 ret = -ENOTTY; 1389 } 1390 - unlock_kernel(); 1391 return ret; 1392 } 1393
··· 35 #include <linux/slab.h> 36 #include <linux/i2c.h> 37 #include <linux/hwmon.h> 38 #include <linux/hwmon-vid.h> 39 #include <linux/hwmon-sysfs.h> 40 #include <linux/err.h> ··· 52 #define WATCHDOG_TIMEOUT 2 /* 2 minute default timeout */ 53 54 /* Addresses to scan */ 55 + static DEFINE_MUTEX(watchdog_mutex); 56 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, 57 I2C_CLIENT_END }; 58 ··· 1333 int val, ret = 0; 1334 struct w83793_data *data = filp->private_data; 1335 1336 + mutex_lock(&watchdog_mutex); 1337 switch (cmd) { 1338 case WDIOC_GETSUPPORT: 1339 if (!nowayout) ··· 1387 default: 1388 ret = -ENOTTY; 1389 } 1390 + mutex_unlock(&watchdog_mutex); 1391 return ret; 1392 } 1393
+4 -3
drivers/input/misc/hp_sdc_rtc.c
··· 43 #include <linux/proc_fs.h> 44 #include <linux/poll.h> 45 #include <linux/rtc.h> 46 - #include <linux/smp_lock.h> 47 #include <linux/semaphore.h> 48 49 MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); ··· 52 53 #define RTC_VERSION "1.10d" 54 55 static unsigned long epoch = 2000; 56 57 static struct semaphore i8042tregs; ··· 666 { 667 int ret; 668 669 - lock_kernel(); 670 ret = hp_sdc_rtc_ioctl(file, cmd, arg); 671 - unlock_kernel(); 672 673 return ret; 674 }
··· 43 #include <linux/proc_fs.h> 44 #include <linux/poll.h> 45 #include <linux/rtc.h> 46 + #include <linux/mutex.h> 47 #include <linux/semaphore.h> 48 49 MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); ··· 52 53 #define RTC_VERSION "1.10d" 54 55 + static DEFINE_MUTEX(hp_sdc_rtc_mutex); 56 static unsigned long epoch = 2000; 57 58 static struct semaphore i8042tregs; ··· 665 { 666 int ret; 667 668 + mutex_lock(&hp_sdc_rtc_mutex); 669 ret = hp_sdc_rtc_ioctl(file, cmd, arg); 670 + mutex_unlock(&hp_sdc_rtc_mutex); 671 672 return ret; 673 }
+6 -5
drivers/misc/phantom.c
··· 24 #include <linux/slab.h> 25 #include <linux/phantom.h> 26 #include <linux/sched.h> 27 - #include <linux/smp_lock.h> 28 29 #include <asm/atomic.h> 30 #include <asm/io.h> ··· 38 #define PHB_RUNNING 1 39 #define PHB_NOT_OH 2 40 41 static struct class *phantom_class; 42 static int phantom_major; 43 ··· 216 struct phantom_device *dev = container_of(inode->i_cdev, 217 struct phantom_device, cdev); 218 219 - lock_kernel(); 220 nonseekable_open(inode, file); 221 222 if (mutex_lock_interruptible(&dev->open_lock)) { 223 - unlock_kernel(); 224 return -ERESTARTSYS; 225 } 226 227 if (dev->opened) { 228 mutex_unlock(&dev->open_lock); 229 - unlock_kernel(); 230 return -EINVAL; 231 } 232 ··· 237 atomic_set(&dev->counter, 0); 238 dev->opened++; 239 mutex_unlock(&dev->open_lock); 240 - unlock_kernel(); 241 return 0; 242 } 243
··· 24 #include <linux/slab.h> 25 #include <linux/phantom.h> 26 #include <linux/sched.h> 27 + #include <linux/mutex.h> 28 29 #include <asm/atomic.h> 30 #include <asm/io.h> ··· 38 #define PHB_RUNNING 1 39 #define PHB_NOT_OH 2 40 41 + static DEFINE_MUTEX(phantom_mutex); 42 static struct class *phantom_class; 43 static int phantom_major; 44 ··· 215 struct phantom_device *dev = container_of(inode->i_cdev, 216 struct phantom_device, cdev); 217 218 + mutex_lock(&phantom_mutex); 219 nonseekable_open(inode, file); 220 221 if (mutex_lock_interruptible(&dev->open_lock)) { 222 + mutex_unlock(&phantom_mutex); 223 return -ERESTARTSYS; 224 } 225 226 if (dev->opened) { 227 mutex_unlock(&dev->open_lock); 228 + mutex_unlock(&phantom_mutex); 229 return -EINVAL; 230 } 231 ··· 236 atomic_set(&dev->counter, 0); 237 dev->opened++; 238 mutex_unlock(&dev->open_lock); 239 + mutex_unlock(&phantom_mutex); 240 return 0; 241 } 242
+7 -6
drivers/pci/hotplug/cpqphp_sysfs.c
··· 34 #include <linux/workqueue.h> 35 #include <linux/pci.h> 36 #include <linux/pci_hotplug.h> 37 - #include <linux/smp_lock.h> 38 #include <linux/debugfs.h> 39 #include "cpqphp.h" 40 41 static int show_ctrl (struct controller *ctrl, char *buf) 42 { 43 char *out = buf; ··· 148 struct ctrl_dbg *dbg; 149 int retval = -ENOMEM; 150 151 - lock_kernel(); 152 dbg = kmalloc(sizeof(*dbg), GFP_KERNEL); 153 if (!dbg) 154 goto exit; ··· 161 file->private_data = dbg; 162 retval = 0; 163 exit: 164 - unlock_kernel(); 165 return retval; 166 } 167 ··· 170 struct ctrl_dbg *dbg; 171 loff_t new = -1; 172 173 - lock_kernel(); 174 dbg = file->private_data; 175 176 switch (whence) { ··· 182 break; 183 } 184 if (new < 0 || new > dbg->size) { 185 - unlock_kernel(); 186 return -EINVAL; 187 } 188 - unlock_kernel(); 189 return (file->f_pos = new); 190 } 191
··· 34 #include <linux/workqueue.h> 35 #include <linux/pci.h> 36 #include <linux/pci_hotplug.h> 37 + #include <linux/mutex.h> 38 #include <linux/debugfs.h> 39 #include "cpqphp.h" 40 41 + static DEFINE_MUTEX(cpqphp_mutex); 42 static int show_ctrl (struct controller *ctrl, char *buf) 43 { 44 char *out = buf; ··· 147 struct ctrl_dbg *dbg; 148 int retval = -ENOMEM; 149 150 + mutex_lock(&cpqphp_mutex); 151 dbg = kmalloc(sizeof(*dbg), GFP_KERNEL); 152 if (!dbg) 153 goto exit; ··· 160 file->private_data = dbg; 161 retval = 0; 162 exit: 163 + mutex_unlock(&cpqphp_mutex); 164 return retval; 165 } 166 ··· 169 struct ctrl_dbg *dbg; 170 loff_t new = -1; 171 172 + mutex_lock(&cpqphp_mutex); 173 dbg = file->private_data; 174 175 switch (whence) { ··· 181 break; 182 } 183 if (new < 0 || new > dbg->size) { 184 + mutex_unlock(&cpqphp_mutex); 185 return -EINVAL; 186 } 187 + mutex_unlock(&cpqphp_mutex); 188 return (file->f_pos = new); 189 } 190
+7 -6
drivers/rtc/rtc-m41t80.c
··· 20 #include <linux/module.h> 21 #include <linux/rtc.h> 22 #include <linux/slab.h> 23 - #include <linux/smp_lock.h> 24 #include <linux/string.h> 25 #ifdef CONFIG_RTC_DRV_M41T80_WDT 26 #include <linux/fs.h> ··· 68 69 #define DRV_VERSION "0.05" 70 71 static const struct i2c_device_id m41t80_id[] = { 72 { "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT }, 73 { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD }, ··· 678 { 679 int ret; 680 681 - lock_kernel(); 682 ret = wdt_ioctl(file, cmd, arg); 683 - unlock_kernel(); 684 685 return ret; 686 } ··· 694 static int wdt_open(struct inode *inode, struct file *file) 695 { 696 if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) { 697 - lock_kernel(); 698 if (test_and_set_bit(0, &wdt_is_open)) { 699 - unlock_kernel(); 700 return -EBUSY; 701 } 702 /* 703 * Activate 704 */ 705 wdt_is_open = 1; 706 - unlock_kernel(); 707 return nonseekable_open(inode, file); 708 } 709 return -ENODEV;
··· 20 #include <linux/module.h> 21 #include <linux/rtc.h> 22 #include <linux/slab.h> 23 + #include <linux/mutex.h> 24 #include <linux/string.h> 25 #ifdef CONFIG_RTC_DRV_M41T80_WDT 26 #include <linux/fs.h> ··· 68 69 #define DRV_VERSION "0.05" 70 71 + static DEFINE_MUTEX(m41t80_rtc_mutex); 72 static const struct i2c_device_id m41t80_id[] = { 73 { "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT }, 74 { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD }, ··· 677 { 678 int ret; 679 680 + mutex_lock(&m41t80_rtc_mutex); 681 ret = wdt_ioctl(file, cmd, arg); 682 + mutex_unlock(&m41t80_rtc_mutex); 683 684 return ret; 685 } ··· 693 static int wdt_open(struct inode *inode, struct file *file) 694 { 695 if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) { 696 + mutex_lock(&m41t80_rtc_mutex); 697 if (test_and_set_bit(0, &wdt_is_open)) { 698 + mutex_unlock(&m41t80_rtc_mutex); 699 return -EBUSY; 700 } 701 /* 702 * Activate 703 */ 704 wdt_is_open = 1; 705 + mutex_unlock(&m41t80_rtc_mutex); 706 return nonseekable_open(inode, file); 707 } 708 return -ENODEV;
+13 -11
drivers/sbus/char/jsflash.c
··· 27 */ 28 29 #include <linux/module.h> 30 - #include <linux/smp_lock.h> 31 #include <linux/types.h> 32 #include <linux/errno.h> 33 #include <linux/miscdevice.h> ··· 67 #define JSF_NPART 3 /* 3 minors per flash device */ 68 #define JSF_PART_BITS 2 /* 2 bits of minors to cover JSF_NPART */ 69 #define JSF_PART_MASK 0x3 /* 2 bits mask */ 70 71 /* 72 * Access functions. ··· 227 { 228 loff_t ret; 229 230 - lock_kernel(); 231 switch (orig) { 232 case 0: 233 file->f_pos = offset; ··· 240 default: 241 ret = -EINVAL; 242 } 243 - unlock_kernel(); 244 return ret; 245 } 246 ··· 386 387 static long jsf_ioctl(struct file *f, unsigned int cmd, unsigned long arg) 388 { 389 - lock_kernel(); 390 int error = -ENOTTY; 391 void __user *argp = (void __user *)arg; 392 393 if (!capable(CAP_SYS_ADMIN)) { 394 - unlock_kernel(); 395 return -EPERM; 396 } 397 switch (cmd) { 398 case JSFLASH_IDENT: 399 if (copy_to_user(argp, &jsf0.id, JSFIDSZ)) { 400 - unlock_kernel(); 401 return -EFAULT; 402 } 403 break; ··· 409 break; 410 } 411 412 - unlock_kernel(); 413 return error; 414 } 415 ··· 420 421 static int jsf_open(struct inode * inode, struct file * filp) 422 { 423 - lock_kernel(); 424 if (jsf0.base == 0) { 425 - unlock_kernel(); 426 return -ENXIO; 427 } 428 if (test_and_set_bit(0, (void *)&jsf0.busy) != 0) { 429 - unlock_kernel(); 430 return -EBUSY; 431 } 432 433 - unlock_kernel(); 434 return 0; /* XXX What security? */ 435 } 436
··· 27 */ 28 29 #include <linux/module.h> 30 + #include <linux/mutex.h> 31 #include <linux/types.h> 32 #include <linux/errno.h> 33 #include <linux/miscdevice.h> ··· 67 #define JSF_NPART 3 /* 3 minors per flash device */ 68 #define JSF_PART_BITS 2 /* 2 bits of minors to cover JSF_NPART */ 69 #define JSF_PART_MASK 0x3 /* 2 bits mask */ 70 + 71 + static DEFINE_MUTEX(jsf_mutex); 72 73 /* 74 * Access functions. ··· 225 { 226 loff_t ret; 227 228 + mutex_lock(&jsf_mutex); 229 switch (orig) { 230 case 0: 231 file->f_pos = offset; ··· 238 default: 239 ret = -EINVAL; 240 } 241 + mutex_unlock(&jsf_mutex); 242 return ret; 243 } 244 ··· 384 385 static long jsf_ioctl(struct file *f, unsigned int cmd, unsigned long arg) 386 { 387 + mutex_lock(&jsf_mutex); 388 int error = -ENOTTY; 389 void __user *argp = (void __user *)arg; 390 391 if (!capable(CAP_SYS_ADMIN)) { 392 + mutex_unlock(&jsf_mutex); 393 return -EPERM; 394 } 395 switch (cmd) { 396 case JSFLASH_IDENT: 397 if (copy_to_user(argp, &jsf0.id, JSFIDSZ)) { 398 + mutex_unlock(&jsf_mutex); 399 return -EFAULT; 400 } 401 break; ··· 407 break; 408 } 409 410 + mutex_unlock(&jsf_mutex); 411 return error; 412 } 413 ··· 418 419 static int jsf_open(struct inode * inode, struct file * filp) 420 { 421 + mutex_lock(&jsf_mutex); 422 if (jsf0.base == 0) { 423 + mutex_unlock(&jsf_mutex); 424 return -ENXIO; 425 } 426 if (test_and_set_bit(0, (void *)&jsf0.busy) != 0) { 427 + mutex_unlock(&jsf_mutex); 428 return -EBUSY; 429 } 430 431 + mutex_unlock(&jsf_mutex); 432 return 0; /* XXX What security? */ 433 } 434
+4 -3
drivers/telephony/ixj.c
··· 257 #include <linux/fs.h> /* everything... */ 258 #include <linux/errno.h> /* error codes */ 259 #include <linux/slab.h> 260 - #include <linux/smp_lock.h> 261 #include <linux/mm.h> 262 #include <linux/ioport.h> 263 #include <linux/interrupt.h> ··· 277 #define TYPE(inode) (iminor(inode) >> 4) 278 #define NUM(inode) (iminor(inode) & 0xf) 279 280 static int ixjdebug; 281 static int hertz = HZ; 282 static int samplerate = 100; ··· 6656 static long ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg) 6657 { 6658 long ret; 6659 - lock_kernel(); 6660 ret = do_ixj_ioctl(file_p, cmd, arg); 6661 - unlock_kernel(); 6662 return ret; 6663 } 6664
··· 257 #include <linux/fs.h> /* everything... */ 258 #include <linux/errno.h> /* error codes */ 259 #include <linux/slab.h> 260 + #include <linux/mutex.h> 261 #include <linux/mm.h> 262 #include <linux/ioport.h> 263 #include <linux/interrupt.h> ··· 277 #define TYPE(inode) (iminor(inode) >> 4) 278 #define NUM(inode) (iminor(inode) & 0xf) 279 280 + static DEFINE_MUTEX(ixj_mutex); 281 static int ixjdebug; 282 static int hertz = HZ; 283 static int samplerate = 100; ··· 6655 static long ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg) 6656 { 6657 long ret; 6658 + mutex_lock(&ixj_mutex); 6659 ret = do_ixj_ioctl(file_p, cmd, arg); 6660 + mutex_unlock(&ixj_mutex); 6661 return ret; 6662 } 6663
+8 -7
drivers/watchdog/cpwd.c
··· 25 #include <linux/ioport.h> 26 #include <linux/timer.h> 27 #include <linux/slab.h> 28 - #include <linux/smp_lock.h> 29 #include <linux/io.h> 30 #include <linux/of.h> 31 #include <linux/of_device.h> ··· 89 } devs[WD_NUMDEVS]; 90 }; 91 92 static struct cpwd *cpwd_device; 93 94 /* Sun uses Altera PLD EPF8820ATC144-4 ··· 369 { 370 struct cpwd *p = cpwd_device; 371 372 - lock_kernel(); 373 switch (iminor(inode)) { 374 case WD0_MINOR: 375 case WD1_MINOR: ··· 377 break; 378 379 default: 380 - unlock_kernel(); 381 return -ENODEV; 382 } 383 ··· 387 IRQF_SHARED, DRIVER_NAME, p)) { 388 printk(KERN_ERR PFX "Cannot register IRQ %d\n", 389 p->irq); 390 - unlock_kernel(); 391 return -EBUSY; 392 } 393 p->initialized = true; 394 } 395 396 - unlock_kernel(); 397 398 return nonseekable_open(inode, f); 399 } ··· 483 case WIOCSTART: 484 case WIOCSTOP: 485 case WIOCGSTAT: 486 - lock_kernel(); 487 rval = cpwd_ioctl(file, cmd, arg); 488 - unlock_kernel(); 489 break; 490 491 /* everything else is handled by the generic compat layer */
··· 25 #include <linux/ioport.h> 26 #include <linux/timer.h> 27 #include <linux/slab.h> 28 + #include <linux/mutex.h> 29 #include <linux/io.h> 30 #include <linux/of.h> 31 #include <linux/of_device.h> ··· 89 } devs[WD_NUMDEVS]; 90 }; 91 92 + static DEFINE_MUTEX(cpwd_mutex); 93 static struct cpwd *cpwd_device; 94 95 /* Sun uses Altera PLD EPF8820ATC144-4 ··· 368 { 369 struct cpwd *p = cpwd_device; 370 371 + mutex_lock(&cpwd_mutex); 372 switch (iminor(inode)) { 373 case WD0_MINOR: 374 case WD1_MINOR: ··· 376 break; 377 378 default: 379 + mutex_unlock(&cpwd_mutex); 380 return -ENODEV; 381 } 382 ··· 386 IRQF_SHARED, DRIVER_NAME, p)) { 387 printk(KERN_ERR PFX "Cannot register IRQ %d\n", 388 p->irq); 389 + mutex_unlock(&cpwd_mutex); 390 return -EBUSY; 391 } 392 p->initialized = true; 393 } 394 395 + mutex_unlock(&cpwd_mutex); 396 397 return nonseekable_open(inode, f); 398 } ··· 482 case WIOCSTART: 483 case WIOCSTOP: 484 case WIOCGSTAT: 485 + mutex_lock(&cpwd_mutex); 486 rval = cpwd_ioctl(file, cmd, arg); 487 + mutex_unlock(&cpwd_mutex); 488 break; 489 490 /* everything else is handled by the generic compat layer */