diff options
Diffstat (limited to 'sound/soc/codecs/ad73311.c')
-rw-r--r-- | sound/soc/codecs/ad73311.c | 66 |
1 files changed, 19 insertions, 47 deletions
diff --git a/sound/soc/codecs/ad73311.c b/sound/soc/codecs/ad73311.c index 475807bea2c2..c53955fe17b6 100644 --- a/sound/soc/codecs/ad73311.c +++ b/sound/soc/codecs/ad73311.c | |||
@@ -23,8 +23,8 @@ | |||
23 | 23 | ||
24 | #include "ad73311.h" | 24 | #include "ad73311.h" |
25 | 25 | ||
26 | struct snd_soc_dai ad73311_dai = { | 26 | static struct snd_soc_dai_driver ad73311_dai = { |
27 | .name = "AD73311", | 27 | .name = "ad73311-hifi", |
28 | .playback = { | 28 | .playback = { |
29 | .stream_name = "Playback", | 29 | .stream_name = "Playback", |
30 | .channels_min = 1, | 30 | .channels_min = 1, |
@@ -38,68 +38,40 @@ struct snd_soc_dai ad73311_dai = { | |||
38 | .rates = SNDRV_PCM_RATE_8000, | 38 | .rates = SNDRV_PCM_RATE_8000, |
39 | .formats = SNDRV_PCM_FMTBIT_S16_LE, }, | 39 | .formats = SNDRV_PCM_FMTBIT_S16_LE, }, |
40 | }; | 40 | }; |
41 | EXPORT_SYMBOL_GPL(ad73311_dai); | ||
42 | 41 | ||
43 | static int ad73311_soc_probe(struct platform_device *pdev) | 42 | static struct snd_soc_codec_driver soc_codec_dev_ad73311; |
44 | { | ||
45 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
46 | struct snd_soc_codec *codec; | ||
47 | int ret = 0; | ||
48 | |||
49 | codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); | ||
50 | if (codec == NULL) | ||
51 | return -ENOMEM; | ||
52 | mutex_init(&codec->mutex); | ||
53 | codec->name = "AD73311"; | ||
54 | codec->owner = THIS_MODULE; | ||
55 | codec->dai = &ad73311_dai; | ||
56 | codec->num_dai = 1; | ||
57 | socdev->card->codec = codec; | ||
58 | INIT_LIST_HEAD(&codec->dapm_widgets); | ||
59 | INIT_LIST_HEAD(&codec->dapm_paths); | ||
60 | |||
61 | /* register pcms */ | ||
62 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | ||
63 | if (ret < 0) { | ||
64 | printk(KERN_ERR "ad73311: failed to create pcms\n"); | ||
65 | goto pcm_err; | ||
66 | } | ||
67 | |||
68 | return ret; | ||
69 | 43 | ||
70 | pcm_err: | 44 | static int ad73311_probe(struct platform_device *pdev) |
71 | kfree(socdev->card->codec); | 45 | { |
72 | socdev->card->codec = NULL; | 46 | return snd_soc_register_codec(&pdev->dev, |
73 | return ret; | 47 | &soc_codec_dev_ad73311, &ad73311_dai, 1); |
74 | } | 48 | } |
75 | 49 | ||
76 | static int ad73311_soc_remove(struct platform_device *pdev) | 50 | static int ad73311_remove(struct platform_device *pdev) |
77 | { | 51 | { |
78 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 52 | snd_soc_unregister_codec(&pdev->dev); |
79 | struct snd_soc_codec *codec = socdev->card->codec; | ||
80 | |||
81 | if (codec == NULL) | ||
82 | return 0; | ||
83 | snd_soc_free_pcms(socdev); | ||
84 | kfree(codec); | ||
85 | return 0; | 53 | return 0; |
86 | } | 54 | } |
87 | 55 | ||
88 | struct snd_soc_codec_device soc_codec_dev_ad73311 = { | 56 | static struct platform_driver ad73311_codec_driver = { |
89 | .probe = ad73311_soc_probe, | 57 | .driver = { |
90 | .remove = ad73311_soc_remove, | 58 | .name = "ad73311-codec", |
59 | .owner = THIS_MODULE, | ||
60 | }, | ||
61 | |||
62 | .probe = ad73311_probe, | ||
63 | .remove = __devexit_p(ad73311_remove), | ||
91 | }; | 64 | }; |
92 | EXPORT_SYMBOL_GPL(soc_codec_dev_ad73311); | ||
93 | 65 | ||
94 | static int __init ad73311_init(void) | 66 | static int __init ad73311_init(void) |
95 | { | 67 | { |
96 | return snd_soc_register_dai(&ad73311_dai); | 68 | return platform_driver_register(&ad73311_codec_driver); |
97 | } | 69 | } |
98 | module_init(ad73311_init); | 70 | module_init(ad73311_init); |
99 | 71 | ||
100 | static void __exit ad73311_exit(void) | 72 | static void __exit ad73311_exit(void) |
101 | { | 73 | { |
102 | snd_soc_unregister_dai(&ad73311_dai); | 74 | platform_driver_unregister(&ad73311_codec_driver); |
103 | } | 75 | } |
104 | module_exit(ad73311_exit); | 76 | module_exit(ad73311_exit); |
105 | 77 | ||