[ALSA] Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / sound / core / device.c
index 6ce4da4a1081995317c79523c22bfefd63786529..ea1a0621eefb6680ccd885b014005281ad455820 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Device management routines
- *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
+ *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  *
  *
  *   This program is free software; you can redistribute it and/or modify
@@ -71,7 +71,7 @@ EXPORT_SYMBOL(snd_device_new);
  * @device_data: the data pointer to release
  *
  * Removes the device from the list on the card and invokes the
- * callback, dev_unregister or dev_free, corresponding to the state.
+ * callbacks, dev_disconnect and dev_free, corresponding to the state.
  * Then release the device.
  *
  * Returns zero if successful, or a negative error code on failure or if the
@@ -79,27 +79,23 @@ EXPORT_SYMBOL(snd_device_new);
  */
 int snd_device_free(struct snd_card *card, void *device_data)
 {
-       struct list_head *list;
        struct snd_device *dev;
        
        snd_assert(card != NULL, return -ENXIO);
        snd_assert(device_data != NULL, return -ENXIO);
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);
+       list_for_each_entry(dev, &card->devices, list) {
                if (dev->device_data != device_data)
                        continue;
                /* unlink */
                list_del(&dev->list);
-               if ((dev->state == SNDRV_DEV_REGISTERED ||
-                    dev->state == SNDRV_DEV_DISCONNECTED) &&
-                   dev->ops->dev_unregister) {
-                       if (dev->ops->dev_unregister(dev))
-                               snd_printk(KERN_ERR "device unregister failure\n");
-               } else {
-                       if (dev->ops->dev_free) {
-                               if (dev->ops->dev_free(dev))
-                                       snd_printk(KERN_ERR "device free failure\n");
-                       }
+               if (dev->state == SNDRV_DEV_REGISTERED &&
+                   dev->ops->dev_disconnect)
+                       if (dev->ops->dev_disconnect(dev))
+                               snd_printk(KERN_ERR
+                                          "device disconnect failure\n");
+               if (dev->ops->dev_free) {
+                       if (dev->ops->dev_free(dev))
+                               snd_printk(KERN_ERR "device free failure\n");
                }
                kfree(dev);
                return 0;
@@ -126,13 +122,11 @@ EXPORT_SYMBOL(snd_device_free);
  */
 int snd_device_disconnect(struct snd_card *card, void *device_data)
 {
-       struct list_head *list;
        struct snd_device *dev;
 
        snd_assert(card != NULL, return -ENXIO);
        snd_assert(device_data != NULL, return -ENXIO);
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);
+       list_for_each_entry(dev, &card->devices, list) {
                if (dev->device_data != device_data)
                        continue;
                if (dev->state == SNDRV_DEV_REGISTERED &&
@@ -163,14 +157,12 @@ int snd_device_disconnect(struct snd_card *card, void *device_data)
  */
 int snd_device_register(struct snd_card *card, void *device_data)
 {
-       struct list_head *list;
        struct snd_device *dev;
        int err;
 
        snd_assert(card != NULL, return -ENXIO);
        snd_assert(device_data != NULL, return -ENXIO);
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);
+       list_for_each_entry(dev, &card->devices, list) {
                if (dev->device_data != device_data)
                        continue;
                if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
@@ -194,13 +186,11 @@ EXPORT_SYMBOL(snd_device_register);
  */
 int snd_device_register_all(struct snd_card *card)
 {
-       struct list_head *list;
        struct snd_device *dev;
        int err;
        
        snd_assert(card != NULL, return -ENXIO);
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);
+       list_for_each_entry(dev, &card->devices, list) {
                if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
                        if ((err = dev->ops->dev_register(dev)) < 0)
                                return err;
@@ -217,12 +207,10 @@ int snd_device_register_all(struct snd_card *card)
 int snd_device_disconnect_all(struct snd_card *card)
 {
        struct snd_device *dev;
-       struct list_head *list;
        int err = 0;
 
        snd_assert(card != NULL, return -ENXIO);
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);
+       list_for_each_entry(dev, &card->devices, list) {
                if (snd_device_disconnect(card, dev->device_data) < 0)
                        err = -ENXIO;
        }
@@ -236,7 +224,6 @@ int snd_device_disconnect_all(struct snd_card *card)
 int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
 {
        struct snd_device *dev;
-       struct list_head *list;
        int err;
        unsigned int range_low, range_high;
 
@@ -244,8 +231,7 @@ int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
        range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE;
        range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1;
       __again:
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);         
+       list_for_each_entry(dev, &card->devices, list) {
                if (dev->type >= range_low && dev->type <= range_high) {
                        if ((err = snd_device_free(card, dev->device_data)) < 0)
                                return err;