All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 06/10] ALSA: hda - Manage each codec instance individually
Date: Wed, 26 Feb 2014 07:47:28 +0100	[thread overview]
Message-ID: <1393397252-11690-7-git-send-email-tiwai@suse.de> (raw)
In-Reply-To: <1393397252-11690-1-git-send-email-tiwai@suse.de>

Now each snd_hda_codec instance is managed via the device chain, the
registration and release are done by its callback instead of calling
from bus.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/hda_codec.c | 36 +++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 51360d916e6b..5ea1156954ab 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -821,35 +821,35 @@ static int init_unsol_queue(struct hda_bus *bus)
 /*
  * destructor
  */
-static void snd_hda_codec_free(struct hda_codec *codec);
-
-static int snd_hda_bus_free(struct hda_bus *bus)
+static void snd_hda_bus_free(struct hda_bus *bus)
 {
-	struct hda_codec *codec, *n;
-
 	if (!bus)
-		return 0;
+		return;
+
+	WARN_ON(!list_empty(&bus->codec_list));
 	if (bus->workq)
 		flush_workqueue(bus->workq);
 	if (bus->unsol)
 		kfree(bus->unsol);
-	list_for_each_entry_safe(codec, n, &bus->codec_list, list) {
-		snd_hda_codec_free(codec);
-	}
 	if (bus->ops.private_free)
 		bus->ops.private_free(bus);
 	if (bus->workq)
 		destroy_workqueue(bus->workq);
 
 	kfree(bus);
-	return 0;
 }
 
 static int snd_hda_bus_dev_free(struct snd_device *device)
 {
+	snd_hda_bus_free(device->device_data);
+	return 0;
+}
+
+static int snd_hda_bus_dev_disconnect(struct snd_device *device)
+{
 	struct hda_bus *bus = device->device_data;
 	bus->shutdown = 1;
-	return snd_hda_bus_free(bus);
+	return 0;
 }
 
 /**
@@ -867,6 +867,7 @@ int snd_hda_bus_new(struct snd_card *card,
 	struct hda_bus *bus;
 	int err;
 	static struct snd_device_ops dev_ops = {
+		.dev_disconnect = snd_hda_bus_dev_disconnect,
 		.dev_free = snd_hda_bus_dev_free,
 	};
 
@@ -1376,6 +1377,12 @@ static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec,
 static unsigned int hda_set_power_state(struct hda_codec *codec,
 				unsigned int power_state);
 
+static int snd_hda_codec_dev_free(struct snd_device *device)
+{
+	snd_hda_codec_free(device->device_data);
+	return 0;
+}
+
 /**
  * snd_hda_codec_new - create a HDA codec
  * @bus: the bus to assign
@@ -1392,6 +1399,9 @@ int snd_hda_codec_new(struct hda_bus *bus,
 	char component[31];
 	hda_nid_t fg;
 	int err;
+	static struct snd_device_ops dev_ops = {
+		.dev_free = snd_hda_codec_dev_free,
+	};
 
 	if (snd_BUG_ON(!bus))
 		return -EINVAL;
@@ -1512,6 +1522,10 @@ int snd_hda_codec_new(struct hda_bus *bus,
 		codec->subsystem_id, codec->revision_id);
 	snd_component_add(codec->bus->card, component);
 
+	err = snd_device_new(bus->card, SNDRV_DEV_CODEC, codec, &dev_ops);
+	if (err < 0)
+		goto error;
+
 	if (codecp)
 		*codecp = codec;
 	return 0;
-- 
1.9.0

  parent reply	other threads:[~2014-02-26  6:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-26  6:47 [PATCH 00/10] A few more ALSA and HD-audio core updates Takashi Iwai
2014-02-26  6:47 ` [PATCH 01/10] ALSA: Create sysfs attribute files via groups Takashi Iwai
2014-02-26  6:47 ` [PATCH 02/10] ALSA: hwdep: Take private_data as drvdata for sysfs Takashi Iwai
2014-02-26  6:47 ` [PATCH 03/10] ALSA: hwdep: Allow to assign the given parent Takashi Iwai
2014-02-26  6:47 ` [PATCH 04/10] ALSA: Use priority list for managing device list Takashi Iwai
2014-02-26  6:47 ` [PATCH 05/10] ALSA: Clean up snd_device_*() codes Takashi Iwai
2014-02-26  6:47 ` Takashi Iwai [this message]
2014-02-26  6:47 ` [PATCH 07/10] ALSA: hda - Create own device struct for each codec Takashi Iwai
2014-02-26  6:47 ` [PATCH 08/10] ALSA: hda - Add sysfs to codec object, too Takashi Iwai
2014-02-26  6:47 ` [PATCH 09/10] ALSA: hda - Enable sysfs attributes without CONFIG_SND_HDA_RECONFIG Takashi Iwai
2014-02-26  6:47 ` [PATCH 10/10] ALSA: hda - Replace with standard printk Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393397252-11690-7-git-send-email-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.