mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 08:19:28 +00:00
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>
This commit is contained in:
parent
eda1a701fd
commit
bdfd60e3c0
1 changed files with 30 additions and 50 deletions
|
@ -42,34 +42,7 @@ static struct snd_ac97_bus soc_ac97_bus = {
|
|||
.ops = NULL, /* Gets initialized in snd_soc_set_ac97_ops() */
|
||||
};
|
||||
|
||||
/* unregister ac97 codec */
|
||||
static int soc_ac97_dev_unregister(struct snd_soc_codec *codec)
|
||||
{
|
||||
if (codec->ac97->dev.bus)
|
||||
device_del(&codec->ac97->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* register ac97 codec to bus */
|
||||
static int soc_ac97_dev_register(struct snd_soc_codec *codec)
|
||||
{
|
||||
int err;
|
||||
|
||||
codec->ac97->dev.bus = &ac97_bus_type;
|
||||
codec->ac97->dev.parent = codec->component.card->dev;
|
||||
|
||||
dev_set_name(&codec->ac97->dev, "%d-%d:%s",
|
||||
codec->component.card->snd_card->number, 0,
|
||||
codec->component.name);
|
||||
err = device_add(&codec->ac97->dev);
|
||||
if (err < 0) {
|
||||
dev_err(codec->dev, "ASoC: Can't register ac97 bus\n");
|
||||
codec->ac97->dev.bus = NULL;
|
||||
return err;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int soc_register_ac97_codec(struct snd_soc_codec *codec,
|
||||
struct snd_soc_dai *codec_dai)
|
||||
{
|
||||
|
@ -78,7 +51,9 @@ static int soc_register_ac97_codec(struct snd_soc_codec *codec,
|
|||
/* Only instantiate AC97 if not already done by the adaptor
|
||||
* for the generic AC97 subsystem.
|
||||
*/
|
||||
if (codec_dai->driver->ac97_control && !codec->ac97_registered) {
|
||||
if (!codec_dai->driver->ac97_control || codec->ac97_registered)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* It is possible that the AC97 device is already registered to
|
||||
* the device subsystem. This happens when the device is created
|
||||
|
@ -90,24 +65,29 @@ static int soc_register_ac97_codec(struct snd_soc_codec *codec,
|
|||
if (!codec->ac97_created)
|
||||
return 0;
|
||||
|
||||
ret = soc_ac97_dev_register(codec);
|
||||
codec->ac97->dev.bus = &ac97_bus_type;
|
||||
codec->ac97->dev.parent = codec->component.card->dev;
|
||||
|
||||
dev_set_name(&codec->ac97->dev, "%d-%d:%s",
|
||||
codec->component.card->snd_card->number, 0,
|
||||
codec->component.name);
|
||||
ret = device_add(&codec->ac97->dev);
|
||||
if (ret < 0) {
|
||||
dev_err(codec->dev,
|
||||
"ASoC: AC97 device register failed: %d\n", ret);
|
||||
dev_err(codec->dev, "ASoC: AC97 device register failed: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
codec->ac97_registered = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void soc_unregister_ac97_codec(struct snd_soc_codec *codec)
|
||||
{
|
||||
if (codec->ac97_registered) {
|
||||
soc_ac97_dev_unregister(codec);
|
||||
if (!codec->ac97_registered)
|
||||
return;
|
||||
device_del(&codec->ac97->dev);
|
||||
codec->ac97_registered = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd)
|
||||
|
|
Loading…
Reference in a new issue