--- ../alsa-kernel/ppc/beep.c	2008-02-05 11:23:24.000000000 +0200
+++ beep.c	2008-04-17 15:26:15.732223056 +0300
@@ -1,3 +1,13 @@
+#define __NO_VERSION__
+#include "adriver.h"
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
+#include "beep_old.c"
+#else /* 2.6 kernels */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
+#define input_get_drvdata(dev) (dev->private)
+#endif
+
 /*
  * Beep using pcm
  *
@@ -226,7 +236,11 @@
 		return -ENOMEM;
 	dmabuf = dma_alloc_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4,
 				    &beep->addr, GFP_KERNEL);
+#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 (! dmabuf || ! input_dev)
 		goto fail1;
 
@@ -241,8 +255,15 @@
 	input_dev->evbit[0] = BIT_MASK(EV_SND);
 	input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
 	input_dev->event = snd_pmac_beep_event;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
 	input_dev->dev.parent = &chip->pdev->dev;
 	input_set_drvdata(input_dev, chip);
+#else
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
+	input_dev->cdev.dev = &chip->pdev->dev;
+#endif
+ 	input_dev->private = chip;
+#endif /* 2.6.22 */
 
 	beep->dev = input_dev;
 	beep->buf = dmabuf;
@@ -256,14 +277,23 @@
 
 	chip->beep = beep;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
 	err = input_register_device(beep->dev);
 	if (err)
 		goto fail2;
+#else
+	input_register_device(beep->dev);
+#endif
  
  	return 0;
  
  fail2:	snd_ctl_remove(chip->card, beep_ctl);
- fail1:	input_free_device(input_dev);
+ fail1:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
+	input_free_device(input_dev);
+#else
+	kfree(input_dev);
+#endif
 	if (dmabuf)
 		dma_free_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4,
 				  dmabuf, beep->addr);
@@ -275,9 +305,16 @@
 {
 	if (chip->beep) {
 		input_unregister_device(chip->beep->dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 15)
+		kfree(chip->beep->dev);
+#else
+		input_free_device(chip->beep->dev);
+#endif
 		dma_free_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4,
 				  chip->beep->buf, chip->beep->addr);
 		kfree(chip->beep);
 		chip->beep = NULL;
 	}
 }
+
+#endif
