--- ../../alsa-kernel/pci/hda/hda_beep.c	2009-11-04 14:33:48.000000000 +0100
+++ hda_beep.c	2009-11-10 13:25:36.000000000 +0100
@@ -1,3 +1,5 @@
+#define __NO_VERSION__
+#include "adriver.h"
 /*
  * Digital Beep Input Interface for HD-audio codec
  *
@@ -92,7 +94,11 @@ static int beep_standard_tone(struct hda
 static int snd_hda_beep_event(struct input_dev *dev, unsigned int type,
 				unsigned int code, int hz)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
+	struct hda_beep *beep = dev->private;
+#else
 	struct hda_beep *beep = input_get_drvdata(dev);
+#endif
 
 	switch (code) {
 	case SND_BELL:
@@ -116,8 +122,13 @@ static int snd_hda_beep_event(struct inp
 static void snd_hda_do_detach(struct hda_beep *beep)
 {
 	input_unregister_device(beep->dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 15)
+	kfree(beep->dev);
+#endif
 	beep->dev = NULL;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
 	cancel_work_sync(&beep->beep_work);
+#endif
 	/* turn off beep for sure */
 	snd_hda_codec_write_cache(beep->codec, beep->nid, 0,
 				  AC_VERB_SET_BEEP_CONTROL, 0);
@@ -129,7 +140,11 @@ static int snd_hda_do_attach(struct hda_
 	struct hda_codec *codec = beep->codec;
 	int err;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
 	input_dev = input_allocate_device();
+#else
+	input_dev = kzalloc(sizeof(*input_dev), GFP_KERNEL);
+#endif
 	if (!input_dev) {
 		printk(KERN_INFO "hda_beep: unable to allocate input device\n");
 		return -ENOMEM;
@@ -147,15 +162,26 @@ static int snd_hda_do_attach(struct hda_
 	input_dev->evbit[0] = BIT_MASK(EV_SND);
 	input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
 	input_dev->event = snd_hda_beep_event;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
 	input_dev->dev.parent = &codec->bus->pci->dev;
 	input_set_drvdata(input_dev, beep);
+#else
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
+	input_dev->cdev.dev = &codec->bus->pci->dev;
+#endif
+	input_dev->private = beep;
+#endif /* 2.6.22 */ 
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
 	err = input_register_device(input_dev);
 	if (err < 0) {
 		input_free_device(input_dev);
 		printk(KERN_INFO "hda_beep: unable to register input device\n");
 		return err;
 	}
+#else
+	input_register_device(input_dev);
+#endif
 	beep->dev = input_dev;
 	return 0;
 }
@@ -238,7 +264,9 @@ void snd_hda_detach_beep_device(struct h
 {
 	struct hda_beep *beep = codec->beep;
 	if (beep) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
 		cancel_work_sync(&beep->register_work);
+#endif
 		cancel_delayed_work(&beep->unregister_work);
 		if (beep->enabled)
 			snd_hda_do_detach(beep);
