Merge branch 'topic/memdup_user' into for-linus
[linux-2.6.git] / sound / isa / wavefront / wavefront_fx.c
index 15331ed..2bb1cee 100644 (file)
@@ -16,7 +16,6 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-#include <sound/driver.h>
 #include <asm/io.h>
 #include <linux/init.h>
 #include <linux/time.h>
 
 #define WAIT_IDLE      0xff
 
-#define FIRMWARE_IN_THE_KERNEL
-
-#ifdef FIRMWARE_IN_THE_KERNEL
-#include "yss225.c"
-static const struct firmware yss225_registers_firmware = {
-       .data = (u8 *)yss225_registers,
-       .size = sizeof yss225_registers
-};
-#endif
-
 static int
 wavefront_fx_idle (snd_wavefront_t *dev)
 
@@ -183,11 +172,11 @@ snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file,
        unsigned short *pd;
        int err = 0;
 
-       snd_assert(sdev->card != NULL, return -ENODEV);
-       
        card = sdev->card;
-
-       snd_assert(card->private_data != NULL, return -ENODEV);
+       if (snd_BUG_ON(!card))
+               return -ENODEV;
+       if (snd_BUG_ON(!card->private_data))
+               return -ENODEV;
 
        acard = card->private_data;
        dev = &acard->wavefront;
@@ -213,15 +202,11 @@ snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file,
                                            "> 512 bytes to FX\n");
                                return -EIO;
                        }
-                       page_data = kmalloc(r.data[2] * sizeof(short), GFP_KERNEL);
-                       if (!page_data)
-                               return -ENOMEM;
-                       if (copy_from_user (page_data,
-                                           (unsigned char __user *) r.data[3],
-                                           r.data[2] * sizeof(short))) {
-                               kfree(page_data);
-                               return -EFAULT;
-                       }
+                       page_data = memdup_user((unsigned char __user *)
+                                               r.data[3],
+                                               r.data[2] * sizeof(short));
+                       if (IS_ERR(page_data))
+                               return PTR_ERR(page_data);
                        pd = page_data;
                }
 
@@ -258,7 +243,7 @@ snd_wavefront_fx_start (snd_wavefront_t *dev)
 {
        unsigned int i;
        int err;
-       const struct firmware *firmware;
+       const struct firmware *firmware = NULL;
 
        if (dev->fx_initialized)
                return 0;
@@ -266,12 +251,8 @@ snd_wavefront_fx_start (snd_wavefront_t *dev)
        err = request_firmware(&firmware, "yamaha/yss225_registers.bin",
                               dev->card->dev);
        if (err < 0) {
-#ifdef FIRMWARE_IN_THE_KERNEL
-               firmware = &yss225_registers_firmware;
-#else
                err = -1;
                goto out;
-#endif
        }
 
        for (i = 0; i + 1 < firmware->size; i += 2) {
@@ -295,9 +276,8 @@ snd_wavefront_fx_start (snd_wavefront_t *dev)
        err = 0;
 
 out:
-#ifdef FIRMWARE_IN_THE_KERNEL
-       if (firmware != &yss225_registers_firmware)
-#endif
-               release_firmware(firmware);
+       release_firmware(firmware);
        return err;
 }
+
+MODULE_FIRMWARE("yamaha/yss225_registers.bin");