Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+5 −18
Original line number Diff line number Diff line
@@ -540,7 +540,6 @@ static int cs4270_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec = cs4270_codec;
	unsigned int i;
	int ret;

	/* Connect the codec to the socdev.  snd_soc_new_pcms() needs this. */
@@ -554,24 +553,12 @@ static int cs4270_probe(struct platform_device *pdev)
	}

	/* Add the non-DAPM controls */
	for (i = 0; i < ARRAY_SIZE(cs4270_snd_controls); i++) {
		struct snd_kcontrol *kctrl;

		kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL);
		if (!kctrl) {
			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);
	ret = snd_soc_add_controls(codec, cs4270_snd_controls,
				ARRAY_SIZE(cs4270_snd_controls));
	if (ret < 0) {
			dev_err(codec->dev, "error adding control '%s'\n",
			       cs4270_snd_controls[i].name);
		dev_err(codec->dev, "failed to add controls\n");
		goto error_free_pcms;
	}
	}

	/* And finally, register the socdev */
	ret = snd_soc_init_card(socdev);
+4 −7
Original line number Diff line number Diff line
@@ -324,9 +324,8 @@ static int aic26_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec;
	struct snd_kcontrol *kcontrol;
	struct aic26 *aic26;
	int i, ret, err;
	int ret, err;

	dev_info(&pdev->dev, "Probing AIC26 SoC CODEC driver\n");
	dev_dbg(&pdev->dev, "socdev=%p\n", socdev);
@@ -353,11 +352,9 @@ static int aic26_probe(struct platform_device *pdev)

	/* register controls */
	dev_dbg(&pdev->dev, "Registering controls\n");
	for (i = 0; i < ARRAY_SIZE(aic26_snd_controls); i++) {
		kcontrol = snd_soc_cnew(&aic26_snd_controls[i], codec, NULL);
		err = snd_ctl_add(codec->card, kcontrol);
	err = snd_soc_add_controls(codec, aic26_snd_controls,
			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");
+2 −10
Original line number Diff line number Diff line
@@ -351,16 +351,8 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME,
/* add non dapm controls */
static int wm8400_add_controls(struct snd_soc_codec *codec)
{
	int err, i;

	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;
	return snd_soc_add_controls(codec, wm8400_snd_controls,
				ARRAY_SIZE(wm8400_snd_controls));
}

/*
+5 −7
Original line number Diff line number Diff line
@@ -248,7 +248,7 @@ static const struct snd_kcontrol_new aic33_n810_controls[] = {

static int n810_aic33_init(struct snd_soc_codec *codec)
{
	int i, err;
	int err;

	/* Not connected */
	snd_soc_dapm_nc_pin(codec, "MONO_LOUT");
@@ -256,12 +256,10 @@ static int n810_aic33_init(struct snd_soc_codec *codec)
	snd_soc_dapm_nc_pin(codec, "HPRCOM");

	/* Add N810 specific controls */
	for (i = 0; i < ARRAY_SIZE(aic33_n810_controls); i++) {
		err = snd_ctl_add(codec->card,
			snd_soc_cnew(&aic33_n810_controls[i], codec, NULL));
	err = snd_soc_add_controls(codec, aic33_n810_controls,
				ARRAY_SIZE(aic33_n810_controls));
	if (err < 0)
		return err;
	}

	/* Add N810 specific widgets */
	snd_soc_dapm_new_controls(codec, aic33_dapm_widgets,
+5 −7
Original line number Diff line number Diff line
@@ -276,18 +276,16 @@ static const struct snd_kcontrol_new wm8731_corgi_controls[] = {
 */
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, "RLINEIN");

	/* Add corgi specific controls */
	for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) {
		err = snd_ctl_add(codec->card,
			snd_soc_cnew(&wm8731_corgi_controls[i], codec, NULL));
	err = snd_soc_add_controls(codec, wm8731_corgi_controls,
				ARRAY_SIZE(wm8731_corgi_controls));
	if (err < 0)
		return err;
	}

	/* Add corgi specific widgets */
	snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets,
Loading