From 90f826bd0f00ec2e4d2029b2a460835836b0fec9 Mon Sep 17 00:00:00 2001 From: Stoyan Gaydarov Date: Mon, 14 Jul 2008 22:12:29 -0700 Subject: [PATCH] --- yaml --- r: 104169 b: refs/heads/master c: ab772027ca42a06f7e480077182434a2a30a8037 h: refs/heads/master i: 104167: 3399c2d458b5bb6496a5162bc79b364f750f5438 v: v3 --- [refs] | 2 +- trunk/arch/sparc/kernel/apc.c | 40 ++++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/[refs] b/[refs] index 70533a15651d..ace1db1c49da 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f5e706ad886b6a5eb59637830110b09ccebf01c5 +refs/heads/master: ab772027ca42a06f7e480077182434a2a30a8037 diff --git a/trunk/arch/sparc/kernel/apc.c b/trunk/arch/sparc/kernel/apc.c index 54f7ccd7455f..5267d48fb2c6 100644 --- a/trunk/arch/sparc/kernel/apc.c +++ b/trunk/arch/sparc/kernel/apc.c @@ -85,54 +85,70 @@ static int apc_release(struct inode *inode, struct file *f) return 0; } -static int apc_ioctl(struct inode *inode, struct file *f, - unsigned int cmd, unsigned long __arg) +static long apc_ioctl(struct file *f, unsigned int cmd, unsigned long __arg) { __u8 inarg, __user *arg; arg = (__u8 __user *) __arg; + + lock_kernel(); + switch (cmd) { case APCIOCGFANCTL: - if (put_user(apc_readb(APC_FANCTL_REG) & APC_REGMASK, arg)) - return -EFAULT; + if (put_user(apc_readb(APC_FANCTL_REG) & APC_REGMASK, arg)) { + unlock_kernel(); + return -EFAULT; + } break; case APCIOCGCPWR: - if (put_user(apc_readb(APC_CPOWER_REG) & APC_REGMASK, arg)) + if (put_user(apc_readb(APC_CPOWER_REG) & APC_REGMASK, arg)) { + unlock_kernel(); return -EFAULT; + } break; case APCIOCGBPORT: - if (put_user(apc_readb(APC_BPORT_REG) & APC_BPMASK, arg)) + if (put_user(apc_readb(APC_BPORT_REG) & APC_BPMASK, arg)) { + unlock_kernel(); return -EFAULT; + } break; case APCIOCSFANCTL: - if (get_user(inarg, arg)) + if (get_user(inarg, arg)) { + unlock_kernel(); return -EFAULT; + } apc_writeb(inarg & APC_REGMASK, APC_FANCTL_REG); break; case APCIOCSCPWR: - if (get_user(inarg, arg)) + if (get_user(inarg, arg)) { + unlock_kernel(); return -EFAULT; + } apc_writeb(inarg & APC_REGMASK, APC_CPOWER_REG); break; case APCIOCSBPORT: - if (get_user(inarg, arg)) + if (get_user(inarg, arg)) { + unlock_kernel(); return -EFAULT; + } apc_writeb(inarg & APC_BPMASK, APC_BPORT_REG); break; default: + unlock_kernel(); return -EINVAL; }; + unlock_kernel(); return 0; } static const struct file_operations apc_fops = { - .ioctl = apc_ioctl, - .open = apc_open, - .release = apc_release, + .unlocked_ioctl = apc_ioctl, + .open = apc_open, + .release = apc_release, }; static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops };