--- ../alsa-kernel/core/rawmidi.c	2009-12-15 22:08:58.000000000 +0100
+++ rawmidi.c	2009-12-15 22:25:55.000000000 +0100
@@ -1,3 +1,4 @@
+#include "adriver.h"
 /*
  *  Abstract layer for MIDI v1.0 stream
  *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
@@ -22,6 +23,7 @@
 #include <sound/core.h>
 #include <linux/major.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/time.h>
@@ -1257,6 +1259,9 @@
 			break;
 		count -= count1;
 	}
+#ifndef O_DSYNC
+#define O_DSYNC O_SYNC
+#endif
 	if (file->f_flags & O_DSYNC) {
 		spin_lock_irq(&runtime->lock);
 		while (runtime->avail != runtime->buffer_size) {
@@ -1309,12 +1314,25 @@
 
 /*
  */
-#ifdef CONFIG_COMPAT
+#if defined(CONFIG_COMPAT) && defined(CONFIG_SND_HAVE_NEW_IOCTL)
 #include "rawmidi_compat.c"
 #else
 #define snd_rawmidi_ioctl_compat	NULL
 #endif
 
+#ifndef CONFIG_SND_HAVE_NEW_IOCTL
+/* need to unlock BKL to allow preemption */
+static int snd_rawmidi_ioctl_old(struct inode *inode, struct file * file,
+				 unsigned int cmd, unsigned long arg)
+{
+	int err;
+	unlock_kernel();
+	err = snd_rawmidi_ioctl(file, cmd, arg);
+	lock_kernel();
+	return err;
+}
+#endif
+
 /*
 
  */
@@ -1386,14 +1404,20 @@
 
 static const struct file_operations snd_rawmidi_f_ops =
 {
+#ifndef LINUX_2_2
 	.owner =	THIS_MODULE,
+#endif
 	.read =		snd_rawmidi_read,
 	.write =	snd_rawmidi_write,
 	.open =		snd_rawmidi_open,
 	.release =	snd_rawmidi_release,
 	.poll =		snd_rawmidi_poll,
+#ifdef CONFIG_SND_HAVE_NEW_IOCTL
 	.unlocked_ioctl =	snd_rawmidi_ioctl,
 	.compat_ioctl =	snd_rawmidi_ioctl_compat,
+#else
+	.ioctl =	snd_rawmidi_ioctl_old,
+#endif
 };
 
 static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi,
