diff mbox

[v3,1/9] ASoC: rt5514: Switch to snd_soc_register_codec

Message ID 20170817044417.22069-2-jeffy.chen@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeffy Chen Aug. 17, 2017, 4:44 a.m. UTC
Currently we are using devm_snd_soc_register_component, which would
use legacy dai name.

Switch to snd_soc_register_codec to use dai driver name.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

Changes in v3: None
Changes in v2: None

 sound/soc/codecs/rt5514-spi.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

Comments

Mark Brown Aug. 17, 2017, 5:11 p.m. UTC | #1
On Thu, Aug 17, 2017 at 12:44:09PM +0800, Jeffy Chen wrote:
> Currently we are using devm_snd_soc_register_component, which would
> use legacy dai name.

> Switch to snd_soc_register_codec to use dai driver name.

This is the wrong direction to be going in, we are trying to move all
drivers to use component.  Whatever you want to do make components use
it.
Jeffy Chen Aug. 18, 2017, 2:48 a.m. UTC | #2
Hi Mark,

On 08/18/2017 01:11 AM, Mark Brown wrote:
> On Thu, Aug 17, 2017 at 12:44:09PM +0800, Jeffy Chen wrote:
>> Currently we are using devm_snd_soc_register_component, which would
>> use legacy dai name.
>
>> Switch to snd_soc_register_codec to use dai driver name.
>
> This is the wrong direction to be going in, we are trying to move all
> drivers to use component.  Whatever you want to do make components use
> it.
>

i was trying to make dai name use dai driver name:

         /*
          * Back in the old days when we still had component-less DAIs,
          * instead of having a static name, component-less DAIs would
          * inherit the name of the parent device so it is possible to
          * register multiple instances of the DAI. We still need to keep
          * the same naming style even though those DAIs are not
          * component-less anymore.
          */
         if (legacy_dai_naming &&
            (dai_drv->id == 0 || dai_drv->name == NULL)) {
                 dai->name = fmt_single_name(dev, &dai->id);
         } else {
                 dai->name = fmt_multiple_name(dev, dai_drv);


specify an non-zero id for dai driver works too, i'll do it in new 
patches :)
diff mbox

Patch

diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c
index 640193d845be..ad6bc51dd82a 100644
--- a/sound/soc/codecs/rt5514-spi.c
+++ b/sound/soc/codecs/rt5514-spi.c
@@ -277,8 +277,10 @@  static struct snd_soc_platform_driver rt5514_spi_platform = {
 	.ops = &rt5514_spi_pcm_ops,
 };
 
-static const struct snd_soc_component_driver rt5514_spi_dai_component = {
-	.name		= "rt5514-spi-dai",
+static const struct snd_soc_codec_driver rt5514_spi_dai_codec = {
+	.component_driver = {
+		.name = "rt5514-spi-dai",
+	},
 };
 
 /**
@@ -426,9 +428,8 @@  static int rt5514_spi_probe(struct spi_device *spi)
 		return ret;
 	}
 
-	ret = devm_snd_soc_register_component(&spi->dev,
-					      &rt5514_spi_dai_component,
-					      &rt5514_spi_dai, 1);
+	ret = snd_soc_register_codec(&spi->dev, &rt5514_spi_dai_codec,
+				     &rt5514_spi_dai, 1);
 	if (ret < 0) {
 		dev_err(&spi->dev, "Failed to register component.\n");
 		return ret;
@@ -437,6 +438,13 @@  static int rt5514_spi_probe(struct spi_device *spi)
 	return 0;
 }
 
+static int rt5514_spi_remove(struct spi_device *spi)
+{
+	snd_soc_unregister_codec(&spi->dev);
+
+	return 0;
+}
+
 static const struct of_device_id rt5514_of_match[] = {
 	{ .compatible = "realtek,rt5514", },
 	{},
@@ -449,6 +457,7 @@  static struct spi_driver rt5514_spi_driver = {
 		.of_match_table = of_match_ptr(rt5514_of_match),
 	},
 	.probe = rt5514_spi_probe,
+	.remove = rt5514_spi_remove,
 };
 module_spi_driver(rt5514_spi_driver);