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: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-tegra@vger.kernel.org
Subject: [PATCH v2 08/20] ASoC: tegra20: spdif: Improve driver's code
Date: Fri, 26 Nov 2021 19:17:55 +0300 [thread overview]
Message-ID: <20211126161807.15776-9-digetx@gmail.com> (raw)
In-Reply-To: <20211126161807.15776-1-digetx@gmail.com>
- Clean up whitespaces, defines and variables.
- Remove obsolete code.
- Adhere to upstream coding style.
- Don't override returned error code.
- Replace pr_err with dev_err.
No functional changes are made by this patch. This is a minor code's
refactoring that will ease further maintenance of the driver.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
sound/soc/tegra/tegra20_spdif.c | 49 ++++++++++++---------------------
1 file changed, 18 insertions(+), 31 deletions(-)
diff --git a/sound/soc/tegra/tegra20_spdif.c b/sound/soc/tegra/tegra20_spdif.c
index 6650875d2555..9383683aa4e9 100644
--- a/sound/soc/tegra/tegra20_spdif.c
+++ b/sound/soc/tegra/tegra20_spdif.c
@@ -23,8 +23,6 @@
#include "tegra20_spdif.h"
-#define DRV_NAME "tegra20-spdif"
-
static __maybe_unused int tegra20_spdif_runtime_suspend(struct device *dev)
{
struct tegra20_spdif *spdif = dev_get_drvdata(dev);
@@ -49,11 +47,10 @@ static __maybe_unused int tegra20_spdif_runtime_resume(struct device *dev)
}
static int tegra20_spdif_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params,
- struct snd_soc_dai *dai)
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai)
{
- struct device *dev = dai->dev;
- struct tegra20_spdif *spdif = snd_soc_dai_get_drvdata(dai);
+ struct tegra20_spdif *spdif = dev_get_drvdata(dai->dev);
unsigned int mask = 0, val = 0;
int ret, spdifclock;
@@ -106,7 +103,7 @@ static int tegra20_spdif_hw_params(struct snd_pcm_substream *substream,
ret = clk_set_rate(spdif->clk_spdif_out, spdifclock);
if (ret) {
- dev_err(dev, "Can't set SPDIF clock rate: %d\n", ret);
+ dev_err(dai->dev, "Can't set SPDIF clock rate: %d\n", ret);
return ret;
}
@@ -127,9 +124,9 @@ static void tegra20_spdif_stop_playback(struct tegra20_spdif *spdif)
}
static int tegra20_spdif_trigger(struct snd_pcm_substream *substream, int cmd,
- struct snd_soc_dai *dai)
+ struct snd_soc_dai *dai)
{
- struct tegra20_spdif *spdif = snd_soc_dai_get_drvdata(dai);
+ struct tegra20_spdif *spdif = dev_get_drvdata(dai->dev);
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
@@ -151,7 +148,7 @@ static int tegra20_spdif_trigger(struct snd_pcm_substream *substream, int cmd,
static int tegra20_spdif_probe(struct snd_soc_dai *dai)
{
- struct tegra20_spdif *spdif = snd_soc_dai_get_drvdata(dai);
+ struct tegra20_spdif *spdif = dev_get_drvdata(dai->dev);
dai->capture_dma_data = NULL;
dai->playback_dma_data = &spdif->playback_dma_data;
@@ -160,26 +157,26 @@ static int tegra20_spdif_probe(struct snd_soc_dai *dai)
}
static const struct snd_soc_dai_ops tegra20_spdif_dai_ops = {
- .hw_params = tegra20_spdif_hw_params,
- .trigger = tegra20_spdif_trigger,
+ .hw_params = tegra20_spdif_hw_params,
+ .trigger = tegra20_spdif_trigger,
};
static struct snd_soc_dai_driver tegra20_spdif_dai = {
- .name = DRV_NAME,
+ .name = "tegra20-spdif",
.probe = tegra20_spdif_probe,
.playback = {
.stream_name = "Playback",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
- SNDRV_PCM_RATE_48000,
+ SNDRV_PCM_RATE_48000,
.formats = SNDRV_PCM_FMTBIT_S16_LE,
},
.ops = &tegra20_spdif_dai_ops,
};
static const struct snd_soc_component_driver tegra20_spdif_component = {
- .name = DRV_NAME,
+ .name = "tegra20-spdif",
};
static bool tegra20_spdif_wr_rd_reg(struct device *dev, unsigned int reg)
@@ -260,7 +257,7 @@ static const struct regmap_config tegra20_spdif_regmap_config = {
static int tegra20_spdif_platform_probe(struct platform_device *pdev)
{
struct tegra20_spdif *spdif;
- struct resource *mem, *dmareq;
+ struct resource *mem;
void __iomem *regs;
int ret;
@@ -273,27 +270,19 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
spdif->clk_spdif_out = devm_clk_get(&pdev->dev, "spdif_out");
if (IS_ERR(spdif->clk_spdif_out)) {
- pr_err("Can't retrieve spdif clock\n");
- ret = PTR_ERR(spdif->clk_spdif_out);
- return ret;
+ dev_err(&pdev->dev, "Could not retrieve spdif clock\n");
+ return PTR_ERR(spdif->clk_spdif_out);
}
regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
if (IS_ERR(regs))
return PTR_ERR(regs);
- dmareq = platform_get_resource(pdev, IORESOURCE_DMA, 0);
- if (!dmareq) {
- dev_err(&pdev->dev, "No DMA resource\n");
- return -ENODEV;
- }
-
spdif->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
- &tegra20_spdif_regmap_config);
+ &tegra20_spdif_regmap_config);
if (IS_ERR(spdif->regmap)) {
dev_err(&pdev->dev, "regmap init failed\n");
- ret = PTR_ERR(spdif->regmap);
- return ret;
+ return PTR_ERR(spdif->regmap);
}
spdif->playback_dma_data.addr = mem->start + TEGRA20_SPDIF_DATA_OUT;
@@ -306,7 +295,6 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
&tegra20_spdif_dai, 1);
if (ret) {
dev_err(&pdev->dev, "Could not register DAI: %d\n", ret);
- ret = -ENOMEM;
goto err_pm_disable;
}
@@ -349,14 +337,13 @@ MODULE_DEVICE_TABLE(of, tegra20_spdif_of_match);
static struct platform_driver tegra20_spdif_driver = {
.driver = {
- .name = DRV_NAME,
+ .name = "tegra20-spdif",
.pm = &tegra20_spdif_pm_ops,
.of_match_table = tegra20_spdif_of_match,
},
.probe = tegra20_spdif_platform_probe,
.remove = tegra20_spdif_platform_remove,
};
-
module_platform_driver(tegra20_spdif_driver);
MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
--
2.33.1
next prev parent reply other threads:[~2021-11-26 16:23 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-26 16:17 [PATCH v2 00/20] Support HDMI audio on NVIDIA Tegra20 Dmitry Osipenko
2021-11-26 16:17 ` [PATCH v2 01/20] ASoC: dt-bindings: Add binding for Tegra20 S/PDIF Dmitry Osipenko
2021-12-01 23:48 ` Rob Herring
2021-11-26 16:17 ` [PATCH v2 02/20] ASoC: dt-bindings: tegra20-i2s: Convert to schema Dmitry Osipenko
2021-12-01 23:50 ` Rob Herring
2021-11-26 16:17 ` [PATCH v2 03/20] ASoC: dt-bindings: tegra20-i2s: Document new nvidia, fixed-parent-rate property Dmitry Osipenko
2021-12-01 23:50 ` [PATCH v2 03/20] ASoC: dt-bindings: tegra20-i2s: Document new nvidia,fixed-parent-rate property Rob Herring
2021-11-26 16:17 ` [PATCH v2 04/20] dt-bindings: host1x: Document optional HDMI sound-dai-cells Dmitry Osipenko
2021-12-01 23:50 ` Rob Herring
2021-11-26 16:17 ` [PATCH v2 05/20] ASoC: tegra20: spdif: Set FIFO trigger level Dmitry Osipenko
2021-11-26 16:17 ` [PATCH v2 06/20] ASoC: tegra20-spdif: stop setting slave_id Dmitry Osipenko
2021-11-26 16:17 ` [PATCH v2 07/20] ASoC: tegra20: spdif: Support device-tree Dmitry Osipenko
2021-11-26 16:17 ` Dmitry Osipenko [this message]
2021-11-26 16:17 ` [PATCH v2 09/20] ASoC: tegra20: spdif: Use more resource-managed helpers Dmitry Osipenko
2021-11-26 16:17 ` [PATCH v2 10/20] ASoC: tegra20: spdif: Reset hardware Dmitry Osipenko
2021-11-26 16:17 ` [PATCH v2 11/20] ASoC: tegra20: spdif: Support system suspend Dmitry Osipenko
2021-11-26 16:17 ` [PATCH v2 12/20] ASoC: tegra20: spdif: Filter out unsupported rates Dmitry Osipenko
2021-11-26 16:18 ` [PATCH v2 13/20] ASoC: tegra20: i2s: " Dmitry Osipenko
2021-11-26 16:18 ` [PATCH v2 14/20] drm/tegra: hdmi: Unwind tegra_hdmi_init() errors Dmitry Osipenko
2021-11-26 16:18 ` [PATCH v2 15/20] drm/tegra: hdmi: Register audio CODEC on Tegra20 Dmitry Osipenko
2021-11-26 16:18 ` [PATCH v2 16/20] ARM: tegra_defconfig: Enable S/PDIF driver Dmitry Osipenko
2021-11-26 16:18 ` [PATCH v2 17/20] ARM: tegra: Add S/PDIF node to Tegra20 device-tree Dmitry Osipenko
2021-11-26 16:18 ` [PATCH v2 18/20] ARM: tegra: Add HDMI audio graph " Dmitry Osipenko
2021-11-26 16:18 ` [PATCH v2 19/20] ARM: tegra: acer-a500: Enable S/PDIF and HDMI audio Dmitry Osipenko
2021-11-26 16:18 ` [PATCH v2 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=20211126161807.15776-9-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=dri-devel@lists.freedesktop.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).