ASoC: fsl_sai: use local device pointer
[ Upstream commit f53f50ee21d46094a8c48970e95e38a4deaa128e ] Use a local variable to dereference the device pointer once and use the local variable in further calls. No functional changes. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Acked-by: Shengjiu Wang <shengjiu.wang@gmail.com> Link: https://lore.kernel.org/r/20220601092342.3328644-1-m.felsch@pengutronix.de Signed-off-by: Mark Brown <broonie@kernel.org> Stable-dep-of: 6a564338a23c ("ASoC: fsl_asrc fsl_esai fsl_sai: allow CONFIG_PM=N") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
71e496bd33
commit
d1e4288d2a
@@ -1000,6 +1000,7 @@ static int fsl_sai_runtime_resume(struct device *dev);
|
|||||||
static int fsl_sai_probe(struct platform_device *pdev)
|
static int fsl_sai_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device_node *np = pdev->dev.of_node;
|
struct device_node *np = pdev->dev.of_node;
|
||||||
|
struct device *dev = &pdev->dev;
|
||||||
struct fsl_sai *sai;
|
struct fsl_sai *sai;
|
||||||
struct regmap *gpr;
|
struct regmap *gpr;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
@@ -1008,12 +1009,12 @@ static int fsl_sai_probe(struct platform_device *pdev)
|
|||||||
int irq, ret, i;
|
int irq, ret, i;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
sai = devm_kzalloc(&pdev->dev, sizeof(*sai), GFP_KERNEL);
|
sai = devm_kzalloc(dev, sizeof(*sai), GFP_KERNEL);
|
||||||
if (!sai)
|
if (!sai)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
sai->pdev = pdev;
|
sai->pdev = pdev;
|
||||||
sai->soc_data = of_device_get_match_data(&pdev->dev);
|
sai->soc_data = of_device_get_match_data(dev);
|
||||||
|
|
||||||
sai->is_lsb_first = of_property_read_bool(np, "lsb-first");
|
sai->is_lsb_first = of_property_read_bool(np, "lsb-first");
|
||||||
|
|
||||||
@@ -1028,18 +1029,18 @@ static int fsl_sai_probe(struct platform_device *pdev)
|
|||||||
ARRAY_SIZE(fsl_sai_reg_defaults_ofs8);
|
ARRAY_SIZE(fsl_sai_reg_defaults_ofs8);
|
||||||
}
|
}
|
||||||
|
|
||||||
sai->regmap = devm_regmap_init_mmio(&pdev->dev, base, &fsl_sai_regmap_config);
|
sai->regmap = devm_regmap_init_mmio(dev, base, &fsl_sai_regmap_config);
|
||||||
if (IS_ERR(sai->regmap)) {
|
if (IS_ERR(sai->regmap)) {
|
||||||
dev_err(&pdev->dev, "regmap init failed\n");
|
dev_err(dev, "regmap init failed\n");
|
||||||
return PTR_ERR(sai->regmap);
|
return PTR_ERR(sai->regmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
sai->bus_clk = devm_clk_get(&pdev->dev, "bus");
|
sai->bus_clk = devm_clk_get(dev, "bus");
|
||||||
/* Compatible with old DTB cases */
|
/* Compatible with old DTB cases */
|
||||||
if (IS_ERR(sai->bus_clk) && PTR_ERR(sai->bus_clk) != -EPROBE_DEFER)
|
if (IS_ERR(sai->bus_clk) && PTR_ERR(sai->bus_clk) != -EPROBE_DEFER)
|
||||||
sai->bus_clk = devm_clk_get(&pdev->dev, "sai");
|
sai->bus_clk = devm_clk_get(dev, "sai");
|
||||||
if (IS_ERR(sai->bus_clk)) {
|
if (IS_ERR(sai->bus_clk)) {
|
||||||
dev_err(&pdev->dev, "failed to get bus clock: %ld\n",
|
dev_err(dev, "failed to get bus clock: %ld\n",
|
||||||
PTR_ERR(sai->bus_clk));
|
PTR_ERR(sai->bus_clk));
|
||||||
/* -EPROBE_DEFER */
|
/* -EPROBE_DEFER */
|
||||||
return PTR_ERR(sai->bus_clk);
|
return PTR_ERR(sai->bus_clk);
|
||||||
@@ -1047,9 +1048,9 @@ static int fsl_sai_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
for (i = 1; i < FSL_SAI_MCLK_MAX; i++) {
|
for (i = 1; i < FSL_SAI_MCLK_MAX; i++) {
|
||||||
sprintf(tmp, "mclk%d", i);
|
sprintf(tmp, "mclk%d", i);
|
||||||
sai->mclk_clk[i] = devm_clk_get(&pdev->dev, tmp);
|
sai->mclk_clk[i] = devm_clk_get(dev, tmp);
|
||||||
if (IS_ERR(sai->mclk_clk[i])) {
|
if (IS_ERR(sai->mclk_clk[i])) {
|
||||||
dev_err(&pdev->dev, "failed to get mclk%d clock: %ld\n",
|
dev_err(dev, "failed to get mclk%d clock: %ld\n",
|
||||||
i + 1, PTR_ERR(sai->mclk_clk[i]));
|
i + 1, PTR_ERR(sai->mclk_clk[i]));
|
||||||
sai->mclk_clk[i] = NULL;
|
sai->mclk_clk[i] = NULL;
|
||||||
}
|
}
|
||||||
@@ -1064,10 +1065,10 @@ static int fsl_sai_probe(struct platform_device *pdev)
|
|||||||
if (irq < 0)
|
if (irq < 0)
|
||||||
return irq;
|
return irq;
|
||||||
|
|
||||||
ret = devm_request_irq(&pdev->dev, irq, fsl_sai_isr, IRQF_SHARED,
|
ret = devm_request_irq(dev, irq, fsl_sai_isr, IRQF_SHARED,
|
||||||
np->name, sai);
|
np->name, sai);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "failed to claim irq %u\n", irq);
|
dev_err(dev, "failed to claim irq %u\n", irq);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1084,7 +1085,7 @@ static int fsl_sai_probe(struct platform_device *pdev)
|
|||||||
if (of_find_property(np, "fsl,sai-synchronous-rx", NULL) &&
|
if (of_find_property(np, "fsl,sai-synchronous-rx", NULL) &&
|
||||||
of_find_property(np, "fsl,sai-asynchronous", NULL)) {
|
of_find_property(np, "fsl,sai-asynchronous", NULL)) {
|
||||||
/* error out if both synchronous and asynchronous are present */
|
/* error out if both synchronous and asynchronous are present */
|
||||||
dev_err(&pdev->dev, "invalid binding for synchronous mode\n");
|
dev_err(dev, "invalid binding for synchronous mode\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1105,7 +1106,7 @@ static int fsl_sai_probe(struct platform_device *pdev)
|
|||||||
of_device_is_compatible(np, "fsl,imx6ul-sai")) {
|
of_device_is_compatible(np, "fsl,imx6ul-sai")) {
|
||||||
gpr = syscon_regmap_lookup_by_compatible("fsl,imx6ul-iomuxc-gpr");
|
gpr = syscon_regmap_lookup_by_compatible("fsl,imx6ul-iomuxc-gpr");
|
||||||
if (IS_ERR(gpr)) {
|
if (IS_ERR(gpr)) {
|
||||||
dev_err(&pdev->dev, "cannot find iomuxc registers\n");
|
dev_err(dev, "cannot find iomuxc registers\n");
|
||||||
return PTR_ERR(gpr);
|
return PTR_ERR(gpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1123,23 +1124,23 @@ static int fsl_sai_probe(struct platform_device *pdev)
|
|||||||
sai->dma_params_tx.maxburst = FSL_SAI_MAXBURST_TX;
|
sai->dma_params_tx.maxburst = FSL_SAI_MAXBURST_TX;
|
||||||
|
|
||||||
platform_set_drvdata(pdev, sai);
|
platform_set_drvdata(pdev, sai);
|
||||||
pm_runtime_enable(&pdev->dev);
|
pm_runtime_enable(dev);
|
||||||
if (!pm_runtime_enabled(&pdev->dev)) {
|
if (!pm_runtime_enabled(dev)) {
|
||||||
ret = fsl_sai_runtime_resume(&pdev->dev);
|
ret = fsl_sai_runtime_resume(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_pm_disable;
|
goto err_pm_disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pm_runtime_get_sync(&pdev->dev);
|
ret = pm_runtime_get_sync(dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
pm_runtime_put_noidle(&pdev->dev);
|
pm_runtime_put_noidle(dev);
|
||||||
goto err_pm_get_sync;
|
goto err_pm_get_sync;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get sai version */
|
/* Get sai version */
|
||||||
ret = fsl_sai_check_version(&pdev->dev);
|
ret = fsl_sai_check_version(dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_warn(&pdev->dev, "Error reading SAI version: %d\n", ret);
|
dev_warn(dev, "Error reading SAI version: %d\n", ret);
|
||||||
|
|
||||||
/* Select MCLK direction */
|
/* Select MCLK direction */
|
||||||
if (of_find_property(np, "fsl,sai-mclk-direction-output", NULL) &&
|
if (of_find_property(np, "fsl,sai-mclk-direction-output", NULL) &&
|
||||||
@@ -1148,7 +1149,7 @@ static int fsl_sai_probe(struct platform_device *pdev)
|
|||||||
FSL_SAI_MCTL_MCLK_EN, FSL_SAI_MCTL_MCLK_EN);
|
FSL_SAI_MCTL_MCLK_EN, FSL_SAI_MCTL_MCLK_EN);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pm_runtime_put_sync(&pdev->dev);
|
ret = pm_runtime_put_sync(dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err_pm_get_sync;
|
goto err_pm_get_sync;
|
||||||
|
|
||||||
@@ -1161,12 +1162,12 @@ static int fsl_sai_probe(struct platform_device *pdev)
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto err_pm_get_sync;
|
goto err_pm_get_sync;
|
||||||
} else {
|
} else {
|
||||||
ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
|
ret = devm_snd_dmaengine_pcm_register(dev, NULL, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_pm_get_sync;
|
goto err_pm_get_sync;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = devm_snd_soc_register_component(&pdev->dev, &fsl_component,
|
ret = devm_snd_soc_register_component(dev, &fsl_component,
|
||||||
&sai->cpu_dai_drv, 1);
|
&sai->cpu_dai_drv, 1);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_pm_get_sync;
|
goto err_pm_get_sync;
|
||||||
@@ -1174,10 +1175,10 @@ static int fsl_sai_probe(struct platform_device *pdev)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
err_pm_get_sync:
|
err_pm_get_sync:
|
||||||
if (!pm_runtime_status_suspended(&pdev->dev))
|
if (!pm_runtime_status_suspended(dev))
|
||||||
fsl_sai_runtime_suspend(&pdev->dev);
|
fsl_sai_runtime_suspend(dev);
|
||||||
err_pm_disable:
|
err_pm_disable:
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(dev);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user