Commit 4cddb886a4d0e5cc7a790151740bfb87b568c97d

Authored by Alan Cox
Committed by Tony Luck
1 parent fb86611f8f

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>

Showing 1 changed file with 15 additions and 14 deletions Side-by-side Diff

drivers/char/mmtimer.c
... ... @@ -32,6 +32,7 @@
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>
... ... @@ -57,8 +58,8 @@
57 58  
58 59 #define rtc_time() (*RTC_COUNTER_ADDR)
59 60  
60   -static int mmtimer_ioctl(struct inode *inode, struct file *file,
61   - unsigned int cmd, unsigned long arg);
  61 +static long mmtimer_ioctl(struct file *file, unsigned int cmd,
  62 + unsigned long arg);
62 63 static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma);
63 64  
64 65 /*
... ... @@ -67,9 +68,9 @@
67 68 static unsigned long mmtimer_femtoperiod = 0;
68 69  
69 70 static const struct file_operations mmtimer_fops = {
70   - .owner = THIS_MODULE,
71   - .mmap = mmtimer_mmap,
72   - .ioctl = mmtimer_ioctl,
  71 + .owner = THIS_MODULE,
  72 + .mmap = mmtimer_mmap,
  73 + .unlocked_ioctl = mmtimer_ioctl,
73 74 };
74 75  
75 76 /*
... ... @@ -339,7 +340,6 @@
339 340  
340 341 /**
341 342 * mmtimer_ioctl - ioctl interface for /dev/mmtimer
342   - * @inode: inode of the device
343 343 * @file: file structure for the device
344 344 * @cmd: command to execute
345 345 * @arg: optional argument to command
346 346  
... ... @@ -365,11 +365,13 @@
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 372  
  373 + lock_kernel();
  374 +
373 375 switch (cmd) {
374 376 case MMTIMER_GETOFFSET: /* offset of the counter */
375 377 /*
376 378  
... ... @@ -384,15 +386,14 @@
384 386 case MMTIMER_GETRES: /* resolution of the clock in 10^-15 s */
385 387 if(copy_to_user((unsigned long __user *)arg,
386 388 &mmtimer_femtoperiod, sizeof(unsigned long)))
387   - return -EFAULT;
  389 + ret = -EFAULT;
388 390 break;
389 391  
390 392 case MMTIMER_GETFREQ: /* frequency in Hz */
391 393 if(copy_to_user((unsigned long __user *)arg,
392 394 &sn_rtc_cycles_per_second,
393 395 sizeof(unsigned long)))
394   - return -EFAULT;
395   - ret = 0;
  396 + ret = -EFAULT;
396 397 break;
397 398  
398 399 case MMTIMER_GETBITS: /* number of bits in the clock */
399 400  
400 401  
... ... @@ -406,13 +407,13 @@
406 407 case MMTIMER_GETCOUNTER:
407 408 if(copy_to_user((unsigned long __user *)arg,
408 409 RTC_COUNTER_ADDR, sizeof(unsigned long)))
409   - return -EFAULT;
  410 + ret = -EFAULT;
410 411 break;
411 412 default:
412   - ret = -ENOSYS;
  413 + ret = -ENOTTY;
413 414 break;
414 415 }
415   -
  416 + unlock_kernel();
416 417 return ret;
417 418 }
418 419