Skip to content

Commit

Permalink
ASoC: Factor out snd_soc_init_card()
Browse files Browse the repository at this point in the history
snd_soc_init_card() is always called as the last part of the CODEC probe
function so we can factor it out into the core card setup rather than
have each CODEC replicate the code to do the initialiastation. This will
be required to support multiple CODECs per card.

Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
broonie committed Nov 3, 2009
1 parent 2624d5f commit fe3e78e
Show file tree
Hide file tree
Showing 49 changed files with 69 additions and 450 deletions.
1 change: 0 additions & 1 deletion include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
/* pcm <-> DAI connect */
void snd_soc_free_pcms(struct snd_soc_device *socdev);
int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
int snd_soc_init_card(struct snd_soc_device *socdev);

/* set runtime hw params */
int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
Expand Down
3 changes: 0 additions & 3 deletions sound/soc/codecs/ac97.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ static int ac97_soc_probe(struct platform_device *pdev)
if (ret < 0)
goto bus_err;

ret = snd_soc_init_card(socdev);
if (ret < 0)
goto bus_err;
return 0;

bus_err:
Expand Down
6 changes: 0 additions & 6 deletions sound/soc/codecs/ad1836.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,6 @@ static int ad1836_probe(struct platform_device *pdev)
snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths));
snd_soc_dapm_new_widgets(codec);

ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(codec->dev, "failed to register card: %d\n", ret);
goto card_err;
}

return ret;

card_err:
Expand Down
6 changes: 0 additions & 6 deletions sound/soc/codecs/ad1938.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,6 @@ static int ad1938_probe(struct platform_device *pdev)

ad1938_set_bias_level(codec, SND_SOC_BIAS_STANDBY);

ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(codec->dev, "failed to register card: %d\n", ret);
goto card_err;
}

return ret;

card_err:
Expand Down
5 changes: 0 additions & 5 deletions sound/soc/codecs/ad1980.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,6 @@ static int ad1980_soc_probe(struct platform_device *pdev)

snd_soc_add_controls(codec, ad1980_snd_ac97_controls,
ARRAY_SIZE(ad1980_snd_ac97_controls));
ret = snd_soc_init_card(socdev);
if (ret < 0) {
printk(KERN_ERR "ad1980: failed to register card\n");
goto reset_err;
}

return 0;

Expand Down
8 changes: 0 additions & 8 deletions sound/soc/codecs/ad73311.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,8 @@ static int ad73311_soc_probe(struct platform_device *pdev)
goto pcm_err;
}

ret = snd_soc_init_card(socdev);
if (ret < 0) {
printk(KERN_ERR "ad73311: failed to register card\n");
goto register_err;
}

return ret;

register_err:
snd_soc_free_pcms(socdev);
pcm_err:
kfree(socdev->card->codec);
socdev->card->codec = NULL;
Expand Down
8 changes: 0 additions & 8 deletions sound/soc/codecs/ak4104.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,6 @@ static int ak4104_probe(struct platform_device *pdev)
return ret;
}

/* Register the socdev */
ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(codec->dev, "failed to register card\n");
snd_soc_free_pcms(socdev);
return ret;
}

return 0;
}

Expand Down
8 changes: 0 additions & 8 deletions sound/soc/codecs/ak4535.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,17 +485,9 @@ static int ak4535_init(struct snd_soc_device *socdev)
snd_soc_add_controls(codec, ak4535_snd_controls,
ARRAY_SIZE(ak4535_snd_controls));
ak4535_add_widgets(codec);
ret = snd_soc_init_card(socdev);
if (ret < 0) {
printk(KERN_ERR "ak4535: failed to register card\n");
goto card_err;
}

return ret;

card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);
pcm_err:
kfree(codec->reg_cache);

Expand Down
9 changes: 0 additions & 9 deletions sound/soc/codecs/ak4642.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,18 +442,9 @@ static int ak4642_probe(struct platform_device *pdev)
goto pcm_err;
}

