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,18 +42,28 @@ static struct snd_ac97_bus soc_ac97_bus = {
|
||||||
.ops = NULL, /* Gets initialized in snd_soc_set_ac97_ops() */
|
.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 */
|
/* register ac97 codec to bus */
|
||||||
static int soc_ac97_dev_register(struct snd_soc_codec *codec)
|
static int soc_register_ac97_codec(struct snd_soc_codec *codec,
|
||||||
|
struct snd_soc_dai *codec_dai)
|
||||||
{
|
{
|
||||||
int err;
|
int ret;
|
||||||
|
|
||||||
|
/* Only instantiate AC97 if not already done by the adaptor
|
||||||
|
* for the generic AC97 subsystem.
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
* via snd_ac97_mixer(). Currently only SoC codec that does so
|
||||||
|
* is the generic AC97 glue but others migh emerge.
|
||||||
|
*
|
||||||
|
* In those cases we don't try to register the device again.
|
||||||
|
*/
|
||||||
|
if (!codec->ac97_created)
|
||||||
|
return 0;
|
||||||
|
|
||||||
codec->ac97->dev.bus = &ac97_bus_type;
|
codec->ac97->dev.bus = &ac97_bus_type;
|
||||||
codec->ac97->dev.parent = codec->component.card->dev;
|
codec->ac97->dev.parent = codec->component.card->dev;
|
||||||
|
@ -61,53 +71,23 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec)
|
||||||
dev_set_name(&codec->ac97->dev, "%d-%d:%s",
|
dev_set_name(&codec->ac97->dev, "%d-%d:%s",
|
||||||
codec->component.card->snd_card->number, 0,
|
codec->component.card->snd_card->number, 0,
|
||||||
codec->component.name);
|
codec->component.name);
|
||||||
err = device_add(&codec->ac97->dev);
|
ret = device_add(&codec->ac97->dev);
|
||||||
if (err < 0) {
|
if (ret < 0) {
|
||||||
dev_err(codec->dev, "ASoC: Can't register ac97 bus\n");
|
dev_err(codec->dev, "ASoC: AC97 device register failed: %d\n",
|
||||||
codec->ac97->dev.bus = NULL;
|
ret);
|
||||||
return err;
|
return ret;
|
||||||
}
|
}
|
||||||
return 0;
|
codec->ac97_registered = 1;
|
||||||
}
|
|
||||||
|
|
||||||
static int soc_register_ac97_codec(struct snd_soc_codec *codec,
|
|
||||||
struct snd_soc_dai *codec_dai)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Only instantiate AC97 if not already done by the adaptor
|
|
||||||
* for the generic AC97 subsystem.
|
|
||||||
*/
|
|
||||||
if (codec_dai->driver->ac97_control && !codec->ac97_registered) {
|
|
||||||
/*
|
|
||||||
* It is possible that the AC97 device is already registered to
|
|
||||||
* the device subsystem. This happens when the device is created
|
|
||||||
* via snd_ac97_mixer(). Currently only SoC codec that does so
|
|
||||||
* is the generic AC97 glue but others migh emerge.
|
|
||||||
*
|
|
||||||
* In those cases we don't try to register the device again.
|
|
||||||
*/
|
|
||||||
if (!codec->ac97_created)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = soc_ac97_dev_register(codec);
|
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(codec->dev,
|
|
||||||
"ASoC: AC97 device register failed: %d\n", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
codec->ac97_registered = 1;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void soc_unregister_ac97_codec(struct snd_soc_codec *codec)
|
static void soc_unregister_ac97_codec(struct snd_soc_codec *codec)
|
||||||
{
|
{
|
||||||
if (codec->ac97_registered) {
|
if (!codec->ac97_registered)
|
||||||
soc_ac97_dev_unregister(codec);
|
return;
|
||||||
codec->ac97_registered = 0;
|
device_del(&codec->ac97->dev);
|
||||||
}
|
codec->ac97_registered = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd)
|
static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd)
|
||||||
|
|
Loading…
Reference in a new issue