All of lore.kernel.org
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
To: broonie@kernel.org
Cc: alsa-devel@alsa-project.org, lars@metafoo.de,
	lgirdwood@gmail.com, patches@opensource.wolfsonmicro.com
Subject: [PATCH v3 3/5] ASoC: dapm: Append "Autodisable" to autodisable widget names
Date: Fri,  1 May 2015 12:37:25 +0100	[thread overview]
Message-ID: <1430480247-28753-3-git-send-email-ckeepax@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1430480247-28753-1-git-send-email-ckeepax@opensource.wolfsonmicro.com>

This makes it a little easier to follow what is happening in debugfs.
Additionally is also useful in facilitating work to add autodisable
muxes because the control name is already used for the mux widget and
thus shouldn't be reused for the autodisable widget.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/soc-dapm.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index beb48b6..a0d97f8 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -308,6 +308,8 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
 {
 	struct dapm_kcontrol_data *data;
 	struct soc_mixer_control *mc;
+	const char *name;
+	int ret;
 
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data)
@@ -324,6 +326,13 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
 		if (mc->autodisable) {
 			struct snd_soc_dapm_widget template;
 
+			name = kasprintf(GFP_KERNEL, "%s %s", kcontrol->id.name,
+					 "Autodisable");
+			if (!name) {
+				ret = -ENOMEM;
+				goto err_data;
+			}
+
 			memset(&template, 0, sizeof(template));
 			template.reg = mc->reg;
 			template.mask = (1 << fls(mc->max)) - 1;
@@ -334,15 +343,15 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
 				template.off_val = 0;
 			template.on_val = template.off_val;
 			template.id = snd_soc_dapm_kcontrol;
-			template.name = kcontrol->id.name;
+			template.name = name;
 
 			data->value = template.on_val;
 
 			data->widget = snd_soc_dapm_new_control(widget->dapm,
 				&template);
 			if (!data->widget) {
-				kfree(data);
-				return -ENOMEM;
+				ret = -ENOMEM;
+				goto err_name;
 			}
 		}
 		break;
@@ -353,11 +362,19 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
 	kcontrol->private_data = data;
 
 	return 0;
+
+err_name:
+	kfree(name);
+err_data:
+	kfree(data);
+	return ret;
 }
 
 static void dapm_kcontrol_free(struct snd_kcontrol *kctl)
 {
 	struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl);
+	if (data->widget)
+		kfree(data->widget->name);
 	kfree(data->wlist);
 	kfree(data);
 }
-- 
1.7.2.5

  parent reply	other threads:[~2015-05-01 11:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-01 11:37 [PATCH v3 1/5] ASoC: Correct typo in SOC_VALUE_ENUM_SINGLE macro Charles Keepax
2015-05-01 11:37 ` [PATCH v3 2/5] ASoC: dapm: Remove local OOM error message Charles Keepax
2015-05-04 12:04   ` Mark Brown
2015-05-01 11:37 ` Charles Keepax [this message]
2015-05-04 12:04   ` [PATCH v3 3/5] ASoC: dapm: Append "Autodisable" to autodisable widget names Mark Brown
2015-05-01 11:37 ` [PATCH v3 4/5] ASoC: dapm: Add support for autodisable mux controls Charles Keepax
2015-05-06 16:12   ` Mark Brown
2015-05-01 11:37 ` [PATCH v3 5/5] ASoC: arizona: Use auto disable muxes for routing Charles Keepax
2015-05-06 16:16   ` Mark Brown
2015-05-01 14:31 ` [PATCH v3 1/5] ASoC: Correct typo in SOC_VALUE_ENUM_SINGLE macro Lars-Peter Clausen
2015-05-04 12:03 ` Mark Brown
2015-05-04 14:23   ` Charles Keepax

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=1430480247-28753-3-git-send-email-ckeepax@opensource.wolfsonmicro.com \
    --to=ckeepax@opensource.wolfsonmicro.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=patches@opensource.wolfsonmicro.com \
    /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.