Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmtimer: Push BKL down into the ioctl handler

Switches to unlocked_ioctl read to remove ioctl BKL method. Fix the
unknown ioctl return. Probably a nice easy one to kill off BKL usage
entirely later

Signed-off-by: Alan Cox <alan@redhat.com>
Acked-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>

authored by

Alan Cox and committed by
Tony Luck
4cddb886 fb86611f

+15 -14
+15 -14
drivers/char/mmtimer.c
··· 32 32 #include <linux/interrupt.h> 33 33 #include <linux/time.h> 34 34 #include <linux/math64.h> 35 + #include <linux/smp_lock.h> 35 36 36 37 #include <asm/uaccess.h> 37 38 #include <asm/sn/addrs.h> ··· 58 57 59 58 #define rtc_time() (*RTC_COUNTER_ADDR) 60 59 61 - static int mmtimer_ioctl(struct inode *inode, struct file *file, 62 - unsigned int cmd, unsigned long arg); 60 + static long mmtimer_ioctl(struct file *file, unsigned int cmd, 61 + unsigned long arg); 63 62 static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma); 64 63 65 64 /* ··· 68 67 static unsigned long mmtimer_femtoperiod = 0; 69 68 70 69 static const struct file_operations mmtimer_fops = { 71 - .owner = THIS_MODULE, 72 - .mmap = mmtimer_mmap, 73 - .ioctl = mmtimer_ioctl, 70 + .owner = THIS_MODULE, 71 + .mmap = mmtimer_mmap, 72 + .unlocked_ioctl = mmtimer_ioctl, 74 73 }; 75 74 76 75 /* ··· 340 339 341 340 /** 342 341 * mmtimer_ioctl - ioctl interface for /dev/mmtimer 343 - * @inode: inode of the device 344 342 * @file: file structure for the device 345 343 * @cmd: command to execute 346 344 * @arg: optional argument to command ··· 365 365 * %MMTIMER_GETCOUNTER - Gets the current value in the counter and places it 366 366 * in the address specified by @arg. 367 367 */ 368 - static int mmtimer_ioctl(struct inode *inode, struct file *file, 369 - unsigned int cmd, unsigned long arg) 368 + static long mmtimer_ioctl(struct file *file, unsigned int cmd, 369 + unsigned long arg) 370 370 { 371 371 int ret = 0; 372 + 373 + lock_kernel(); 372 374 373 375 switch (cmd) { 374 376 case MMTIMER_GETOFFSET: /* offset of the counter */ ··· 386 384 case MMTIMER_GETRES: /* resolution of the clock in 10^-15 s */ 387 385 if(copy_to_user((unsigned long __user *)arg, 388 386 &mmtimer_femtoperiod, sizeof(unsigned long))) 389 - return -EFAULT; 387 + ret = -EFAULT; 390 388 break; 391 389 392 390 case MMTIMER_GETFREQ: /* frequency in Hz */ 393 391 if(copy_to_user((unsigned long __user *)arg, 394 392 &sn_rtc_cycles_per_second, 395 393 sizeof(unsigned long))) 396 - return -EFAULT; 397 - ret = 0; 394 + ret = -EFAULT; 398 395 break; 399 396 400 397 case MMTIMER_GETBITS: /* number of bits in the clock */ ··· 407 406 case MMTIMER_GETCOUNTER: 408 407 if(copy_to_user((unsigned long __user *)arg, 409 408 RTC_COUNTER_ADDR, sizeof(unsigned long))) 410 - return -EFAULT; 409 + ret = -EFAULT; 411 410 break; 412 411 default: 413 - ret = -ENOSYS; 412 + ret = -ENOTTY; 414 413 break; 415 414 } 416 - 415 + unlock_kernel(); 417 416 return ret; 418 417 } 419 418