diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-11-10 16:41:48 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-11-18 10:37:57 -0500 |
commit | bdfd60e3c0affb914549f1d22e8aeef71e7828e6 (patch) | |
tree | ead1fb889010a82158481275d92670e7d9362523 | |
parent | eda1a701fd9589b6ed15b109558bd4f6202e3829 (diff) |
ASoC: ac97: Merge soc_ac97_dev_{un,}register()/soc_{un,}register_ac97_codec()
soc_{un,}register_ac97_codec() is just a simple wrapper around
soc_ac97_dev_{un,}register(). There is no need to split these up into two
different sets of functions.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/soc-ac97.c | 80 |
1 files changed, 30 insertions, 50 deletions
diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c index dbfca7e7dddb..b5d23c976662 100644 --- a/sound/soc/soc-ac97.c +++ b/sound/soc/soc-ac97.c | |||
@@ -42,18 +42,28 @@ static struct snd_ac97_bus soc_ac97_bus = { | |||
42 | .ops = NULL, /* Gets initialized in snd_soc_set_ac97_ops() */ | 42 | .ops = NULL, /* Gets initialized in snd_soc_set_ac97_ops() */ |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /* unregister ac97 codec */ | ||
46 | static int soc_ac97_dev_unregister(struct snd_soc_codec *codec) | ||
47 | { | ||
48 | if (codec->ac97->dev.bus) | ||
49 | device_del(&codec->ac97->dev); | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | /* register ac97 codec to bus */ | 45 | /* register ac97 codec to bus */ |
54 | static int soc_ac97_dev_register(struct snd_soc_codec *codec) | 46 | static int soc_register_ac97_codec(struct snd_soc_codec *codec, |
47 | struct snd_soc_dai *codec_dai) | ||
55 | { | 48 | { |
56 | int err; | 49 | int ret; |
50 | |||
51 | /* Only instantiate AC97 if not already done by the adaptor | ||
52 | * for the generic AC97 subsystem. | ||
53 | */ | ||
54 | if (!codec_dai->driver->ac97_control || codec->ac97_registered) | ||
55 | return 0; | ||
56 | |||
57 | /* | ||
58 | * It is possible that the AC97 device is already registered to | ||
59 | * the device subsystem. This happens when the device is created | ||
60 | * via snd_ac97_mixer(). Currently only SoC codec that does so | ||
61 | * is the generic AC97 glue but others migh emerge. | ||
62 | * | ||
63 | * In those cases we don't try to register the device again. | ||
64 | */ | ||
65 | if (!codec->ac97_created) | ||
66 | return 0; | ||
57 | 67 | ||
58 | codec->ac97->dev.bus = &ac97_bus_type; | 68 | codec->ac97->dev.bus = &ac97_bus_type; |
59 | codec->ac97->dev.parent = codec->component.card->dev; | 69 | codec->ac97->dev.parent = codec->component.card->dev; |
@@ -61,53 +71,23 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec) | |||
61 | dev_set_name(&codec->ac97->dev, "%d-%d:%s", | 71 | dev_set_name(&codec->ac97->dev, "%d-%d:%s", |
62 | codec->component.card->snd_card->number, 0, | 72 | codec->component.card->snd_card->number, 0, |
63 | codec->component.name); | 73 | codec->component.name); |
64 | err = device_add(&codec->ac97->dev); | 74 | ret = device_add(&codec->ac97->dev); |
65 | if (err < 0) { | 75 | if (ret < 0) { |
66 | dev_err(codec->dev, "ASoC: Can't register ac97 bus\n"); | 76 | dev_err(codec->dev, "ASoC: AC97 device register failed: %d\n", |
67 | codec->ac97->dev.bus = NULL; | 77 | ret); |
68 | return err; | 78 | return ret; |
69 | } | 79 | } |
70 | return 0; | 80 | codec->ac97_registered = 1; |
71 | } | ||
72 | |||
73 | static int soc_register_ac97_codec(struct snd_soc_codec *codec, | ||
74 | struct snd_soc_dai *codec_dai) | ||
75 | { | ||
76 | int ret; | ||
77 | 81 | ||
78 | /* Only instantiate AC97 if not already done by the adaptor | ||
79 | * for the generic AC97 subsystem. | ||
80 | */ | ||
81 | if (codec_dai->driver->ac97_control && !codec->ac97_registered) { | ||
82 | /* | ||
83 | * It is possible that the AC97 device is already registered to | ||
84 | * the device subsystem. This happens when the device is created | ||
85 | * via snd_ac97_mixer(). Currently only SoC codec that does so | ||
86 | * is the generic AC97 glue but others migh emerge. | ||
87 | * | ||
88 | * In those cases we don't try to register the device again. | ||
89 | */ | ||
90 | if (!codec->ac97_created) | ||
91 | return 0; | ||
92 | |||
93 | ret = soc_ac97_dev_register(codec); | ||
94 | if (ret < 0) { | ||
95 | dev_err(codec->dev, | ||
96 | "ASoC: AC97 device register failed: %d\n", ret); | ||
97 | return ret; | ||
98 | } | ||
99 | |||
100 | codec->ac97_registered = 1; | ||
101 | } | ||
102 | return 0; | 82 | return 0; |
103 | } | 83 | } |
104 | 84 | ||
105 | static void soc_unregister_ac97_codec(struct snd_soc_codec *codec) | 85 | static void soc_unregister_ac97_codec(struct snd_soc_codec *codec) |
106 | { | 86 | { |
107 | if (codec->ac97_registered) { | 87 | if (!codec->ac97_registered) |
108 | soc_ac97_dev_unregister(codec); | 88 | return; |
109 | codec->ac97_registered = 0; | 89 | device_del(&codec->ac97->dev); |
110 | } | 90 | codec->ac97_registered = 0; |
111 | } | 91 | } |
112 | 92 | ||
113 | static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) | 93 | static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) |