Commit 6627a653 authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: Push the codec runtime storage into the card structure



This is a further stage on the road to refactoring away the ASoC
platform device.

Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 0db4d070
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -418,6 +418,8 @@ struct snd_soc_card {

	struct snd_soc_device *socdev;

	struct snd_soc_codec *codec;

	struct snd_soc_platform *platform;
	struct delayed_work delayed_work;
	struct work_struct deferred_resume_work;
@@ -427,7 +429,6 @@ struct snd_soc_card {
struct snd_soc_device {
	struct device *dev;
	struct snd_soc_card *card;
	struct snd_soc_codec *codec;
	struct snd_soc_codec_device *codec_dev;
	void *codec_data;
};
+10 −10
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ static int ac97_prepare(struct snd_pcm_substream *substream,
	struct snd_pcm_runtime *runtime = substream->runtime;
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_device *socdev = rtd->socdev;
	struct snd_soc_codec *codec = socdev->codec;
	struct snd_soc_codec *codec = socdev->card->codec;

	int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
		  AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE;
@@ -84,10 +84,10 @@ static int ac97_soc_probe(struct platform_device *pdev)

	printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION);

	socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
	if (!socdev->codec)
	socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
	if (!socdev->card->codec)
		return -ENOMEM;
	codec = socdev->codec;
	codec = socdev->card->codec;
	mutex_init(&codec->mutex);

	codec->name = "AC97";
@@ -123,21 +123,21 @@ static int ac97_soc_probe(struct platform_device *pdev)
	snd_soc_free_pcms(socdev);

err:
	kfree(socdev->codec);
	socdev->codec = NULL;
	kfree(socdev->card->codec);
	socdev->card->codec = NULL;
	return ret;
}

static int ac97_soc_remove(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec = socdev->codec;
	struct snd_soc_codec *codec = socdev->card->codec;

	if (!codec)
		return 0;

	snd_soc_free_pcms(socdev);
	kfree(socdev->codec);
	kfree(socdev->card->codec);

	return 0;
}
@@ -147,7 +147,7 @@ static int ac97_soc_suspend(struct platform_device *pdev, pm_message_t msg)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);

	snd_ac97_suspend(socdev->codec->ac97);
	snd_ac97_suspend(socdev->card->codec->ac97);

	return 0;
}
@@ -156,7 +156,7 @@ static int ac97_soc_resume(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);

	snd_ac97_resume(socdev->codec->ac97);
	snd_ac97_resume(socdev->card->codec->ac97);

	return 0;
}
+6 −6
Original line number Diff line number Diff line
@@ -186,10 +186,10 @@ static int ad1980_soc_probe(struct platform_device *pdev)

	printk(KERN_INFO "AD1980 SoC Audio Codec\n");

	socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
	if (socdev->codec == NULL)
	socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
	if (socdev->card->codec == NULL)
		return -ENOMEM;
	codec = socdev->codec;
	codec = socdev->card->codec;
	mutex_init(&codec->mutex);

	codec->reg_cache =
@@ -275,15 +275,15 @@ static int ad1980_soc_probe(struct platform_device *pdev)
	kfree(codec->reg_cache);

cache_err:
	kfree(socdev->codec);
	socdev->codec = NULL;
	kfree(socdev->card->codec);
	socdev->card->codec = NULL;
	return ret;
}

static int ad1980_soc_remove(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec = socdev->codec;
	struct snd_soc_codec *codec = socdev->card->codec;

	if (codec == NULL)
		return 0;
+4 −4
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ static int ad73311_soc_probe(struct platform_device *pdev)
	codec->owner = THIS_MODULE;
	codec->dai = &ad73311_dai;
	codec->num_dai = 1;
	socdev->codec = codec;
	socdev->card->codec = codec;
	INIT_LIST_HEAD(&codec->dapm_widgets);
	INIT_LIST_HEAD(&codec->dapm_paths);

@@ -75,15 +75,15 @@ static int ad73311_soc_probe(struct platform_device *pdev)
register_err:
	snd_soc_free_pcms(socdev);
pcm_err:
	kfree(socdev->codec);
	socdev->codec = NULL;
	kfree(socdev->card->codec);
	socdev->card->codec = NULL;
	return ret;
}

static int ad73311_soc_remove(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec = socdev->codec;
	struct snd_soc_codec *codec = socdev->card->codec;

	if (codec == NULL)
		return 0;
+7 −7
Original line number Diff line number Diff line
@@ -329,7 +329,7 @@ static int ak4535_hw_params(struct snd_pcm_substream *substream,
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_device *socdev = rtd->socdev;
	struct snd_soc_codec *codec = socdev->codec;
	struct snd_soc_codec *codec = socdev->card->codec;
	struct ak4535_priv *ak4535 = codec->private_data;
	u8 mode2 = ak4535_read_reg_cache(codec, AK4535_MODE2) & ~(0x3 << 5);
	int rate = params_rate(params), fs = 256;
@@ -447,7 +447,7 @@ EXPORT_SYMBOL_GPL(ak4535_dai);
static int ak4535_suspend(struct platform_device *pdev, pm_message_t state)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec = socdev->codec;
	struct snd_soc_codec *codec = socdev->card->codec;

	ak4535_set_bias_level(codec, SND_SOC_BIAS_OFF);
	return 0;
@@ -456,7 +456,7 @@ static int ak4535_suspend(struct platform_device *pdev, pm_message_t state)
static int ak4535_resume(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec = socdev->codec;
	struct snd_soc_codec *codec = socdev->card->codec;
	ak4535_sync(codec);
	ak4535_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
	ak4535_set_bias_level(codec, codec->suspend_bias_level);
@@ -469,7 +469,7 @@ static int ak4535_resume(struct platform_device *pdev)
 */
static int ak4535_init(struct snd_soc_device *socdev)
{
	struct snd_soc_codec *codec = socdev->codec;
	struct snd_soc_codec *codec = socdev->card->codec;
	int ret = 0;

	codec->name = "AK4535";
@@ -523,7 +523,7 @@ static int ak4535_i2c_probe(struct i2c_client *i2c,
			    const struct i2c_device_id *id)
{
	struct snd_soc_device *socdev = ak4535_socdev;
	struct snd_soc_codec *codec = socdev->codec;
	struct snd_soc_codec *codec = socdev->card->codec;
	int ret;

	i2c_set_clientdata(i2c, codec);
@@ -622,7 +622,7 @@ static int ak4535_probe(struct platform_device *pdev)
	}

	codec->private_data = ak4535;
	socdev->codec = codec;
	socdev->card->codec = codec;
	mutex_init(&codec->mutex);
	INIT_LIST_HEAD(&codec->dapm_widgets);
	INIT_LIST_HEAD(&codec->dapm_paths);
@@ -649,7 +649,7 @@ static int ak4535_probe(struct platform_device *pdev)
static int ak4535_remove(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec = socdev->codec;
	struct snd_soc_codec *codec = socdev->card->codec;

	if (codec->control_data)
		ak4535_set_bias_level(codec, SND_SOC_BIAS_OFF);
Loading