ret = snd_soc_init_card(socdev);
if (ret < 0) {
printk(KERN_ERR "ak4642: failed to register card\n");
goto card_err;
}

dev_info(&pdev->dev, "AK4642 Audio Codec %s", AK4642_VERSION);
return ret;

card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);
pcm_err:
return ret;

Expand Down
9 changes: 0 additions & 9 deletions sound/soc/codecs/ak4671.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,19 +662,10 @@ static int ak4671_probe(struct platform_device *pdev)
ARRAY_SIZE(ak4671_snd_controls));
ak4671_add_widgets(codec);

ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(codec->dev, "failed to register card: %d\n", ret);
goto card_err;
}

ak4671_set_bias_level(codec, SND_SOC_BIAS_STANDBY);

return ret;

card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);
pcm_err:
return ret;
}
Expand Down
7 changes: 0 additions & 7 deletions sound/soc/codecs/cs4270.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,6 @@ static int cs4270_probe(struct platform_device *pdev)
goto error_free_pcms;
}

/* And finally, register the socdev */
ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(codec->dev, "failed to register card\n");
goto error_free_pcms;
}

return 0;

error_free_pcms:
Expand Down
6 changes: 0 additions & 6 deletions sound/soc/codecs/cx20442.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,6 @@ static int cx20442_codec_probe(struct platform_device *pdev)

cx20442_add_widgets(codec);

ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(&pdev->dev, "failed to register card\n");
goto card_err;
}

return ret;

card_err:
Expand Down
9 changes: 0 additions & 9 deletions sound/soc/codecs/pcm3008.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ static int pcm3008_soc_probe(struct platform_device *pdev)
goto pcm_err;
}

/* Register Card. */
ret = snd_soc_init_card(socdev);
if (ret < 0) {
printk(KERN_ERR "pcm3008: failed to register card\n");
goto card_err;
}

/* DEM1 DEM0 DE-EMPHASIS_MODE
* Low Low De-emphasis 44.1 kHz ON
* Low High De-emphasis OFF
Expand Down Expand Up @@ -136,8 +129,6 @@ static int pcm3008_soc_probe(struct platform_device *pdev)

gpio_err:
pcm3008_gpio_free(setup);
card_err:
snd_soc_free_pcms(socdev);
pcm_err:
kfree(socdev->card->codec);

Expand Down
8 changes: 0 additions & 8 deletions sound/soc/codecs/ssm2602.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,17 +613,9 @@ static int ssm2602_init(struct snd_soc_device *socdev)
snd_soc_add_controls(codec, ssm2602_snd_controls,
ARRAY_SIZE(ssm2602_snd_controls));
ssm2602_add_widgets(codec);
ret = snd_soc_init_card(socdev);
if (ret < 0) {
pr_err("ssm2602: failed to register card\n");
goto card_err;
}

return ret;

card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);
pcm_err:
kfree(codec->reg_cache);
return ret;
Expand Down
3 changes: 0 additions & 3 deletions sound/soc/codecs/stac9766.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,6 @@ static int stac9766_codec_probe(struct platform_device *pdev)
snd_soc_add_controls(codec, stac9766_snd_ac97_controls,
ARRAY_SIZE(stac9766_snd_ac97_controls));

ret = snd_soc_init_card(socdev);
if (ret < 0)
goto reset_err;
return 0;

reset_err:
Expand Down
8 changes: 0 additions & 8 deletions sound/soc/codecs/tlv320aic23.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,17 +707,9 @@ static int tlv320aic23_init(struct snd_soc_device *socdev)
snd_soc_add_controls(codec, tlv320aic23_snd_controls,
ARRAY_SIZE(tlv320aic23_snd_controls));
tlv320aic23_add_widgets(codec);
ret = snd_soc_init_card(socdev);
if (ret < 0) {
printk(KERN_ERR "tlv320aic23: failed to register card\n");
goto card_err;
}

return ret;

card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);
pcm_err:
kfree(codec->reg_cache);
return ret;
Expand Down
11 changes: 0 additions & 11 deletions sound/soc/codecs/tlv320aic26.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,18 +356,7 @@ static int aic26_probe(struct platform_device *pdev)
ARRAY_SIZE(aic26_snd_controls));
WARN_ON(err < 0);

/* CODEC is setup, we can register the card now */
dev_dbg(&pdev->dev, "Registering card\n");
ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(&pdev->dev, "aic26: failed to register card\n");
goto card_err;
}
return 0;

