linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.com>,
	Jaroslav Kysela <perex@perex.cz>,
	Liam Girdwood <lgirdwood@gmail.com>, Agneli <poczt@protonmail.ch>,
	Rob Herring <robh+dt@kernel.org>
Cc: linux-tegra@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: [PATCH v1 09/20] ASoC: tegra20: spdif: Use more resource-managed helpers
Date: Thu, 25 Nov 2021 01:00:46 +0300	[thread overview]
Message-ID: <20211124220057.15763-10-digetx@gmail.com> (raw)
In-Reply-To: <20211124220057.15763-1-digetx@gmail.com>

Use resource-managed helpers to make code cleaner. Driver's remove callback
isn't needed anymore since driver is completely resource-managed now.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 sound/soc/tegra/tegra20_spdif.c | 33 +++++++++------------------------
 sound/soc/tegra/tegra_pcm.c     |  6 ++++++
 sound/soc/tegra/tegra_pcm.h     |  1 +
 3 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/sound/soc/tegra/tegra20_spdif.c b/sound/soc/tegra/tegra20_spdif.c
index 9383683aa4e9..6ca48bc322ae 100644
--- a/sound/soc/tegra/tegra20_spdif.c
+++ b/sound/soc/tegra/tegra20_spdif.c
@@ -289,38 +289,24 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
 	spdif->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
 	spdif->playback_dma_data.maxburst = 4;
 
-	pm_runtime_enable(&pdev->dev);
+	ret = devm_pm_runtime_enable(&pdev->dev);
+	if (ret)
+		return ret;
 
-	ret = snd_soc_register_component(&pdev->dev, &tegra20_spdif_component,
-					 &tegra20_spdif_dai, 1);
+	ret = devm_snd_soc_register_component(&pdev->dev,
+					      &tegra20_spdif_component,
+					      &tegra20_spdif_dai, 1);
 	if (ret) {
 		dev_err(&pdev->dev, "Could not register DAI: %d\n", ret);
-		goto err_pm_disable;
+		return ret;
 	}
 
-	ret = tegra_pcm_platform_register(&pdev->dev);
+	ret = devm_tegra_pcm_platform_register(&pdev->dev);
 	if (ret) {
 		dev_err(&pdev->dev, "Could not register PCM: %d\n", ret);
-		goto err_unregister_component;
+		return ret;
 	}
 
-	return 0;
-
-err_unregister_component:
-	snd_soc_unregister_component(&pdev->dev);
-err_pm_disable:
-	pm_runtime_disable(&pdev->dev);
-
-	return ret;
-}
-
-static int tegra20_spdif_platform_remove(struct platform_device *pdev)
-{
-	tegra_pcm_platform_unregister(&pdev->dev);
-	snd_soc_unregister_component(&pdev->dev);
-
-	pm_runtime_disable(&pdev->dev);
-
 	return 0;
 }
 
@@ -342,7 +328,6 @@ static struct platform_driver tegra20_spdif_driver = {
 		.of_match_table = tegra20_spdif_of_match,
 	},
 	.probe = tegra20_spdif_platform_probe,
-	.remove = tegra20_spdif_platform_remove,
 };
 module_platform_driver(tegra20_spdif_driver);
 
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c
index ef1e74d95236..468c8e77de21 100644
--- a/sound/soc/tegra/tegra_pcm.c
+++ b/sound/soc/tegra/tegra_pcm.c
@@ -48,6 +48,12 @@ int tegra_pcm_platform_register(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(tegra_pcm_platform_register);
 
+int devm_tegra_pcm_platform_register(struct device *dev)
+{
+	return devm_snd_dmaengine_pcm_register(dev, &tegra_dmaengine_pcm_config, 0);
+}
+EXPORT_SYMBOL_GPL(devm_tegra_pcm_platform_register);
+
 int tegra_pcm_platform_register_with_chan_names(struct device *dev,
 				struct snd_dmaengine_pcm_config *config,
 				char *txdmachan, char *rxdmachan)
diff --git a/sound/soc/tegra/tegra_pcm.h b/sound/soc/tegra/tegra_pcm.h
index d602126c65b7..2a36eea1740d 100644
--- a/sound/soc/tegra/tegra_pcm.h
+++ b/sound/soc/tegra/tegra_pcm.h
@@ -32,6 +32,7 @@ int tegra_pcm_hw_params(struct snd_soc_component *component,
 snd_pcm_uframes_t tegra_pcm_pointer(struct snd_soc_component *component,
 				    struct snd_pcm_substream *substream);
 int tegra_pcm_platform_register(struct device *dev);
+int devm_tegra_pcm_platform_register(struct device *dev);
 int tegra_pcm_platform_register_with_chan_names(struct device *dev,
 				struct snd_dmaengine_pcm_config *config,
 				char *txdmachan, char *rxdmachan);
-- 
2.33.1


  parent reply	other threads:[~2021-11-24 22:07 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24 22:00 [PATCH v1 00/20] Support HDMI audio on NVIDIA Tegra20 Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 01/20] ASoC: dt-bindings: Add binding for Tegra20 S/PDIF Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 02/20] ASoC: dt-bindings: tegra20-i2s: Convert to schema Dmitry Osipenko
2021-11-25 21:26   ` Rob Herring
2021-11-26  1:08     ` Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 03/20] ASoC: dt-bindings: tegra20-i2s: Document new nvidia,fixed-parent-rate property Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 04/20] dt-bindings: host1x: Document optional HDMI sound-dai-cells Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 05/20] ASoC: tegra20-spdif: stop setting slave_id Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 06/20] ASoC: tegra20: spdif: Support device-tree Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 07/20] ASoC: tegra20: spdif: Set FIFO trigger level Dmitry Osipenko
2021-11-25 12:02   ` Mark Brown
2021-11-25 12:04     ` Dmitry Osipenko
2021-11-25 12:28       ` Mark Brown
2021-11-25 12:53         ` Dmitry Osipenko
2021-11-25 13:18           ` Mark Brown
2021-11-25 13:36             ` Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 08/20] ASoC: tegra20: spdif: Improve driver's code Dmitry Osipenko
2021-11-24 22:00 ` Dmitry Osipenko [this message]
2021-11-24 22:00 ` [PATCH v1 10/20] ASoC: tegra20: spdif: Reset hardware Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 11/20] ASoC: tegra20: spdif: Support system suspend Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 12/20] ASoC: tegra20: spdif: Filter out unsupported rates Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 13/20] ASoC: tegra20: i2s: " Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 14/20] drm/tegra: hdmi: Unwind tegra_hdmi_init() errors Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 15/20] drm/tegra: hdmi: Register audio CODEC on Tegra20 Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 16/20] ARM: tegra_defconfig: Enable S/PDIF driver Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 17/20] ARM: tegra: Add S/PDIF node to Tegra20 device-tree Dmitry Osipenko
2021-11-25 11:43   ` Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 18/20] ARM: tegra: Add HDMI audio graph " Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 19/20] ARM: tegra: acer-a500: Enable S/PDIF and HDMI audio Dmitry Osipenko
2021-11-24 22:00 ` [PATCH v1 20/20] ARM: tegra: paz00: " Dmitry Osipenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211124220057.15763-10-digetx@gmail.com \
    --to=digetx@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=poczt@protonmail.ch \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).