aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2015-05-01 07:37:25 -0400
committerMark Brown <broonie@kernel.org>2015-05-06 12:12:57 -0400
commit773da9b358bfbef1b7a862425fea0d9d9d3443f8 (patch)
tree8432cc1a3aae321a07fb59682ff7075ed4c46f6b
parent5967cb3d87802908fe5ab96aa0b417606bf4ca3b (diff)
ASoC: dapm: Append "Autodisable" to autodisable widget names
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> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/soc-dapm.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index beb48b608142..a0d97f89eb75 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,
308{ 308{
309 struct dapm_kcontrol_data *data; 309 struct dapm_kcontrol_data *data;
310 struct soc_mixer_control *mc; 310 struct soc_mixer_control *mc;
311 const char *name;
312 int ret;
311 313
312 data = kzalloc(sizeof(*data), GFP_KERNEL); 314 data = kzalloc(sizeof(*data), GFP_KERNEL);
313 if (!data) 315 if (!data)
@@ -324,6 +326,13 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
324 if (mc->autodisable) { 326 if (mc->autodisable) {
325 struct snd_soc_dapm_widget template; 327 struct snd_soc_dapm_widget template;
326 328
329 name = kasprintf(GFP_KERNEL, "%s %s", kcontrol->id.name,
330 "Autodisable");
331 if (!name) {
332 ret = -ENOMEM;
333 goto err_data;
334 }
335
327 memset(&template, 0, sizeof(template)); 336 memset(&template, 0, sizeof(template));
328 template.reg = mc->reg; 337 template.reg = mc->reg;
329 template.mask = (1 << fls(mc->max)) - 1; 338 template.mask = (1 << fls(mc->max)) - 1;
@@ -334,15 +343,15 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
334 template.off_val = 0; 343 template.off_val = 0;
335 template.on_val = template.off_val; 344 template.on_val = template.off_val;
336 template.id = snd_soc_dapm_kcontrol; 345 template.id = snd_soc_dapm_kcontrol;
337 template.name = kcontrol->id.name; 346 template.name = name;
338 347
339 data->value = template.on_val; 348 data->value = template.on_val;
340 349
341 data->widget = snd_soc_dapm_new_control(widget->dapm, 350 data->widget = snd_soc_dapm_new_control(widget->dapm,
342 &template); 351 &template);
343 if (!data->widget) { 352 if (!data->widget) {
344 kfree(data); 353 ret = -ENOMEM;
345 return -ENOMEM; 354 goto err_name;
346 } 355 }
347 } 356 }
348 break; 357 break;
@@ -353,11 +362,19 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
353 kcontrol->private_data = data; 362 kcontrol->private_data = data;
354 363
355 return 0; 364 return 0;
365
366err_name:
367 kfree(name);
368err_data:
369 kfree(data);
370 return ret;
356} 371}
357 372
358static void dapm_kcontrol_free(struct snd_kcontrol *kctl) 373static void dapm_kcontrol_free(struct snd_kcontrol *kctl)
359{ 374{
360 struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl); 375 struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl);
376 if (data->widget)
377 kfree(data->widget->name);
361 kfree(data->wlist); 378 kfree(data->wlist);
362 kfree(data); 379 kfree(data);
363} 380}