card_err:
snd_soc_free_pcms(socdev);
return ret;
}

static int aic26_remove(struct platform_device *pdev)
Expand Down
10 changes: 0 additions & 10 deletions sound/soc/codecs/tlv320aic3x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1405,18 +1405,8 @@ static int aic3x_probe(struct platform_device *pdev)

aic3x_add_widgets(codec);

ret = snd_soc_init_card(socdev);
if (ret < 0) {
printk(KERN_ERR "aic3x: failed to register card\n");
goto card_err;
}

return ret;

card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);

pcm_err:
kfree(codec->reg_cache);
return ret;
Expand Down
10 changes: 1 addition & 9 deletions sound/soc/codecs/tlv320dac33.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,16 +960,8 @@ static int dac33_soc_probe(struct platform_device *pdev)
/* power on device */
dac33_set_bias_level(codec, SND_SOC_BIAS_STANDBY);

ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(codec->dev, "failed to register card\n");
goto card_err;
}

return 0;
card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);

pcm_err:
dac33_hard_power(codec, 0);
return ret;
Expand Down
12 changes: 0 additions & 12 deletions sound/soc/codecs/twl4030.c
Original file line number Diff line number Diff line change
Expand Up @@ -2155,19 +2155,7 @@ static int twl4030_soc_probe(struct platform_device *pdev)
ARRAY_SIZE(twl4030_snd_controls));
twl4030_add_widgets(codec);

ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(&pdev->dev, "failed to register card\n");
goto card_err;
}

return 0;

card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);

return ret;
}

static int twl4030_soc_remove(struct platform_device *pdev)
Expand Down
9 changes: 0 additions & 9 deletions sound/soc/codecs/uda134x.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,17 +562,8 @@ static int uda134x_soc_probe(struct platform_device *pdev)
goto pcm_err;
}

ret = snd_soc_init_card(socdev);
if (ret < 0) {
printk(KERN_ERR "UDA134X: failed to register card\n");
goto card_err;
}

return 0;

card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);
pcm_err:
kfree(codec->reg_cache);
reg_err:
Expand Down
8 changes: 0 additions & 8 deletions sound/soc/codecs/uda1380.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,17 +713,9 @@ static int uda1380_probe(struct platform_device *pdev)
snd_soc_add_controls(codec, uda1380_snd_controls,
ARRAY_SIZE(uda1380_snd_controls));
uda1380_add_widgets(codec);
ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(codec->dev, "failed to register card: %d\n", ret);
goto card_err;
}

return ret;

card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);
pcm_err:
return ret;
}
Expand Down
11 changes: 0 additions & 11 deletions sound/soc/codecs/wm8350.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,18 +1501,7 @@ static int wm8350_probe(struct platform_device *pdev)

wm8350_set_bias_level(codec, SND_SOC_BIAS_STANDBY);

ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(&pdev->dev, "failed to register card\n");
goto card_err;
}

return 0;

card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);
return ret;
}

static int wm8350_remove(struct platform_device *pdev)
Expand Down
6 changes: 0 additions & 6 deletions sound/soc/codecs/wm8400.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,12 +1400,6 @@ static int wm8400_probe(struct platform_device *pdev)
wm8400_add_controls(codec);
wm8400_add_widgets(codec);

ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(&pdev->dev, "failed to register card\n");
goto card_err;
}

return ret;

card_err:
Expand Down
Loading

0 comments on commit fe3e78e

Please sign in to comment.