Skip to content

Commit

Permalink
ASoC: Push the codec runtime storage into the card structure
Browse files Browse the repository at this point in the history
This is a further stage on the road to refactoring away the ASoC
platform device.

Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
broonie committed Jan 27, 2009
1 parent 0db4d07 commit 6627a65
Show file tree
Hide file tree
Showing 31 changed files with 220 additions and 219 deletions.
3 changes: 2 additions & 1 deletion include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};
Expand Down
20 changes: 10 additions & 10 deletions sound/soc/codecs/ac97.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
12 changes: 6 additions & 6 deletions sound/soc/codecs/ad1980.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions sound/soc/codecs/ad73311.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions sound/soc/codecs/ak4535.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions sound/soc/codecs/cs4270.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ static int cs4270_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 cs4270_private *cs4270 = codec->private_data;
int ret;
unsigned int i;
Expand Down Expand Up @@ -575,7 +575,7 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
return -ENOMEM;
}
codec = &cs4270->codec;
socdev->codec = codec;
socdev->card->codec = codec;

mutex_init(&codec->mutex);
INIT_LIST_HEAD(&codec->dapm_widgets);
Expand Down Expand Up @@ -653,7 +653,7 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
static int cs4270_i2c_remove(struct i2c_client *i2c_client)
{
struct snd_soc_device *socdev = i2c_get_clientdata(i2c_client);
struct snd_soc_codec *codec = socdev->codec;
struct snd_soc_codec *codec = socdev->card->codec;
struct cs4270_private *cs4270 = codec->private_data;

snd_soc_free_pcms(socdev);
Expand Down
12 changes: 6 additions & 6 deletions sound/soc/codecs/pcm3008.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ static int pcm3008_soc_probe(struct platform_device *pdev)

printk(KERN_INFO "PCM3008 SoC Audio Codec %s\n", PCM3008_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 = "PCM3008";
Expand Down Expand Up @@ -139,23 +139,23 @@ static int pcm3008_soc_probe(struct platform_device *pdev)
card_err:
snd_soc_free_pcms(socdev);
pcm_err:
kfree(socdev->codec);
kfree(socdev->card->codec);

return ret;
}

static int pcm3008_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;
struct pcm3008_setup_data *setup = socdev->codec_data;

if (!codec)
return 0;

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

return 0;
}
Expand Down
20 changes: 10 additions & 10 deletions sound/soc/codecs/ssm2602.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ static int ssm2602_hw_params(struct snd_pcm_substream *substream,
u16 srate;
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 ssm2602_priv *ssm2602 = codec->private_data;
struct i2c_client *i2c = codec->control_data;
u16 iface = ssm2602_read_reg_cache(codec, SSM2602_IFACE) & 0xfff3;
Expand Down Expand Up @@ -321,7 +321,7 @@ static int ssm2602_startup(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 ssm2602_priv *ssm2602 = codec->private_data;
struct i2c_client *i2c = codec->control_data;
struct snd_pcm_runtime *master_runtime;
Expand Down Expand Up @@ -358,7 +358,7 @@ static int ssm2602_pcm_prepare(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;
/* set active */
ssm2602_write(codec, SSM2602_ACTIVE, ACTIVE_ACTIVATE_CODEC);

Expand All @@ -370,7 +370,7 @@ static void ssm2602_shutdown(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 ssm2602_priv *ssm2602 = codec->private_data;
/* deactivate */
if (!codec->active)
Expand Down Expand Up @@ -535,7 +535,7 @@ EXPORT_SYMBOL_GPL(ssm2602_dai);
static int ssm2602_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;

ssm2602_set_bias_level(codec, SND_SOC_BIAS_OFF);
return 0;
Expand All @@ -544,7 +544,7 @@ static int ssm2602_suspend(struct platform_device *pdev, pm_message_t state)
static int ssm2602_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;
int i;
u8 data[2];
u16 *cache = codec->reg_cache;
Expand All @@ -566,7 +566,7 @@ static int ssm2602_resume(struct platform_device *pdev)
*/
static int ssm2602_init(struct snd_soc_device *socdev)
{
struct snd_soc_codec *codec = socdev->codec;
struct snd_soc_codec *codec = socdev->card->codec;
int reg, ret = 0;

codec->name = "SSM2602";
Expand Down Expand Up @@ -639,7 +639,7 @@ static int ssm2602_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct snd_soc_device *socdev = ssm2602_socdev;
struct snd_soc_codec *codec = socdev->codec;
struct snd_soc_codec *codec = socdev->card->codec;
int ret;

i2c_set_clientdata(i2c, codec);
Expand Down Expand Up @@ -733,7 +733,7 @@ static int ssm2602_probe(struct platform_device *pdev)
}

codec->private_data = ssm2602;
socdev->codec = codec;
socdev->card->codec = codec;
mutex_init(&codec->mutex);
INIT_LIST_HEAD(&codec->dapm_widgets);
INIT_LIST_HEAD(&codec->dapm_paths);
Expand All @@ -754,7 +754,7 @@ static int ssm2602_probe(struct platform_device *pdev)
static int ssm2602_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)
ssm2602_set_bias_level(codec, SND_SOC_BIAS_OFF);
Expand Down
Loading

0 comments on commit 6627a65

Please sign in to comment.