Skip to contentSkip to conversation

apm_emu: push BKL down into ioctl handlers

PATCH In review Alan Cox 2 participants 3 messages May 22, 2008

Subsystems (2)
lore
Share & tools
lore

Alan Cox

author
#0 lore raw

PATCH 1/1 apm_emu: push BKL down into ioctl handlers

Part of the elimination of the old lock based ioctl. This one can probably lose the remaining BKL pretty trivially

author
#2 lore raw
Quoted 6 lines · On Thu, 22 May 2008 22:40:59 +0200 Sam Ravnborg <[email protected]> wrote:
Quoted 4 lines · Alan Cox

Part of the elimination of the old lock based ioctl. This one can probably lose the remaining BKL pretty trivially

-ENOPATCH

Must be race between the sending gnomes and the pasting gnome ;)

drivers/char/apm-emulation.c +6 -4
index cdd876d..4ea7188 100644
@@ -29,6 +29,7 @@
 #include <linux/completion.h>
 #include <linux/kthread.h>
 #include <linux/delay.h>
+#include <linux/smp_lock.h>
 
 #include <asm/system.h>
 
@@ -292,8 +293,7 @@ static unsigned int apm_poll(struct file *fp, poll_table * wait)
  *   Only when everyone who has opened /dev/apm_bios with write permission
  *   has acknowledge does the actual suspend happen.
  */
-static int
-apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
+static long apm_ioctl(struct file *filp, u_int cmd, u_long arg)
 {
 	struct apm_user *as = filp->private_data;
 	int err = -EINVAL;
@@ -301,6 +301,8 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
 	if (!as->suser || !as->writer)
 		return -EPERM;
 
+	lock_kernel();
+
 	switch (cmd) {
 	case APM_IOC_SUSPEND:
 		mutex_lock(&state_lock);
@@ -378,7 +380,7 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
 		mutex_unlock(&state_lock);
 		break;
 	}
-
+	unlock_kernel();
 	return err;
 }
 
@@ -443,7 +445,7 @@ static struct file_operations apm_bios_fops = {
 	.owner		= THIS_MODULE,
 	.read		= apm_read,
 	.poll		= apm_poll,
-	.ioctl		= apm_ioctl,
+	.unlocked_ioctl	= apm_ioctl,
 	.open		= apm_open,
 	.release	= apm_release,
 };