vserver 1.9.3
[linux-2.6.git] / sound / core / hwdep.c
index d18e476..b79f231 100644 (file)
@@ -22,6 +22,7 @@
 #include <sound/driver.h>
 #include <linux/major.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/time.h>
 #include <sound/core.h>
@@ -49,7 +50,7 @@ static int snd_hwdep_dev_unregister(snd_device_t *device);
 
 static loff_t snd_hwdep_llseek(struct file * file, loff_t offset, int orig)
 {
-       snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return -ENXIO);
+       snd_hwdep_t *hw = file->private_data;
        if (hw->ops.llseek)
                return hw->ops.llseek(hw, file, offset, orig);
        return -ENXIO;
@@ -57,7 +58,7 @@ static loff_t snd_hwdep_llseek(struct file * file, loff_t offset, int orig)
 
 static ssize_t snd_hwdep_read(struct file * file, char __user *buf, size_t count, loff_t *offset)
 {
-       snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return -ENXIO);
+       snd_hwdep_t *hw = file->private_data;
        if (hw->ops.read)
                return hw->ops.read(hw, buf, count, offset);
        return -ENXIO;  
@@ -65,7 +66,7 @@ static ssize_t snd_hwdep_read(struct file * file, char __user *buf, size_t count
 
 static ssize_t snd_hwdep_write(struct file * file, const char __user *buf, size_t count, loff_t *offset)
 {
-       snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return -ENXIO);
+       snd_hwdep_t *hw = file->private_data;
        if (hw->ops.write)
                return hw->ops.write(hw, buf, count, offset);
        return -ENXIO;  
@@ -157,7 +158,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
 static int snd_hwdep_release(struct inode *inode, struct file * file)
 {
        int err = -ENXIO;
-       snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return -ENXIO);
+       snd_hwdep_t *hw = file->private_data;
        down(&hw->open_mutex);
        if (hw->ops.release) {
                err = hw->ops.release(hw, file);
@@ -173,7 +174,7 @@ static int snd_hwdep_release(struct inode *inode, struct file * file)
 
 static unsigned int snd_hwdep_poll(struct file * file, poll_table * wait)
 {
-       snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return 0);
+       snd_hwdep_t *hw = file->private_data;
        if (hw->ops.poll)
                return hw->ops.poll(hw, file, wait);
        return 0;
@@ -231,10 +232,10 @@ static int snd_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t __user *_in
        return 0;
 }
 
-static insnd_hwdep_ioctl(struct inode *inode, struct file * file,
-                          unsigned int cmd, unsigned long arg)
+static inline int _snd_hwdep_ioctl(struct inode *inode, struct file * file,
+                                  unsigned int cmd, unsigned long arg)
 {
-       snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return -ENXIO);
+       snd_hwdep_t *hw = file->private_data;
        void __user *argp = (void __user *)arg;
        switch (cmd) {
        case SNDRV_HWDEP_IOCTL_PVERSION:
@@ -251,9 +252,20 @@ static int snd_hwdep_ioctl(struct inode *inode, struct file * file,
        return -ENOTTY;
 }
 
+/* FIXME: need to unlock BKL to allow preemption */
+static int snd_hwdep_ioctl(struct inode *inode, struct file * file,
+                          unsigned int cmd, unsigned long arg)
+{
+       int err;
+       unlock_kernel();
+       err = _snd_hwdep_ioctl(inode, file, cmd, arg);
+       lock_kernel();
+       return err;
+}
+
 static int snd_hwdep_mmap(struct file * file, struct vm_area_struct * vma)
 {
-       snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return -ENXIO);
+       snd_hwdep_t *hw = file->private_data;
        if (hw->ops.mmap)
                return hw->ops.mmap(hw, file, vma);
        return -ENXIO;
@@ -352,7 +364,7 @@ int snd_hwdep_new(snd_card_t * card, char *id, int device, snd_hwdep_t ** rhwdep
        snd_assert(rhwdep != NULL, return -EINVAL);
        *rhwdep = NULL;
        snd_assert(card != NULL, return -ENXIO);
-       hwdep = snd_magic_kcalloc(snd_hwdep_t, 0, GFP_KERNEL);
+       hwdep = kcalloc(1, sizeof(*hwdep), GFP_KERNEL);
        if (hwdep == NULL)
                return -ENOMEM;
        hwdep->card = card;
@@ -378,19 +390,19 @@ static int snd_hwdep_free(snd_hwdep_t *hwdep)
        snd_assert(hwdep != NULL, return -ENXIO);
        if (hwdep->private_free)
                hwdep->private_free(hwdep);
-       snd_magic_kfree(hwdep);
+       kfree(hwdep);
        return 0;
 }
 
 static int snd_hwdep_dev_free(snd_device_t *device)
 {
-       snd_hwdep_t *hwdep = snd_magic_cast(snd_hwdep_t, device->device_data, return -ENXIO);
+       snd_hwdep_t *hwdep = device->device_data;
        return snd_hwdep_free(hwdep);
 }
 
 static int snd_hwdep_dev_register(snd_device_t *device)
 {
-       snd_hwdep_t *hwdep = snd_magic_cast(snd_hwdep_t, device->device_data, return -ENXIO);
+       snd_hwdep_t *hwdep = device->device_data;
        int idx, err;
        char name[32];
 
@@ -433,7 +445,7 @@ static int snd_hwdep_dev_register(snd_device_t *device)
 
 static int snd_hwdep_dev_unregister(snd_device_t *device)
 {
-       snd_hwdep_t *hwdep = snd_magic_cast(snd_hwdep_t, device->device_data, return -ENXIO);
+       snd_hwdep_t *hwdep = device->device_data;
        int idx;
 
        snd_assert(hwdep != NULL, return -ENXIO);