From 289ca025ee1d78223e3368801fc2b984e5efbfc7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 29 Jan 2014 15:53:35 +0100 Subject: ALSA: Use priority list for managing device list Basically, the device type specifies the priority of the device to be registered / freed, too. However, the priority value isn't well utilized but only it's checked as a group. This results in inconsistent register and free order (where each of them should be in reversed direction). This patch simplifies the device list management code by simply inserting a list entry at creation time in an incremental order for the priority value. Since we can just follow the link for register, disconnect and free calls, we don't have to specify the group; so the whole enum definitions are also simplified as well. The visible change to outside is that the priorities of some object types are revisited. For example, now the SNDRV_DEV_LOWLEVEL object is registered before others (control, PCM, etc) and, in return, released after others. Similarly, SNDRV_DEV_CODEC is in a lower priority than SNDRV_DEV_BUS for ensuring the dependency. Also, the unused SNDRV_DEV_TOPLEVEL, SNDRV_DEV_LOWLEVEL_PRE and SNDRV_DEV_LOWLEVEL_NORMAL are removed as a cleanup. Signed-off-by: Takashi Iwai --- sound/core/init.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'sound/core/init.c') diff --git a/sound/core/init.c b/sound/core/init.c index b7085eb..9e7f17b 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -266,7 +266,7 @@ int snd_card_new(struct device *parent, int idx, const char *xid, return 0; __error_ctl: - snd_device_free_all(card, SNDRV_DEV_CMD_PRE); + snd_device_free_all(card); __error: put_device(&card->card_dev); return err; @@ -454,16 +454,8 @@ static int snd_card_do_free(struct snd_card *card) if (snd_mixer_oss_notify_callback) snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_FREE); #endif - if (snd_device_free_all(card, SNDRV_DEV_CMD_PRE) < 0) { - dev_err(card->dev, "unable to free all devices (pre)\n"); - /* Fatal, but this situation should never occur */ - } - if (snd_device_free_all(card, SNDRV_DEV_CMD_NORMAL) < 0) { - dev_err(card->dev, "unable to free all devices (normal)\n"); - /* Fatal, but this situation should never occur */ - } - if (snd_device_free_all(card, SNDRV_DEV_CMD_POST) < 0) { - dev_err(card->dev, "unable to free all devices (post)\n"); + if (snd_device_free_all(card) < 0) { + dev_err(card->dev, "unable to free all devices\n"); /* Fatal, but this situation should never occur */ } if (card->private_free) -- cgit v1.1