generic rtc and nvram: Push the BKL down
PATCH 1/1 generic rtc and nvram: Push the BKL down
Switch the ioctl handlers to unlocked_ioctl and push lock_kernel into the driver instead.
Signed-off-by Alan Cox <[email protected]>
drivers/char/generic_nvram.c +23 -14
@@ -20,7 +20,8 @@#include <linux/fcntl.h> #include <linux/init.h> #include <linux/smp_lock.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> +#include <linux/smp_lock.h> #include <asm/nvram.h> #ifdef CONFIG_PPC_PMAC #include <asm/machdep.h>
@@ -85,25 +86,33 @@ static ssize_t write_nvram(struct file *file, const char __user *buf,return p - buf; } -static int nvram_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long nvram_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) { +int ret =0 ;switch (cmd) {#ifdef CONFIG_PPC_PMAC case OBSOLETE_PMAC_NVRAM_GET_OFFSET : +/* FIXME: should be rate limited */ printk (KERN_WARNING "nvram: Using obsolete PMAC_NVRAM_GET_OFFSET ioctl\n" );case IOC_NVRAM_GET_OFFSET : {int part, offset; -if (!machine_is (powermac)) -return -EINVAL ; -if (copy_from_user (&part, (void __user *)arg,sizeof (part)) !=0 ) -return -EFAULT ; -if (part < pmac_nvram_OF || part > pmac_nvram_NR) -return -EINVAL ; +if (!machine_is (powermac)) { + ret = -EINVAL ; +break ; + } +if (copy_from_user (&part, (void __user *)arg,sizeof (part)) !=0 ) { + ret = -EFAULT ; +break ; + } +if (part < pmac_nvram_OF || part > pmac_nvram_NR) { + ret = -EINVAL ; +break ; + } offset =pmac_get_partition (part);if (copy_to_user ((void __user *)arg, &offset,sizeof (offset)) !=0 ) -return -EFAULT ; + ret = -EFAULT ;break ; }#endif /* CONFIG_PPC_PMAC */
@@ -111,10 +120,10 @@ static int nvram_ioctl(struct inode *inode, struct file *file,nvram_sync ();break ;default : -return -EINVAL ; + ret = -ENOTTY ; } - -return 0 ; +unlock_kernel (); +return ret; }const struct file_operations nvram_fops = {
@@ -122,7 +131,7 @@ const struct file_operations nvram_fops = { .llseek = nvram_llseek, .read = read_nvram, .write = write_nvram, - .ioctl = nvram_ioctl, + .unlocked_ioctl = nvram_ioctl, };static struct miscdevice nvram_dev = {
drivers/char/genrtc.c +46 -30
135 lines not on this page · raw message