linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / sound / core / hwdep.c
index a562f96..618c43b 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/time.h>
-#include <linux/mutex.h>
 #include <sound/core.h>
 #include <sound/control.h>
 #include <sound/minors.h>
@@ -37,7 +36,7 @@ MODULE_DESCRIPTION("Hardware dependent layer");
 MODULE_LICENSE("GPL");
 
 static LIST_HEAD(snd_hwdep_devices);
-static DEFINE_MUTEX(register_mutex);
+static DECLARE_MUTEX(register_mutex);
 
 static int snd_hwdep_free(struct snd_hwdep *hwdep);
 static int snd_hwdep_dev_free(struct snd_device *device);
@@ -112,7 +111,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
 
        init_waitqueue_entry(&wait, current);
        add_wait_queue(&hw->open_wait, &wait);
-       mutex_lock(&hw->open_mutex);
+       down(&hw->open_mutex);
        while (1) {
                if (hw->exclusive && hw->used > 0) {
                        err = -EBUSY;
@@ -129,9 +128,9 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
                } else
                        break;
                set_current_state(TASK_INTERRUPTIBLE);
-               mutex_unlock(&hw->open_mutex);
+               up(&hw->open_mutex);
                schedule();
-               mutex_lock(&hw->open_mutex);
+               down(&hw->open_mutex);
                if (signal_pending(current)) {
                        err = -ERESTARTSYS;
                        break;
@@ -148,7 +147,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
                                hw->ops.release(hw, file);
                }
        }
-       mutex_unlock(&hw->open_mutex);
+       up(&hw->open_mutex);
        if (err < 0)
                module_put(hw->card->module);
        return err;
@@ -158,8 +157,7 @@ static int snd_hwdep_release(struct inode *inode, struct file * file)
 {
        int err = -ENXIO;
        struct snd_hwdep *hw = file->private_data;
-       struct module *mod = hw->card->module;
-       mutex_lock(&hw->open_mutex);
+       down(&hw->open_mutex);
        if (hw->ops.release) {
                err = hw->ops.release(hw, file);
                wake_up(&hw->open_wait);
@@ -167,8 +165,8 @@ static int snd_hwdep_release(struct inode *inode, struct file * file)
        if (hw->used > 0)
                hw->used--;
        snd_card_file_remove(hw->card, file);
-       mutex_unlock(&hw->open_mutex);
-       module_put(mod);
+       up(&hw->open_mutex);
+       module_put(hw->card->module);
        return err;
 }
 
@@ -274,7 +272,7 @@ static int snd_hwdep_control_ioctl(struct snd_card *card,
 
                        if (get_user(device, (int __user *)arg))
                                return -EFAULT;
-                       mutex_lock(&register_mutex);
+                       down(&register_mutex);
                        device = device < 0 ? 0 : device + 1;
                        while (device < SNDRV_MINOR_HWDEPS) {
                                if (snd_hwdep_search(card, device))
@@ -283,7 +281,7 @@ static int snd_hwdep_control_ioctl(struct snd_card *card,
                        }
                        if (device >= SNDRV_MINOR_HWDEPS)
                                device = -1;
-                       mutex_unlock(&register_mutex);
+                       up(&register_mutex);
                        if (put_user(device, (int __user *)arg))
                                return -EFAULT;
                        return 0;
@@ -296,13 +294,13 @@ static int snd_hwdep_control_ioctl(struct snd_card *card,
 
                        if (get_user(device, &info->device))
                                return -EFAULT;
-                       mutex_lock(&register_mutex);
+                       down(&register_mutex);
                        hwdep = snd_hwdep_search(card, device);
                        if (hwdep)
                                err = snd_hwdep_info(hwdep, info);
                        else
                                err = -ENXIO;
-                       mutex_unlock(&register_mutex);
+                       up(&register_mutex);
                        return err;
                }
        }
@@ -377,7 +375,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device,
                return err;
        }
        init_waitqueue_head(&hwdep->open_wait);
-       mutex_init(&hwdep->open_mutex);
+       init_MUTEX(&hwdep->open_mutex);
        *rhwdep = hwdep;
        return 0;
 }
@@ -403,9 +401,9 @@ static int snd_hwdep_dev_register(struct snd_device *device)
        int err;
        char name[32];
 
-       mutex_lock(&register_mutex);
+       down(&register_mutex);
        if (snd_hwdep_search(hwdep->card, hwdep->device)) {
-               mutex_unlock(&register_mutex);
+               up(&register_mutex);
                return -EBUSY;
        }
        list_add_tail(&hwdep->list, &snd_hwdep_devices);
@@ -416,7 +414,7 @@ static int snd_hwdep_dev_register(struct snd_device *device)
                snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n",
                           hwdep->card->number, hwdep->device);
                list_del(&hwdep->list);
-               mutex_unlock(&register_mutex);
+               up(&register_mutex);
                return err;
        }
 #ifdef CONFIG_SND_OSSEMUL
@@ -436,7 +434,7 @@ static int snd_hwdep_dev_register(struct snd_device *device)
                }
        }
 #endif
-       mutex_unlock(&register_mutex);
+       up(&register_mutex);
        return 0;
 }
 
@@ -445,9 +443,9 @@ static int snd_hwdep_dev_unregister(struct snd_device *device)
        struct snd_hwdep *hwdep = device->device_data;
 
        snd_assert(hwdep != NULL, return -ENXIO);
-       mutex_lock(&register_mutex);
+       down(&register_mutex);
        if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) {
-               mutex_unlock(&register_mutex);
+               up(&register_mutex);
                return -EINVAL;
        }
 #ifdef CONFIG_SND_OSSEMUL
@@ -456,7 +454,7 @@ static int snd_hwdep_dev_unregister(struct snd_device *device)
 #endif
        snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device);
        list_del(&hwdep->list);
-       mutex_unlock(&register_mutex);
+       up(&register_mutex);
        return snd_hwdep_free(hwdep);
 }
 
@@ -471,13 +469,13 @@ static void snd_hwdep_proc_read(struct snd_info_entry *entry,
        struct list_head *p;
        struct snd_hwdep *hwdep;
 
-       mutex_lock(&register_mutex);
+       down(&register_mutex);
        list_for_each(p, &snd_hwdep_devices) {
                hwdep = list_entry(p, struct snd_hwdep, list);
                snd_iprintf(buffer, "%02i-%02i: %s\n",
                            hwdep->card->number, hwdep->device, hwdep->name);
        }
-       mutex_unlock(&register_mutex);
+       up(&register_mutex);
 }
 
 static struct snd_info_entry *snd_hwdep_proc_entry;
@@ -487,6 +485,7 @@ static void __init snd_hwdep_proc_init(void)
        struct snd_info_entry *entry;
 
        if ((entry = snd_info_create_module_entry(THIS_MODULE, "hwdep", NULL)) != NULL) {
+               entry->c.text.read_size = PAGE_SIZE;
                entry->c.text.read = snd_hwdep_proc_read;
                if (snd_info_register(entry) < 0) {
                        snd_info_free_entry(entry);