Commit 117aeed4 authored by Dmitry Osipenko's avatar Dmitry Osipenko Committed by Mark Brown

ASoC: tegra20: spdif: Improve driver's code

- 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: default avatarDmitry Osipenko <digetx@gmail.com>
Acked-by: default avatarThierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20211204143725.31646-9-digetx@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent c0000fc6
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
#include "tegra20_spdif.h" #include "tegra20_spdif.h"
#define DRV_NAME "tegra20-spdif"
static __maybe_unused int tegra20_spdif_runtime_suspend(struct device *dev) static __maybe_unused int tegra20_spdif_runtime_suspend(struct device *dev)
{ {
struct tegra20_spdif *spdif = dev_get_drvdata(dev); struct tegra20_spdif *spdif = dev_get_drvdata(dev);
...@@ -52,8 +50,7 @@ static int tegra20_spdif_hw_params(struct snd_pcm_substream *substream, ...@@ -52,8 +50,7 @@ static int tegra20_spdif_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct device *dev = dai->dev; struct tegra20_spdif *spdif = dev_get_drvdata(dai->dev);
struct tegra20_spdif *spdif = snd_soc_dai_get_drvdata(dai);
unsigned int mask = 0, val = 0; unsigned int mask = 0, val = 0;
int ret, spdifclock; int ret, spdifclock;
...@@ -106,7 +103,7 @@ static int tegra20_spdif_hw_params(struct snd_pcm_substream *substream, ...@@ -106,7 +103,7 @@ static int tegra20_spdif_hw_params(struct snd_pcm_substream *substream,
ret = clk_set_rate(spdif->clk_spdif_out, spdifclock); ret = clk_set_rate(spdif->clk_spdif_out, spdifclock);
if (ret) { 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; return ret;
} }
...@@ -129,7 +126,7 @@ static void tegra20_spdif_stop_playback(struct tegra20_spdif *spdif) ...@@ -129,7 +126,7 @@ static void tegra20_spdif_stop_playback(struct tegra20_spdif *spdif)
static int tegra20_spdif_trigger(struct snd_pcm_substream *substream, int cmd, 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) { switch (cmd) {
case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_START:
...@@ -151,7 +148,7 @@ static int tegra20_spdif_trigger(struct snd_pcm_substream *substream, int cmd, ...@@ -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) 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->capture_dma_data = NULL;
dai->playback_dma_data = &spdif->playback_dma_data; dai->playback_dma_data = &spdif->playback_dma_data;
...@@ -165,7 +162,7 @@ static const struct snd_soc_dai_ops tegra20_spdif_dai_ops = { ...@@ -165,7 +162,7 @@ static const struct snd_soc_dai_ops tegra20_spdif_dai_ops = {
}; };
static struct snd_soc_dai_driver tegra20_spdif_dai = { static struct snd_soc_dai_driver tegra20_spdif_dai = {
.name = DRV_NAME, .name = "tegra20-spdif",
.probe = tegra20_spdif_probe, .probe = tegra20_spdif_probe,
.playback = { .playback = {
.stream_name = "Playback", .stream_name = "Playback",
...@@ -179,7 +176,7 @@ static struct snd_soc_dai_driver tegra20_spdif_dai = { ...@@ -179,7 +176,7 @@ static struct snd_soc_dai_driver tegra20_spdif_dai = {
}; };
static const struct snd_soc_component_driver tegra20_spdif_component = { 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) 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 = { ...@@ -260,7 +257,7 @@ static const struct regmap_config tegra20_spdif_regmap_config = {
static int tegra20_spdif_platform_probe(struct platform_device *pdev) static int tegra20_spdif_platform_probe(struct platform_device *pdev)
{ {
struct tegra20_spdif *spdif; struct tegra20_spdif *spdif;
struct resource *mem, *dmareq; struct resource *mem;
void __iomem *regs; void __iomem *regs;
int ret; int ret;
...@@ -273,27 +270,19 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev) ...@@ -273,27 +270,19 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
spdif->clk_spdif_out = devm_clk_get(&pdev->dev, "out"); spdif->clk_spdif_out = devm_clk_get(&pdev->dev, "out");
if (IS_ERR(spdif->clk_spdif_out)) { if (IS_ERR(spdif->clk_spdif_out)) {
pr_err("Can't retrieve spdif clock\n"); dev_err(&pdev->dev, "Could not retrieve spdif clock\n");
ret = PTR_ERR(spdif->clk_spdif_out); return PTR_ERR(spdif->clk_spdif_out);
return ret;
} }
regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem); regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
if (IS_ERR(regs)) if (IS_ERR(regs))
return PTR_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, spdif->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
&tegra20_spdif_regmap_config); &tegra20_spdif_regmap_config);
if (IS_ERR(spdif->regmap)) { if (IS_ERR(spdif->regmap)) {
dev_err(&pdev->dev, "regmap init failed\n"); dev_err(&pdev->dev, "regmap init failed\n");
ret = PTR_ERR(spdif->regmap); return PTR_ERR(spdif->regmap);
return ret;
} }
spdif->playback_dma_data.addr = mem->start + TEGRA20_SPDIF_DATA_OUT; 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) ...@@ -306,7 +295,6 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
&tegra20_spdif_dai, 1); &tegra20_spdif_dai, 1);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); dev_err(&pdev->dev, "Could not register DAI: %d\n", ret);
ret = -ENOMEM;
goto err_pm_disable; goto err_pm_disable;
} }
...@@ -349,14 +337,13 @@ MODULE_DEVICE_TABLE(of, tegra20_spdif_of_match); ...@@ -349,14 +337,13 @@ MODULE_DEVICE_TABLE(of, tegra20_spdif_of_match);
static struct platform_driver tegra20_spdif_driver = { static struct platform_driver tegra20_spdif_driver = {
.driver = { .driver = {
.name = DRV_NAME, .name = "tegra20-spdif",
.pm = &tegra20_spdif_pm_ops, .pm = &tegra20_spdif_pm_ops,
.of_match_table = tegra20_spdif_of_match, .of_match_table = tegra20_spdif_of_match,
}, },
.probe = tegra20_spdif_platform_probe, .probe = tegra20_spdif_platform_probe,
.remove = tegra20_spdif_platform_remove, .remove = tegra20_spdif_platform_remove,
}; };
module_platform_driver(tegra20_spdif_driver); module_platform_driver(tegra20_spdif_driver);
MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment