Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 182783
b: refs/heads/master
c: cce2e9d
h: refs/heads/master
i:
  182781: 23fd62b
  182779: 5dff2be
  182775: a7c97a6
  182767: 8a2458f
  182751: 9a30f90
  182719: d2cc226
  182655: f2a604e
  182527: b993e02
  182271: f857544
v: v3
  • Loading branch information
Mark Brown committed Dec 16, 2009
1 parent 761e0c1 commit 67f1d11
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d207c68dd92455a3d618c37b5a9f0dc598723fd6
refs/heads/master: cce2e9db718d823f33ac846c019763cdc84e8658
66 changes: 49 additions & 17 deletions trunk/sound/soc/codecs/wm8727.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,16 @@ struct snd_soc_dai wm8727_dai = {
};
EXPORT_SYMBOL_GPL(wm8727_dai);

static struct snd_soc_codec *wm8727_codec;

static int wm8727_soc_probe(struct platform_device *pdev)
{
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
struct snd_soc_codec *codec;
int ret = 0;

codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
if (codec == NULL)
return -ENOMEM;
mutex_init(&codec->mutex);
codec->name = "WM8727";
codec->owner = THIS_MODULE;
codec->dai = &wm8727_dai;
codec->num_dai = 1;
socdev->card->codec = codec;
INIT_LIST_HEAD(&codec->dapm_widgets);
INIT_LIST_HEAD(&codec->dapm_paths);
BUG_ON(!wm8727_codec);

socdev->card->codec = wm8727_codec;

/* register pcms */
ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
Expand All @@ -80,12 +73,9 @@ static int wm8727_soc_probe(struct platform_device *pdev)
static int wm8727_soc_remove(struct platform_device *pdev)
{
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
struct snd_soc_codec *codec = socdev->card->codec;

if (codec == NULL)
return 0;
snd_soc_free_pcms(socdev);
kfree(codec);

return 0;
}

Expand All @@ -98,13 +88,55 @@ EXPORT_SYMBOL_GPL(soc_codec_dev_wm8727);

static __devinit int wm8727_platform_probe(struct platform_device *pdev)
{
struct snd_soc_codec *codec;
int ret;

if (wm8727_codec) {
dev_err(&pdev->dev, "Another WM8727 is registered\n");
return -EBUSY;
}

codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
if (codec == NULL)
return -ENOMEM;
wm8727_codec = codec;

platform_set_drvdata(pdev, codec);

mutex_init(&codec->mutex);
codec->dev = &pdev->dev;
codec->name = "WM8727";
codec->owner = THIS_MODULE;
codec->dai = &wm8727_dai;
codec->num_dai = 1;
INIT_LIST_HEAD(&codec->dapm_widgets);
INIT_LIST_HEAD(&codec->dapm_paths);

wm8727_dai.dev = &pdev->dev;
return snd_soc_register_dai(&wm8727_dai);

ret = snd_soc_register_codec(codec);
if (ret != 0) {
dev_err(&pdev->dev, "Failed to register CODEC: %d\n", ret);
goto err;
}

ret = snd_soc_register_dai(&wm8727_dai);
if (ret != 0) {
dev_err(&pdev->dev, "Failed to register DAI: %d\n", ret);
goto err_codec;
}

err_codec:
snd_soc_unregister_codec(codec);
err:
kfree(codec);
return ret;
}

static int __devexit wm8727_platform_remove(struct platform_device *pdev)
{
snd_soc_unregister_dai(&wm8727_dai);
snd_soc_unregister_codec(platform_get_drvdata(pdev));
return 0;
}

Expand Down

0 comments on commit 67f1d11

Please sign in to comment.