Commit b764a15f authored by Alan Cox's avatar Alan Cox Committed by Thomas Gleixner

x86: Switch apm to unlocked_kernel

This pushes the lock a fair way down and the final kill looks like it
should be an easy project for someone who wants to have a shot at it.
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Cc: mingo@redhat.com
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 75d3bce2
...@@ -228,6 +228,7 @@ ...@@ -228,6 +228,7 @@
#include <linux/suspend.h> #include <linux/suspend.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/smp_lock.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -1149,7 +1150,7 @@ static void queue_event(apm_event_t event, struct apm_user *sender) ...@@ -1149,7 +1150,7 @@ static void queue_event(apm_event_t event, struct apm_user *sender)
as->event_tail = 0; as->event_tail = 0;
} }
as->events[as->event_head] = event; as->events[as->event_head] = event;
if ((!as->suser) || (!as->writer)) if (!as->suser || !as->writer)
continue; continue;
switch (event) { switch (event) {
case APM_SYS_SUSPEND: case APM_SYS_SUSPEND:
...@@ -1396,7 +1397,7 @@ static void apm_mainloop(void) ...@@ -1396,7 +1397,7 @@ static void apm_mainloop(void)
static int check_apm_user(struct apm_user *as, const char *func) static int check_apm_user(struct apm_user *as, const char *func)
{ {
if ((as == NULL) || (as->magic != APM_BIOS_MAGIC)) { if (as == NULL || as->magic != APM_BIOS_MAGIC) {
printk(KERN_ERR "apm: %s passed bad filp\n", func); printk(KERN_ERR "apm: %s passed bad filp\n", func);
return 1; return 1;
} }
...@@ -1459,18 +1460,19 @@ static unsigned int do_poll(struct file *fp, poll_table *wait) ...@@ -1459,18 +1460,19 @@ static unsigned int do_poll(struct file *fp, poll_table *wait)
return 0; return 0;
} }
static int do_ioctl(struct inode *inode, struct file *filp, static long do_ioctl(struct file *filp, u_int cmd, u_long arg)
u_int cmd, u_long arg)
{ {
struct apm_user *as; struct apm_user *as;
int ret;
as = filp->private_data; as = filp->private_data;
if (check_apm_user(as, "ioctl")) if (check_apm_user(as, "ioctl"))
return -EIO; return -EIO;
if ((!as->suser) || (!as->writer)) if (!as->suser || !as->writer)
return -EPERM; return -EPERM;
switch (cmd) { switch (cmd) {
case APM_IOC_STANDBY: case APM_IOC_STANDBY:
lock_kernel();
if (as->standbys_read > 0) { if (as->standbys_read > 0) {
as->standbys_read--; as->standbys_read--;
as->standbys_pending--; as->standbys_pending--;
...@@ -1479,8 +1481,10 @@ static int do_ioctl(struct inode *inode, struct file *filp, ...@@ -1479,8 +1481,10 @@ static int do_ioctl(struct inode *inode, struct file *filp,
queue_event(APM_USER_STANDBY, as); queue_event(APM_USER_STANDBY, as);
if (standbys_pending <= 0) if (standbys_pending <= 0)
standby(); standby();
unlock_kernel();
break; break;
case APM_IOC_SUSPEND: case APM_IOC_SUSPEND:
lock_kernel();
if (as->suspends_read > 0) { if (as->suspends_read > 0) {
as->suspends_read--; as->suspends_read--;
as->suspends_pending--; as->suspends_pending--;
...@@ -1488,16 +1492,17 @@ static int do_ioctl(struct inode *inode, struct file *filp, ...@@ -1488,16 +1492,17 @@ static int do_ioctl(struct inode *inode, struct file *filp,
} else } else
queue_event(APM_USER_SUSPEND, as); queue_event(APM_USER_SUSPEND, as);
if (suspends_pending <= 0) { if (suspends_pending <= 0) {
return suspend(1); ret = suspend(1);
} else { } else {
as->suspend_wait = 1; as->suspend_wait = 1;
wait_event_interruptible(apm_suspend_waitqueue, wait_event_interruptible(apm_suspend_waitqueue,
as->suspend_wait == 0); as->suspend_wait == 0);
return as->suspend_result; ret = as->suspend_result;
} }
break; unlock_kernel();
return ret;
default: default:
return -EINVAL; return -ENOTTY;
} }
return 0; return 0;
} }
...@@ -1860,7 +1865,7 @@ static const struct file_operations apm_bios_fops = { ...@@ -1860,7 +1865,7 @@ static const struct file_operations apm_bios_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.read = do_read, .read = do_read,
.poll = do_poll, .poll = do_poll,
.ioctl = do_ioctl, .unlocked_ioctl = do_ioctl,
.open = do_open, .open = do_open,
.release = do_release, .release = do_release,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment