Commit eb5f6d75 authored by Philipp Zabel's avatar Philipp Zabel Committed by Mark Brown

ASoC: Replace remaining uses of snd_soc_cnew with snd_soc_add_controls.

The drivers are basically duplicating the same code over and over.
As snd_soc_cnew is going to be made static some time after the next
merge window, we might as well convert them now.
Signed-off-by: default avatarPhilipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 6f7cb44b
...@@ -540,7 +540,6 @@ static int cs4270_probe(struct platform_device *pdev) ...@@ -540,7 +540,6 @@ static int cs4270_probe(struct platform_device *pdev)
{ {
struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_device *socdev = platform_get_drvdata(pdev);
struct snd_soc_codec *codec = cs4270_codec; struct snd_soc_codec *codec = cs4270_codec;
unsigned int i;
int ret; int ret;
/* Connect the codec to the socdev. snd_soc_new_pcms() needs this. */ /* Connect the codec to the socdev. snd_soc_new_pcms() needs this. */
...@@ -554,23 +553,11 @@ static int cs4270_probe(struct platform_device *pdev) ...@@ -554,23 +553,11 @@ static int cs4270_probe(struct platform_device *pdev)
} }
/* Add the non-DAPM controls */ /* Add the non-DAPM controls */
for (i = 0; i < ARRAY_SIZE(cs4270_snd_controls); i++) { ret = snd_soc_add_controls(codec, cs4270_snd_controls,
struct snd_kcontrol *kctrl; ARRAY_SIZE(cs4270_snd_controls));
if (ret < 0) {
kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL); dev_err(codec->dev, "failed to add controls\n");
if (!kctrl) { goto error_free_pcms;
dev_err(codec->dev, "error creating control '%s'\n",
cs4270_snd_controls[i].name);
ret = -ENOMEM;
goto error_free_pcms;
}
ret = snd_ctl_add(codec->card, kctrl);
if (ret < 0) {
dev_err(codec->dev, "error adding control '%s'\n",
cs4270_snd_controls[i].name);
goto error_free_pcms;
}
} }
/* And finally, register the socdev */ /* And finally, register the socdev */
......
...@@ -324,9 +324,8 @@ static int aic26_probe(struct platform_device *pdev) ...@@ -324,9 +324,8 @@ static int aic26_probe(struct platform_device *pdev)
{ {
struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_device *socdev = platform_get_drvdata(pdev);
struct snd_soc_codec *codec; struct snd_soc_codec *codec;
struct snd_kcontrol *kcontrol;
struct aic26 *aic26; struct aic26 *aic26;
int i, ret, err; int ret, err;
dev_info(&pdev->dev, "Probing AIC26 SoC CODEC driver\n"); dev_info(&pdev->dev, "Probing AIC26 SoC CODEC driver\n");
dev_dbg(&pdev->dev, "socdev=%p\n", socdev); dev_dbg(&pdev->dev, "socdev=%p\n", socdev);
...@@ -353,11 +352,9 @@ static int aic26_probe(struct platform_device *pdev) ...@@ -353,11 +352,9 @@ static int aic26_probe(struct platform_device *pdev)
/* register controls */ /* register controls */
dev_dbg(&pdev->dev, "Registering controls\n"); dev_dbg(&pdev->dev, "Registering controls\n");
for (i = 0; i < ARRAY_SIZE(aic26_snd_controls); i++) { err = snd_soc_add_controls(codec, aic26_snd_controls,
kcontrol = snd_soc_cnew(&aic26_snd_controls[i], codec, NULL); ARRAY_SIZE(aic26_snd_controls));
err = snd_ctl_add(codec->card, kcontrol); WARN_ON(err < 0);
WARN_ON(err < 0);
}
/* CODEC is setup, we can register the card now */ /* CODEC is setup, we can register the card now */
dev_dbg(&pdev->dev, "Registering card\n"); dev_dbg(&pdev->dev, "Registering card\n");
......
...@@ -351,16 +351,8 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, ...@@ -351,16 +351,8 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME,
/* add non dapm controls */ /* add non dapm controls */
static int wm8400_add_controls(struct snd_soc_codec *codec) static int wm8400_add_controls(struct snd_soc_codec *codec)
{ {
int err, i; return snd_soc_add_controls(codec, wm8400_snd_controls,
ARRAY_SIZE(wm8400_snd_controls));
for (i = 0; i < ARRAY_SIZE(wm8400_snd_controls); i++) {
err = snd_ctl_add(codec->card,
snd_soc_cnew(&wm8400_snd_controls[i],codec,
NULL));
if (err < 0)
return err;
}
return 0;
} }
/* /*
......
...@@ -248,7 +248,7 @@ static const struct snd_kcontrol_new aic33_n810_controls[] = { ...@@ -248,7 +248,7 @@ static const struct snd_kcontrol_new aic33_n810_controls[] = {
static int n810_aic33_init(struct snd_soc_codec *codec) static int n810_aic33_init(struct snd_soc_codec *codec)
{ {
int i, err; int err;
/* Not connected */ /* Not connected */
snd_soc_dapm_nc_pin(codec, "MONO_LOUT"); snd_soc_dapm_nc_pin(codec, "MONO_LOUT");
...@@ -256,12 +256,10 @@ static int n810_aic33_init(struct snd_soc_codec *codec) ...@@ -256,12 +256,10 @@ static int n810_aic33_init(struct snd_soc_codec *codec)
snd_soc_dapm_nc_pin(codec, "HPRCOM"); snd_soc_dapm_nc_pin(codec, "HPRCOM");
/* Add N810 specific controls */ /* Add N810 specific controls */
for (i = 0; i < ARRAY_SIZE(aic33_n810_controls); i++) { err = snd_soc_add_controls(codec, aic33_n810_controls,
err = snd_ctl_add(codec->card, ARRAY_SIZE(aic33_n810_controls));
snd_soc_cnew(&aic33_n810_controls[i], codec, NULL)); if (err < 0)
if (err < 0) return err;
return err;
}
/* Add N810 specific widgets */ /* Add N810 specific widgets */
snd_soc_dapm_new_controls(codec, aic33_dapm_widgets, snd_soc_dapm_new_controls(codec, aic33_dapm_widgets,
......
...@@ -276,18 +276,16 @@ static const struct snd_kcontrol_new wm8731_corgi_controls[] = { ...@@ -276,18 +276,16 @@ static const struct snd_kcontrol_new wm8731_corgi_controls[] = {
*/ */
static int corgi_wm8731_init(struct snd_soc_codec *codec) static int corgi_wm8731_init(struct snd_soc_codec *codec)
{ {
int i, err; int err;
snd_soc_dapm_nc_pin(codec, "LLINEIN"); snd_soc_dapm_nc_pin(codec, "LLINEIN");
snd_soc_dapm_nc_pin(codec, "RLINEIN"); snd_soc_dapm_nc_pin(codec, "RLINEIN");
/* Add corgi specific controls */ /* Add corgi specific controls */
for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) { err = snd_soc_add_controls(codec, wm8731_corgi_controls,
err = snd_ctl_add(codec->card, ARRAY_SIZE(wm8731_corgi_controls));
snd_soc_cnew(&wm8731_corgi_controls[i], codec, NULL)); if (err < 0)
if (err < 0) return err;
return err;
}
/* Add corgi specific widgets */ /* Add corgi specific widgets */
snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets, snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets,
......
...@@ -146,19 +146,16 @@ static const struct snd_kcontrol_new palm27x_controls[] = { ...@@ -146,19 +146,16 @@ static const struct snd_kcontrol_new palm27x_controls[] = {
static int palm27x_ac97_init(struct snd_soc_codec *codec) static int palm27x_ac97_init(struct snd_soc_codec *codec)
{ {
int i, err; int err;
snd_soc_dapm_nc_pin(codec, "OUT3"); snd_soc_dapm_nc_pin(codec, "OUT3");
snd_soc_dapm_nc_pin(codec, "MONOOUT"); snd_soc_dapm_nc_pin(codec, "MONOOUT");
/* add palm27x specific controls */ /* add palm27x specific controls */
for (i = 0; i < ARRAY_SIZE(palm27x_controls); i++) { err = snd_soc_add_controls(codec, palm27x_controls,
err = snd_ctl_add(codec->card, ARRAY_SIZE(palm27x_controls));
snd_soc_cnew(&palm27x_controls[i], if (err < 0)
codec, NULL)); return err;
if (err < 0)
return err;
}
/* add palm27x specific widgets */ /* add palm27x specific widgets */
snd_soc_dapm_new_controls(codec, palm27x_dapm_widgets, snd_soc_dapm_new_controls(codec, palm27x_dapm_widgets,
......
...@@ -241,19 +241,17 @@ static const struct snd_kcontrol_new wm8731_poodle_controls[] = { ...@@ -241,19 +241,17 @@ static const struct snd_kcontrol_new wm8731_poodle_controls[] = {
*/ */
static int poodle_wm8731_init(struct snd_soc_codec *codec) static int poodle_wm8731_init(struct snd_soc_codec *codec)
{ {
int i, err; int err;
snd_soc_dapm_nc_pin(codec, "LLINEIN"); snd_soc_dapm_nc_pin(codec, "LLINEIN");
snd_soc_dapm_nc_pin(codec, "RLINEIN"); snd_soc_dapm_nc_pin(codec, "RLINEIN");
snd_soc_dapm_enable_pin(codec, "MICIN"); snd_soc_dapm_enable_pin(codec, "MICIN");
/* Add poodle specific controls */ /* Add poodle specific controls */
for (i = 0; i < ARRAY_SIZE(wm8731_poodle_controls); i++) { err = snd_soc_add_controls(codec, wm8731_poodle_controls,
err = snd_ctl_add(codec->card, ARRAY_SIZE(wm8731_poodle_controls));
snd_soc_cnew(&wm8731_poodle_controls[i], codec, NULL)); if (err < 0)
if (err < 0) return err;
return err;
}
/* Add poodle specific widgets */ /* Add poodle specific widgets */
snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets, snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets,
......
...@@ -278,7 +278,7 @@ static const struct snd_kcontrol_new wm8750_spitz_controls[] = { ...@@ -278,7 +278,7 @@ static const struct snd_kcontrol_new wm8750_spitz_controls[] = {
*/ */
static int spitz_wm8750_init(struct snd_soc_codec *codec) static int spitz_wm8750_init(struct snd_soc_codec *codec)
{ {
int i, err; int err;
/* NC codec pins */ /* NC codec pins */
snd_soc_dapm_nc_pin(codec, "RINPUT1"); snd_soc_dapm_nc_pin(codec, "RINPUT1");
...@@ -290,12 +290,10 @@ static int spitz_wm8750_init(struct snd_soc_codec *codec) ...@@ -290,12 +290,10 @@ static int spitz_wm8750_init(struct snd_soc_codec *codec)
snd_soc_dapm_nc_pin(codec, "MONO1"); snd_soc_dapm_nc_pin(codec, "MONO1");
/* Add spitz specific controls */ /* Add spitz specific controls */
for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) { err = snd_soc_add_controls(codec, wm8750_spitz_controls,
err = snd_ctl_add(codec->card, ARRAY_SIZE(wm8750_spitz_controls));
snd_soc_cnew(&wm8750_spitz_controls[i], codec, NULL)); if (err < 0)
if (err < 0) return err;
return err;
}
/* Add spitz specific widgets */ /* Add spitz specific widgets */
snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets, snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets,
......
...@@ -188,18 +188,16 @@ static const struct snd_kcontrol_new tosa_controls[] = { ...@@ -188,18 +188,16 @@ static const struct snd_kcontrol_new tosa_controls[] = {
static int tosa_ac97_init(struct snd_soc_codec *codec) static int tosa_ac97_init(struct snd_soc_codec *codec)
{ {
int i, err; int err;
snd_soc_dapm_nc_pin(codec, "OUT3"); snd_soc_dapm_nc_pin(codec, "OUT3");
snd_soc_dapm_nc_pin(codec, "MONOOUT"); snd_soc_dapm_nc_pin(codec, "MONOOUT");
/* add tosa specific controls */ /* add tosa specific controls */
for (i = 0; i < ARRAY_SIZE(tosa_controls); i++) { err = snd_soc_add_controls(codec, tosa_controls,
err = snd_ctl_add(codec->card, ARRAY_SIZE(tosa_controls));
snd_soc_cnew(&tosa_controls[i],codec, NULL)); if (err < 0)
if (err < 0) return err;
return err;
}
/* add tosa specific widgets */ /* add tosa specific widgets */
snd_soc_dapm_new_controls(codec, tosa_dapm_widgets, snd_soc_dapm_new_controls(codec, tosa_dapm_widgets,
......
...@@ -498,7 +498,7 @@ static const struct snd_kcontrol_new wm8753_neo1973_controls[] = { ...@@ -498,7 +498,7 @@ static const struct snd_kcontrol_new wm8753_neo1973_controls[] = {
*/ */
static int neo1973_wm8753_init(struct snd_soc_codec *codec) static int neo1973_wm8753_init(struct snd_soc_codec *codec)
{ {
int i, err; int err;
pr_debug("Entered %s\n", __func__); pr_debug("Entered %s\n", __func__);
...@@ -518,13 +518,10 @@ static int neo1973_wm8753_init(struct snd_soc_codec *codec) ...@@ -518,13 +518,10 @@ static int neo1973_wm8753_init(struct snd_soc_codec *codec)
set_scenario_endpoints(codec, NEO_AUDIO_OFF); set_scenario_endpoints(codec, NEO_AUDIO_OFF);
/* add neo1973 specific controls */ /* add neo1973 specific controls */
for (i = 0; i < ARRAY_SIZE(wm8753_neo1973_controls); i++) { err = snd_soc_add_controls(codec, wm8753_neo1973_controls,
err = snd_ctl_add(codec->card, ARRAY_SIZE(8753_neo1973_controls));
snd_soc_cnew(&wm8753_neo1973_controls[i], if (err < 0)
codec, NULL)); return err;
if (err < 0)
return err;
}
/* set up neo1973 specific audio routes */ /* set up neo1973 specific audio routes */
err = snd_soc_dapm_add_routes(codec, dapm_routes, err = snd_soc_dapm_add_routes(codec, dapm_routes,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment