]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - sound/core/seq/seq_device.c
[ALSA] alsa core: convert to list_for_each_entry*
[mirror_ubuntu-artful-kernel.git] / sound / core / seq / seq_device.c
index d9a3e5a18d6ad0ae3ef60ec3f82e2adedba71315..37852cdace76091c83a4c33b063c1a60f5a0959c 100644 (file)
@@ -80,7 +80,7 @@ static LIST_HEAD(opslist);
 static int num_ops;
 static DEFINE_MUTEX(ops_mutex);
 #ifdef CONFIG_PROC_FS
-static struct snd_info_entry *info_entry = NULL;
+static struct snd_info_entry *info_entry;
 #endif
 
 /*
@@ -90,7 +90,6 @@ static int snd_seq_device_free(struct snd_seq_device *dev);
 static int snd_seq_device_dev_free(struct snd_device *device);
 static int snd_seq_device_dev_register(struct snd_device *device);
 static int snd_seq_device_dev_disconnect(struct snd_device *device);
-static int snd_seq_device_dev_unregister(struct snd_device *device);
 
 static int init_device(struct snd_seq_device *dev, struct ops_list *ops);
 static int free_device(struct snd_seq_device *dev, struct ops_list *ops);
@@ -107,11 +106,10 @@ static void remove_drivers(void);
 static void snd_seq_device_info(struct snd_info_entry *entry,
                                struct snd_info_buffer *buffer)
 {
-       struct list_head *head;
+       struct ops_list *ops;
 
        mutex_lock(&ops_mutex);
-       list_for_each(head, &opslist) {
-               struct ops_list *ops = list_entry(head, struct ops_list, list);
+       list_for_each_entry(ops, &opslist, list) {
                snd_iprintf(buffer, "snd-%s%s%s%s,%d\n",
                                ops->id,
                                ops->driver & DRIVER_LOADED ? ",loaded" : (ops->driver == DRIVER_EMPTY ? ",empty" : ""),
@@ -144,7 +142,7 @@ void snd_seq_autoload_unlock(void)
 void snd_seq_device_load_drivers(void)
 {
 #ifdef CONFIG_KMOD
-       struct list_head *head;
+       struct ops_list *ops;
 
        /* Calling request_module during module_init()
         * may cause blocking.
@@ -156,8 +154,7 @@ void snd_seq_device_load_drivers(void)
                return;
 
        mutex_lock(&ops_mutex);
-       list_for_each(head, &opslist) {
-               struct ops_list *ops = list_entry(head, struct ops_list, list);
+       list_for_each_entry(ops, &opslist, list) {
                if (! (ops->driver & DRIVER_LOADED) &&
                    ! (ops->driver & DRIVER_REQUESTED)) {
                        ops->used++;
@@ -189,7 +186,6 @@ int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize,
                .dev_free = snd_seq_device_dev_free,
                .dev_register = snd_seq_device_dev_register,
                .dev_disconnect = snd_seq_device_dev_disconnect,
-               .dev_unregister = snd_seq_device_dev_unregister
        };
 
        if (result)
@@ -308,15 +304,6 @@ static int snd_seq_device_dev_disconnect(struct snd_device *device)
        return 0;
 }
 
-/*
- * unregister the existing device
- */
-static int snd_seq_device_dev_unregister(struct snd_device *device)
-{
-       struct snd_seq_device *dev = device->device_data;
-       return snd_seq_device_free(dev);
-}
-
 /*
  * register device driver
  * id = driver id
@@ -325,8 +312,8 @@ static int snd_seq_device_dev_unregister(struct snd_device *device)
 int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
                                   int argsize)
 {
-       struct list_head *head;
        struct ops_list *ops;
+       struct snd_seq_device *dev;
 
        if (id == NULL || entry == NULL ||
            entry->init_device == NULL || entry->free_device == NULL)
@@ -352,8 +339,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
        ops->argsize = argsize;
 
        /* initialize existing devices if necessary */
-       list_for_each(head, &ops->dev_list) {
-               struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
+       list_for_each_entry(dev, &ops->dev_list, list) {
                init_device(dev, ops);
        }
        mutex_unlock(&ops->reg_mutex);
@@ -372,14 +358,19 @@ static struct ops_list * create_driver(char *id)
 {
        struct ops_list *ops;
 
-       ops = kmalloc(sizeof(*ops), GFP_KERNEL);
+       ops = kzalloc(sizeof(*ops), GFP_KERNEL);
        if (ops == NULL)
                return ops;
-       memset(ops, 0, sizeof(*ops));
 
        /* set up driver entry */
        strlcpy(ops->id, id, sizeof(ops->id));
        mutex_init(&ops->reg_mutex);
+       /*
+        * The ->reg_mutex locking rules are per-driver, so we create
+        * separate per-driver lock classes:
+        */
+       lockdep_set_class(&ops->reg_mutex, (struct lock_class_key *)id);
+
        ops->driver = DRIVER_EMPTY;
        INIT_LIST_HEAD(&ops->dev_list);
        /* lock this instance */
@@ -400,8 +391,8 @@ static struct ops_list * create_driver(char *id)
  */
 int snd_seq_device_unregister_driver(char *id)
 {
-       struct list_head *head;
        struct ops_list *ops;
+       struct snd_seq_device *dev;
 
        ops = find_driver(id, 0);
        if (ops == NULL)
@@ -417,8 +408,7 @@ int snd_seq_device_unregister_driver(char *id)
        /* close and release all devices associated with this driver */
        mutex_lock(&ops->reg_mutex);
        ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */
-       list_for_each(head, &ops->dev_list) {
-               struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
+       list_for_each_entry(dev, &ops->dev_list, list) {
                free_device(dev, ops);
        }
 
@@ -518,11 +508,10 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
  */
 static struct ops_list * find_driver(char *id, int create_if_empty)
 {
-       struct list_head *head;
+       struct ops_list *ops;
 
        mutex_lock(&ops_mutex);
-       list_for_each(head, &opslist) {
-               struct ops_list *ops = list_entry(head, struct ops_list, list);
+       list_for_each_entry(ops, &opslist, list) {
                if (strcmp(ops->id, id) == 0) {
                        ops->used++;
                        mutex_unlock(&ops_mutex);
@@ -555,7 +544,6 @@ static int __init alsa_seq_device_init(void)
        if (info_entry == NULL)
                return -ENOMEM;
        info_entry->content = SNDRV_INFO_CONTENT_TEXT;
-       info_entry->c.text.read_size = 2048;
        info_entry->c.text.read = snd_seq_device_info;
        if (snd_info_register(info_entry) < 0) {
                snd_info_free_entry(info_entry);
@@ -569,7 +557,7 @@ static void __exit alsa_seq_device_exit(void)
 {
        remove_drivers();
 #ifdef CONFIG_PROC_FS
-       snd_info_unregister(info_entry);
+       snd_info_free_entry(info_entry);
 #endif
        if (num_ops)
                snd_printk(KERN_ERR "drivers not released (%d)\n", num_ops);