diff --git a/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c b/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c index 1bf8fa62..e5fcb948 100644 --- a/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c +++ b/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/sound/soc/tegra-alt/tegra186_arad_alt.c b/sound/soc/tegra-alt/tegra186_arad_alt.c index 8ea20363..f1e3879f 100644 --- a/sound/soc/tegra-alt/tegra186_arad_alt.c +++ b/sound/soc/tegra-alt/tegra186_arad_alt.c @@ -24,15 +24,12 @@ #include #include #include -#include #include #include #include #include -#include #include #include -#include #include "tegra186_asrc_alt.h" #include "tegra186_arad_alt.h" @@ -753,17 +750,12 @@ static int tegra186_arad_platform_probe(struct platform_device *pdev) match = of_match_device(tegra186_arad_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } - arad = devm_kzalloc(&pdev->dev, - sizeof(struct tegra186_arad), GFP_KERNEL); - if (!arad) { - dev_err(&pdev->dev, "Can't allocate tegra210_arad\n"); - ret = -ENOMEM; - goto err; - } + arad = devm_kzalloc(&pdev->dev, sizeof(*arad), GFP_KERNEL); + if (!arad) + return -ENOMEM; arad_dev = &pdev->dev; dev_set_drvdata(&pdev->dev, arad); @@ -780,13 +772,11 @@ static int tegra186_arad_platform_probe(struct platform_device *pdev) } regcache_cache_only(arad->regmap, true); - if (of_property_read_u32(pdev->dev.of_node, - "nvidia,ahub-arad-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-arad-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(pdev->dev.of_node, "nvidia,ahub-arad-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-arad-id\n"); + return ret; } pm_runtime_enable(&pdev->dev); @@ -796,7 +786,8 @@ static int tegra186_arad_platform_probe(struct platform_device *pdev) ARRAY_SIZE(tegra186_arad_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } #ifdef CONFIG_SND_SOC_TEGRA186_ARAD_WAR @@ -808,14 +799,8 @@ static int tegra186_arad_platform_probe(struct platform_device *pdev) TEGRA186_AHC_ARAD1_CB, &pdev->dev); #endif #endif - return 0; -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra186_arad_runtime_suspend(&pdev->dev); - pm_runtime_disable(&pdev->dev); -err: - return ret; + return 0; } static int tegra186_arad_platform_remove(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra186_asrc_alt.c b/sound/soc/tegra-alt/tegra186_asrc_alt.c index f5edfe5c..1cc3a0bc 100644 --- a/sound/soc/tegra-alt/tegra186_asrc_alt.c +++ b/sound/soc/tegra-alt/tegra186_asrc_alt.c @@ -23,16 +23,13 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include -#include #include "tegra210_xbar_alt.h" #include "tegra186_asrc_alt.h" @@ -1094,17 +1091,12 @@ static int tegra186_asrc_platform_probe(struct platform_device *pdev) match = of_match_device(tegra186_asrc_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } asrc_dev = &pdev->dev; - asrc = devm_kzalloc(&pdev->dev, - sizeof(struct tegra186_asrc), GFP_KERNEL); - if (!asrc) { - dev_err(&pdev->dev, "Can't allocate asrc\n"); - ret = -ENOMEM; - goto err; - } + asrc = devm_kzalloc(&pdev->dev, sizeof(*asrc), GFP_KERNEL); + if (!asrc) + return -ENOMEM; asrc->is_shutdown = false; dev_set_drvdata(&pdev->dev, asrc); @@ -1121,29 +1113,20 @@ static int tegra186_asrc_platform_probe(struct platform_device *pdev) } regcache_cache_only(asrc->regmap, true); - if (of_property_read_u32(pdev->dev.of_node, - "nvidia,ahub-asrc-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-asrc-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(pdev->dev.of_node, "nvidia,ahub-asrc-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-asrc-id\n"); + return ret; } #ifdef CONFIG_TEGRA186_AHC - tegra186_ahc_register_cb(tegra186_asrc_ahc_cb, - TEGRA186_AHC_ASRC1_CB, &pdev->dev); + tegra186_ahc_register_cb(tegra186_asrc_ahc_cb, TEGRA186_AHC_ASRC1_CB, + &pdev->dev); #endif - pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra186_asrc_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_CONFIG, - TEGRA186_ASRC_GLOBAL_CONFIG_FRAC_32BIT_PRECISION); + TEGRA186_ASRC_GLOBAL_CONFIG_FRAC_32BIT_PRECISION); /* initialize default output srate */ for (i = 0; i < 6; i++) { @@ -1159,23 +1142,17 @@ static int tegra186_asrc_platform_probe(struct platform_device *pdev) ASRC_STREAM_REG(TEGRA186_ASRC_STREAM1_CONFIG, i), 1, 1); } + pm_runtime_enable(&pdev->dev); ret = snd_soc_register_codec(&pdev->dev, &tegra186_asrc_codec, tegra186_asrc_dais, ARRAY_SIZE(tegra186_asrc_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra186_asrc_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; } static void tegra186_asrc_platform_shutdown(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra186_dspk_alt.c b/sound/soc/tegra-alt/tegra186_dspk_alt.c index acaa4802..91afdc44 100644 --- a/sound/soc/tegra-alt/tegra186_dspk_alt.c +++ b/sound/soc/tegra-alt/tegra186_dspk_alt.c @@ -23,16 +23,13 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include -#include #include #include "tegra210_xbar_alt.h" @@ -455,42 +452,36 @@ static int tegra186_dspk_platform_probe(struct platform_device *pdev) match = of_match_device(tegra186_dspk_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } - dspk = devm_kzalloc(&pdev->dev, sizeof(struct tegra186_dspk), - GFP_KERNEL); - if (!dspk) { - dev_err(&pdev->dev, "Can't allocate dspk\n"); - ret = -ENOMEM; - goto err; - } + dspk = devm_kzalloc(&pdev->dev, sizeof(*dspk), GFP_KERNEL); + if (!dspk) + return -ENOMEM; dspk->is_shutdown = false; dspk->prod_name = NULL; dspk->rx_fifo_th = 0; dspk->osr_val = TEGRA186_DSPK_OSR_64; + dev_set_drvdata(&pdev->dev, dspk); if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { dspk->clk_dspk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(dspk->clk_dspk)) { dev_err(&pdev->dev, "Can't retrieve dspk clock\n"); - ret = PTR_ERR(dspk->clk_dspk); - goto err; + return PTR_ERR(dspk->clk_dspk); } dspk->clk_pll_a_out0 = devm_clk_get(&pdev->dev, "pll_a_out0"); - if (IS_ERR_OR_NULL(dspk->clk_pll_a_out0)) { + if (IS_ERR(dspk->clk_pll_a_out0)) { dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n"); - ret = -ENOENT; - goto err; + return PTR_ERR(dspk->clk_pll_a_out0); } ret = clk_set_parent(dspk->clk_dspk, dspk->clk_pll_a_out0); if (ret) { dev_err(&pdev->dev, "Can't set parent of dspk clock\n"); - goto err; + return ret; } } @@ -506,34 +497,28 @@ static int tegra186_dspk_platform_probe(struct platform_device *pdev) } regcache_cache_only(dspk->regmap, true); - if (of_property_read_u32(np, "nvidia,ahub-dspk-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-dspk-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(np, "nvidia,ahub-dspk-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-dspk-id\n"); + return ret; } pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra186_dspk_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - ret = snd_soc_register_codec(&pdev->dev, &tegra186_dspk_codec, tegra186_dspk_dais, ARRAY_SIZE(tegra186_dspk_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } if (of_property_read_string(np, "prod-name", &dspk->prod_name) == 0) { ret = tegra_pinctrl_config_prod(&pdev->dev, dspk->prod_name); if (ret < 0) dev_warn(&pdev->dev, "Failed to set %s setting\n", - dspk->prod_name); + dspk->prod_name); } dspk->pinctrl = devm_pinctrl_get(&pdev->dev); @@ -543,31 +528,19 @@ static int tegra186_dspk_platform_probe(struct platform_device *pdev) } dspk->pin_active_state = pinctrl_lookup_state(dspk->pinctrl, - "dap_active"); + "dap_active"); if (IS_ERR(dspk->pin_active_state)) { dev_dbg(&pdev->dev, "Missing dap-active state\n"); goto err_dap; } dspk->pin_idle_state = pinctrl_lookup_state(dspk->pinctrl, - "dap_inactive"); - if (IS_ERR(dspk->pin_idle_state)) { + "dap_inactive"); + if (IS_ERR(dspk->pin_idle_state)) dev_dbg(&pdev->dev, "Missing dap-inactive state\n"); - goto err_dap; - } err_dap: - dev_set_drvdata(&pdev->dev, dspk); - return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra186_dspk_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; } static void tegra186_dspk_platform_shutdown(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra210_admaif_alt.c b/sound/soc/tegra-alt/tegra210_admaif_alt.c index 595f254f..8dadd30b 100644 --- a/sound/soc/tegra-alt/tegra210_admaif_alt.c +++ b/sound/soc/tegra-alt/tegra210_admaif_alt.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -33,7 +32,6 @@ #include "tegra_pcm_alt.h" #include "tegra210_xbar_alt.h" #include "tegra_isomgr_bw_alt.h" - #include "tegra210_admaif_alt.h" #define DRV_NAME "tegra210-ape-admaif" @@ -1130,9 +1128,7 @@ static const struct of_device_id tegra_admaif_of_match[] = { static int tegra_admaif_probe(struct platform_device *pdev) { - int i; - - int ret; + int ret, i; struct tegra_admaif *admaif; void __iomem *regs; struct resource *res; @@ -1146,11 +1142,8 @@ static int tegra_admaif_probe(struct platform_device *pdev) } admaif = devm_kzalloc(&pdev->dev, sizeof(*admaif), GFP_KERNEL); - if (!admaif) { - dev_err(&pdev->dev, "Can't allocate tegra_admaif\n"); - ret = -ENOMEM; - goto err; - } + if (!admaif) + return -ENOMEM; admaif->dev = &pdev->dev; admaif->soc_data = (struct tegra_admaif_soc_data *)match->data; @@ -1161,48 +1154,33 @@ static int tegra_admaif_probe(struct platform_device *pdev) sizeof(struct tegra_alt_pcm_dma_params) * admaif->soc_data->num_ch, GFP_KERNEL); - if (!admaif->capture_dma_data) { - dev_err(&pdev->dev, "Can't allocate capture_dma_data\n"); - ret = -ENOMEM; - goto err; - } + if (!admaif->capture_dma_data) + return -ENOMEM; admaif->playback_dma_data = devm_kzalloc(&pdev->dev, sizeof(struct tegra_alt_pcm_dma_params) * admaif->soc_data->num_ch, GFP_KERNEL); - if (!admaif->playback_dma_data) { - dev_err(&pdev->dev, "Can't allocate playback_dma_data\n"); - ret = -ENOMEM; - goto err; - } + if (!admaif->playback_dma_data) + return -ENOMEM; admaif->override_channels = devm_kzalloc(&pdev->dev, sizeof(int) * admaif->soc_data->num_ch, GFP_KERNEL); - if (!admaif->override_channels) { - dev_err(&pdev->dev, "Can't allocate override channel memory\n"); - ret = -ENOMEM; - goto err; - } + if (!admaif->override_channels) + return -ENOMEM; admaif->tx_mono_to_stereo = devm_kzalloc(&pdev->dev, sizeof(int) * admaif->soc_data->num_ch, GFP_KERNEL); - if (!admaif->tx_mono_to_stereo) { - dev_err(&pdev->dev, "Can't allocate override channel memory\n"); - ret = -ENOMEM; - goto err; - } + if (!admaif->tx_mono_to_stereo) + return -ENOMEM; admaif->rx_stereo_to_mono = devm_kzalloc(&pdev->dev, sizeof(int) * admaif->soc_data->num_ch, GFP_KERNEL); - if (!admaif->rx_stereo_to_mono) { - dev_err(&pdev->dev, "Can't allocate override channel memory\n"); - ret = -ENOMEM; - goto err; - } + if (!admaif->rx_stereo_to_mono) + return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); regs = devm_ioremap_resource(&pdev->dev, res); @@ -1217,13 +1195,6 @@ static int tegra_admaif_probe(struct platform_device *pdev) } regcache_cache_only(admaif->regmap, true); - pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra_admaif_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - if (admaif->soc_data->is_isomgr_client) tegra_isomgr_adma_register(); @@ -1239,14 +1210,14 @@ static int tegra_admaif_probe(struct platform_device *pdev) admaif->playback_dma_data[i].width = 32; admaif->playback_dma_data[i].req_sel = i + 1; - if (of_property_read_string_index(pdev->dev.of_node, + ret = of_property_read_string_index(pdev->dev.of_node, "dma-names", (i * 2) + 1, - &admaif->playback_dma_data[i].chan_name) < 0) { + &admaif->playback_dma_data[i].chan_name); + if (ret < 0) { dev_err(&pdev->dev, "Missing property nvidia,dma-names\n"); - ret = -ENODEV; - goto err_suspend; + return ret; } buffer_size = 0; if (of_property_read_u32_index(pdev->dev.of_node, @@ -1260,14 +1231,14 @@ static int tegra_admaif_probe(struct platform_device *pdev) admaif->capture_dma_data[i].width = 32; admaif->capture_dma_data[i].req_sel = i + 1; - if (of_property_read_string_index(pdev->dev.of_node, + ret = of_property_read_string_index(pdev->dev.of_node, "dma-names", (i * 2), - &admaif->capture_dma_data[i].chan_name) < 0) { + &admaif->capture_dma_data[i].chan_name); + if (ret < 0) { dev_err(&pdev->dev, "Missing property nvidia,dma-names\n"); - ret = -ENODEV; - goto err_suspend; + return ret; } buffer_size = 0; if (of_property_read_u32_index(pdev->dev.of_node, @@ -1280,46 +1251,41 @@ static int tegra_admaif_probe(struct platform_device *pdev) admaif->capture_dma_data[i].buffer_size = buffer_size; } - ret = snd_soc_register_component(&pdev->dev, - &tegra_admaif_dai_driver, - tegra_admaif_dais, - admaif->soc_data->num_ch); + regmap_update_bits(admaif->regmap, admaif->soc_data->global_base + + TEGRA_ADMAIF_GLOBAL_ENABLE, 1, 1); + + ret = devm_snd_soc_register_component(&pdev->dev, + &tegra_admaif_dai_driver, + tegra_admaif_dais, + admaif->soc_data->num_ch); if (ret) { dev_err(&pdev->dev, "Could not register DAIs %d: %d\n", i, ret); - ret = -ENOMEM; - goto err_suspend; + return ret; } + pm_runtime_enable(&pdev->dev); ret = snd_soc_register_codec(&pdev->dev, admaif->soc_data->admaif_codec, - admaif->soc_data->codec_dais, - admaif->soc_data->num_ch * 2); + admaif->soc_data->codec_dais, + admaif->soc_data->num_ch * 2); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_unregister_dais; + goto pm_disable; } ret = tegra_alt_pcm_platform_register(&pdev->dev); if (ret) { dev_err(&pdev->dev, "Could not register PCM: %d\n", ret); - goto err_unregister_codec; + goto unregister_codec; } - regmap_update_bits(admaif->regmap, admaif->soc_data->global_base + - TEGRA_ADMAIF_GLOBAL_ENABLE, 1, 1); - return 0; -err_unregister_codec: +unregister_codec: snd_soc_unregister_codec(&pdev->dev); -err_unregister_dais: - snd_soc_unregister_component(&pdev->dev); -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra_admaif_runtime_suspend(&pdev->dev); -err_pm_disable: +pm_disable: pm_runtime_disable(&pdev->dev); -err: + return ret; } diff --git a/sound/soc/tegra-alt/tegra210_adx_alt.c b/sound/soc/tegra-alt/tegra210_adx_alt.c index 1aa75d05..62bebdee 100644 --- a/sound/soc/tegra-alt/tegra210_adx_alt.c +++ b/sound/soc/tegra-alt/tegra210_adx_alt.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -805,16 +804,12 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev) match = of_match_device(tegra210_adx_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } - adx = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_adx), GFP_KERNEL); - if (!adx) { - dev_err(&pdev->dev, "Can't allocate tegra210_adx\n"); - ret = -ENOMEM; - goto err; - } + adx = devm_kzalloc(&pdev->dev, sizeof(*adx), GFP_KERNEL); + if (!adx) + return -ENOMEM; adx->is_shutdown = false; dev_set_drvdata(&pdev->dev, adx); @@ -831,39 +826,25 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev) } regcache_cache_only(adx->regmap, true); - if (of_property_read_u32(pdev->dev.of_node, - "nvidia,ahub-adx-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-adx-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(pdev->dev.of_node, + "nvidia,ahub-adx-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-adx-id\n"); + return ret; } pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra210_adx_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - ret = snd_soc_register_codec(&pdev->dev, &tegra210_adx_codec, tegra210_adx_dais, ARRAY_SIZE(tegra210_adx_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra210_adx_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; } static void tegra210_adx_platform_shutdown(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra210_afc_alt.c b/sound/soc/tegra-alt/tegra210_afc_alt.c index 9177cdee..6f032b1c 100644 --- a/sound/soc/tegra-alt/tegra210_afc_alt.c +++ b/sound/soc/tegra-alt/tegra210_afc_alt.c @@ -24,12 +24,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include "tegra210_xbar_alt.h" @@ -521,17 +519,13 @@ static int tegra210_afc_platform_probe(struct platform_device *pdev) match = of_match_device(tegra210_afc_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } soc_data = (struct tegra210_afc_soc_data *)match->data; - afc = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_afc), GFP_KERNEL); - if (!afc) { - dev_err(&pdev->dev, "Can't allocate afc\n"); - ret = -ENOMEM; - goto err; - } + afc = devm_kzalloc(&pdev->dev, sizeof(*afc), GFP_KERNEL); + if (!afc) + return -ENOMEM; afc->soc_data = soc_data; tegra210_afc_init(afc); @@ -550,42 +544,28 @@ static int tegra210_afc_platform_probe(struct platform_device *pdev) } regcache_cache_only(afc->regmap, true); - if (of_property_read_u32(pdev->dev.of_node, - "nvidia,ahub-afc-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-afc-id\n"); - ret = -ENODEV; - goto err; - } - - pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra210_afc_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; + ret = of_property_read_u32(pdev->dev.of_node, + "nvidia,ahub-afc-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-afc-id\n"); + return -ret; } /* Disable SLGC */ regmap_write(afc->regmap, TEGRA210_AFC_CG, 0); + pm_runtime_enable(&pdev->dev); ret = snd_soc_register_codec(&pdev->dev, afc->soc_data->afc_codec, tegra210_afc_dais, ARRAY_SIZE(tegra210_afc_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra210_afc_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; } static void tegra210_afc_platform_shutdown(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra210_amx_alt.c b/sound/soc/tegra-alt/tegra210_amx_alt.c index 0b0bce4f..c8c7e47b 100644 --- a/sound/soc/tegra-alt/tegra210_amx_alt.c +++ b/sound/soc/tegra-alt/tegra210_amx_alt.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -886,17 +885,13 @@ static int tegra210_amx_platform_probe(struct platform_device *pdev) match = of_match_device(tegra210_amx_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } soc_data = (struct tegra210_amx_soc_data *)match->data; - amx = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_amx), GFP_KERNEL); - if (!amx) { - dev_err(&pdev->dev, "Can't allocate tegra210_amx\n"); - ret = -ENOMEM; - goto err; - } + amx = devm_kzalloc(&pdev->dev, sizeof(*amx), GFP_KERNEL); + if (!amx) + return -ENOMEM; amx->soc_data = soc_data; amx->is_shutdown = false; @@ -916,46 +911,31 @@ static int tegra210_amx_platform_probe(struct platform_device *pdev) } regcache_cache_only(amx->regmap, true); - if (of_property_read_u32(pdev->dev.of_node, - "nvidia,ahub-amx-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-amx-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(pdev->dev.of_node, + "nvidia,ahub-amx-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-amx-id\n"); + return ret; } /* following is necessary to have the required codec-dai-name */ if (dev_set_name(&pdev->dev, "%s.%d", DRV_NAME, pdev->dev.id)) { dev_err(&pdev->dev, "error in setting AMX dev name\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra210_amx_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - ret = snd_soc_register_codec(&pdev->dev, &tegra210_amx_codec, tegra210_amx_dais, ARRAY_SIZE(tegra210_amx_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra210_amx_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; } static void tegra210_amx_platform_shutdown(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra210_dmic_alt.c b/sound/soc/tegra-alt/tegra210_dmic_alt.c index d97b076d..4555883f 100644 --- a/sound/soc/tegra-alt/tegra210_dmic_alt.c +++ b/sound/soc/tegra-alt/tegra210_dmic_alt.c @@ -568,16 +568,12 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev) match = of_match_device(tegra210_dmic_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } - dmic = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_dmic), GFP_KERNEL); - if (!dmic) { - dev_err(&pdev->dev, "Can't allocate dmic\n"); - ret = -ENOMEM; - goto err; - } + dmic = devm_kzalloc(&pdev->dev, sizeof(*dmic), GFP_KERNEL); + if (!dmic) + return -ENOMEM; dmic->is_shutdown = false; dmic->prod_name = NULL; @@ -587,23 +583,21 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev) if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { dmic->clk_dmic = devm_clk_get(&pdev->dev, "dmic"); - if (IS_ERR_OR_NULL(dmic->clk_dmic)) { + if (IS_ERR(dmic->clk_dmic)) { dev_err(&pdev->dev, "Can't retrieve dmic clock\n"); - ret = PTR_ERR(dmic->clk_dmic); - goto err; + return PTR_ERR(dmic->clk_dmic); } dmic->clk_parent = devm_clk_get(&pdev->dev, "parent"); - if (IS_ERR_OR_NULL(dmic->clk_parent)) { + if (IS_ERR(dmic->clk_parent)) { dev_err(&pdev->dev, "Can't retrieve parent clock\n"); - ret = PTR_ERR(dmic->clk_parent); - goto err; + return PTR_ERR(dmic->clk_parent); } ret = clk_set_parent(dmic->clk_dmic, dmic->clk_parent); if (ret) { dev_err(&pdev->dev, "Can't set parent of dmic clock\n"); - goto err; + return ret; } } @@ -623,27 +617,21 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev) regmap_write(dmic->regmap, TEGRA210_DMIC_DCR_BIQUAD_0_COEF_4, 0x00000000); - if (of_property_read_u32(np, "nvidia,ahub-dmic-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-dmic-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(np, "nvidia,ahub-dmic-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-dmic-id\n"); + return ret; } pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra210_dmic_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - ret = snd_soc_register_codec(&pdev->dev, &tegra210_dmic_codec, tegra210_dmic_dais, ARRAY_SIZE(tegra210_dmic_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } if (of_property_read_string(np, "prod-name", &dmic->prod_name) == 0) { @@ -674,15 +662,8 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev) } err_dap: - return 0; -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra210_dmic_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; + return 0; } static void tegra210_dmic_platform_shutdown(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra210_i2s_alt.c b/sound/soc/tegra-alt/tegra210_i2s_alt.c index 3b5d5dda..193ab8d9 100644 --- a/sound/soc/tegra-alt/tegra210_i2s_alt.c +++ b/sound/soc/tegra-alt/tegra210_i2s_alt.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -1068,16 +1066,12 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev) match = of_match_device(tegra210_i2s_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } - i2s = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_i2s), GFP_KERNEL); - if (!i2s) { - dev_err(&pdev->dev, "Can't allocate i2s\n"); - ret = -ENOMEM; - goto err; - } + i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); + if (!i2s) + return -ENOMEM; i2s->tx_mask = i2s->rx_mask = 0xFFFF; i2s->enable_cya = false; @@ -1092,8 +1086,7 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev) i2s->clk_i2s = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(i2s->clk_i2s)) { dev_err(&pdev->dev, "Can't retrieve i2s clock\n"); - ret = PTR_ERR(i2s->clk_i2s); - goto err; + return PTR_ERR(i2s->clk_i2s); } i2s->clk_i2s_sync = devm_clk_get(&pdev->dev, "ext_audio_sync"); @@ -1107,8 +1100,7 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev) i2s->clk_i2s_source = devm_clk_get(&pdev->dev, "i2s_clk_parent"); if (IS_ERR(i2s->clk_i2s_source)) { dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n"); - ret = PTR_ERR(i2s->clk_i2s_source); - goto err; + return PTR_ERR(i2s->clk_i2s_source); } } @@ -1124,12 +1116,11 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev) } regcache_cache_only(i2s->regmap, true); - if (of_property_read_u32(np, "nvidia,ahub-i2s-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-i2s-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(np, "nvidia,ahub-i2s-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-i2s-id\n"); + return ret; } if (of_property_read_u32(pdev->dev.of_node, "bclk-ratio", @@ -1152,32 +1143,31 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev) i2s->fsync_width = 31; } - i2s->enable_cya = - of_property_read_bool(pdev->dev.of_node, - "enable-cya"); + i2s->enable_cya = of_property_read_bool(pdev->dev.of_node, + "enable-cya"); if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { if (of_property_read_string(np, "prod-name", - &i2s->prod_name) == 0) + &i2s->prod_name) == 0) tegra_pinctrl_config_prod(&pdev->dev, i2s->prod_name); - num_supplies = - of_property_count_strings(np, "regulator-supplies"); + num_supplies = of_property_count_strings(np, + "regulator-supplies"); if (num_supplies > 0) { i2s->num_supplies = num_supplies; i2s->supplies = devm_kzalloc(&pdev->dev, num_supplies * - sizeof(*i2s->supplies), GFP_KERNEL); - if (!i2s->supplies) { - ret = -ENOMEM; - goto err; - } - of_property_for_each_string(np, - "regulator-supplies", prop, supply) + sizeof(*i2s->supplies), + GFP_KERNEL); + if (!i2s->supplies) + return -ENOMEM; + + of_property_for_each_string(np, "regulator-supplies", + prop, supply) i2s->supplies[count++].supply = supply; - ret = devm_regulator_bulk_get( - &pdev->dev, i2s->num_supplies, - i2s->supplies); + ret = devm_regulator_bulk_get(&pdev->dev, + i2s->num_supplies, + i2s->supplies); if (ret) { dev_err(&pdev->dev, "Failed to get supplies: %d\n", ret); @@ -1192,45 +1182,33 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev) } i2s->pin_default_state = pinctrl_lookup_state(i2s->pinctrl, - "dap_active"); + "dap_active"); if (IS_ERR(i2s->pin_default_state)) { dev_dbg(&pdev->dev, "Missing dap-active state\n"); goto err_dap; } i2s->pin_idle_state = pinctrl_lookup_state(i2s->pinctrl, - "dap_inactive"); + "dap_inactive"); if (IS_ERR(i2s->pin_idle_state)) { dev_dbg(&pdev->dev, "Missing dap-inactive state\n"); goto err_dap; } } + err_dap: pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra210_i2s_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - ret = snd_soc_register_codec(&pdev->dev, &tegra210_i2s_codec, tegra210_i2s_dais, ARRAY_SIZE(tegra210_i2s_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra210_i2s_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; } static void tegra210_i2s_platform_shutdown(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra210_iqc_alt.c b/sound/soc/tegra-alt/tegra210_iqc_alt.c index 2e140216..8fd56a31 100644 --- a/sound/soc/tegra-alt/tegra210_iqc_alt.c +++ b/sound/soc/tegra-alt/tegra210_iqc_alt.c @@ -23,14 +23,11 @@ #include #include #include -#include #include #include #include #include -#include #include -#include #include #include "tegra210_xbar_alt.h" @@ -300,16 +297,12 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev) match = of_match_device(tegra210_iqc_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } - iqc = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_iqc), GFP_KERNEL); - if (!iqc) { - dev_err(&pdev->dev, "Can't allocate iqc\n"); - ret = -ENOMEM; - goto err; - } + iqc = devm_kzalloc(&pdev->dev, sizeof(*iqc), GFP_KERNEL); + if (!iqc) + return -ENOMEM; dev_set_drvdata(&pdev->dev, iqc); @@ -317,8 +310,7 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev) iqc->clk_iqc = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(iqc->clk_iqc)) { dev_err(&pdev->dev, "Can't retrieve iqc clock\n"); - ret = PTR_ERR(iqc->clk_iqc); - goto err; + return PTR_ERR(iqc->clk_iqc); } } @@ -334,19 +326,18 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev) } regcache_cache_only(iqc->regmap, true); - if (of_property_read_u32(pdev->dev.of_node, - "nvidia,ahub-iqc-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-iqc-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(pdev->dev.of_node, + "nvidia,ahub-iqc-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-iqc-id\n"); + return ret; } if (of_property_read_u32(pdev->dev.of_node, - "timestamp-enable", - &iqc->timestamp_enable) < 0) { - dev_err(&pdev->dev, + "timestamp-enable", + &iqc->timestamp_enable) < 0) { + dev_dbg(&pdev->dev, "Missing property timestamp-enable for IQC\n"); iqc->timestamp_enable = 1; } @@ -354,35 +345,22 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev) if (of_property_read_u32(pdev->dev.of_node, "data-offset", &iqc->data_offset) < 0) { - dev_err(&pdev->dev, + dev_dbg(&pdev->dev, "Missing property data-offset for IQC\n"); iqc->data_offset = 0; } pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra210_iqc_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - ret = snd_soc_register_codec(&pdev->dev, &tegra210_iqc_codec, tegra210_iqc_dais, ARRAY_SIZE(tegra210_iqc_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra210_iqc_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; } static int tegra210_iqc_platform_remove(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra210_mbdrc_alt.c b/sound/soc/tegra-alt/tegra210_mbdrc_alt.c index 91bc78cc..f95537d7 100644 --- a/sound/soc/tegra-alt/tegra210_mbdrc_alt.c +++ b/sound/soc/tegra-alt/tegra210_mbdrc_alt.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include diff --git a/sound/soc/tegra-alt/tegra210_mixer_alt.c b/sound/soc/tegra-alt/tegra210_mixer_alt.c index 5c7e3bff..d2a60e14 100644 --- a/sound/soc/tegra-alt/tegra210_mixer_alt.c +++ b/sound/soc/tegra-alt/tegra210_mixer_alt.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -688,17 +687,12 @@ static int tegra210_mixer_platform_probe(struct platform_device *pdev) match = of_match_device(tegra210_mixer_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } - mixer = devm_kzalloc(&pdev->dev, - sizeof(struct tegra210_mixer), GFP_KERNEL); - if (!mixer) { - dev_err(&pdev->dev, "Can't allocate tegra210_mixer\n"); - ret = -ENOMEM; - goto err; - } + mixer = devm_kzalloc(&pdev->dev, sizeof(*mixer), GFP_KERNEL); + if (!mixer) + return -ENOMEM; mixer->is_shutdown = false; mixer->gain_coeff[0] = 0; @@ -732,39 +726,25 @@ static int tegra210_mixer_platform_probe(struct platform_device *pdev) } regcache_cache_only(mixer->regmap, true); - if (of_property_read_u32(pdev->dev.of_node, - "nvidia,ahub-amixer-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-amixer-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(pdev->dev.of_node, + "nvidia,ahub-amixer-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-amixer-id\n"); + return ret; } pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra210_mixer_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - ret = snd_soc_register_codec(&pdev->dev, &tegra210_mixer_codec, tegra210_mixer_dais, ARRAY_SIZE(tegra210_mixer_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra210_mixer_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; } static void tegra210_mixer_platform_shutdown(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra210_mvc_alt.c b/sound/soc/tegra-alt/tegra210_mvc_alt.c index 7853629d..6fd52f61 100644 --- a/sound/soc/tegra-alt/tegra210_mvc_alt.c +++ b/sound/soc/tegra-alt/tegra210_mvc_alt.c @@ -23,12 +23,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include @@ -627,16 +625,12 @@ static int tegra210_mvc_platform_probe(struct platform_device *pdev) match = of_match_device(tegra210_mvc_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } - mvc = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_mvc), GFP_KERNEL); - if (!mvc) { - dev_err(&pdev->dev, "Can't allocate mvc\n"); - ret = -ENOMEM; - goto err; - } + mvc = devm_kzalloc(&pdev->dev, sizeof(*mvc), GFP_KERNEL); + if (!mvc) + return -ENOMEM; mvc->is_shutdown = false; dev_set_drvdata(&pdev->dev, mvc); @@ -669,39 +663,25 @@ static int tegra210_mvc_platform_probe(struct platform_device *pdev) } regcache_cache_only(mvc->regmap, true); - if (of_property_read_u32(pdev->dev.of_node, - "nvidia,ahub-mvc-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-mvc-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(pdev->dev.of_node, + "nvidia,ahub-mvc-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-mvc-id\n"); + return ret; } pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra210_mvc_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - ret = snd_soc_register_codec(&pdev->dev, &tegra210_mvc_codec, tegra210_mvc_dais, ARRAY_SIZE(tegra210_mvc_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra210_mvc_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; } static void tegra210_mvc_platform_shutdown(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra210_ope_alt.c b/sound/soc/tegra-alt/tegra210_ope_alt.c index e0127285..81f12cae 100644 --- a/sound/soc/tegra-alt/tegra210_ope_alt.c +++ b/sound/soc/tegra-alt/tegra210_ope_alt.c @@ -24,12 +24,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include "tegra210_xbar_alt.h" @@ -326,16 +324,12 @@ static int tegra210_ope_platform_probe(struct platform_device *pdev) match = of_match_device(tegra210_ope_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } - ope = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_ope), GFP_KERNEL); - if (!ope) { - dev_err(&pdev->dev, "Can't allocate ope\n"); - ret = -ENOMEM; - goto err; - } + ope = devm_kzalloc(&pdev->dev, sizeof(*ope), GFP_KERNEL); + if (!ope) + return -ENOMEM; ope->is_shutdown = false; @@ -356,52 +350,38 @@ static int tegra210_ope_platform_probe(struct platform_device *pdev) ret = tegra210_peq_init(pdev, TEGRA210_PEQ_IORESOURCE_MEM); if (ret < 0) { dev_err(&pdev->dev, "peq init failed\n"); - goto err; + return ret; } regcache_cache_only(ope->peq_regmap, true); ret = tegra210_mbdrc_init(pdev, TEGRA210_MBDRC_IORESOURCE_MEM); if (ret < 0) { dev_err(&pdev->dev, "mbdrc init failed\n"); - goto err; + return ret; } regcache_cache_only(ope->mbdrc_regmap, true); - if (of_property_read_u32(pdev->dev.of_node, - "nvidia,ahub-ope-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-ope-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(pdev->dev.of_node, + "nvidia,ahub-ope-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-ope-id\n"); + return ret; } pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra210_ope_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - ret = snd_soc_register_codec(&pdev->dev, &tegra210_ope_codec, tegra210_ope_dais, ARRAY_SIZE(tegra210_ope_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } pr_info("OPE platform probe successful\n"); return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra210_ope_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; } static void tegra210_ope_platform_shutdown(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra210_peq_alt.c b/sound/soc/tegra-alt/tegra210_peq_alt.c index 1edd7d52..bd4aae45 100644 --- a/sound/soc/tegra-alt/tegra210_peq_alt.c +++ b/sound/soc/tegra-alt/tegra210_peq_alt.c @@ -24,12 +24,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include "tegra210_xbar_alt.h" diff --git a/sound/soc/tegra-alt/tegra210_sfc_alt.c b/sound/soc/tegra-alt/tegra210_sfc_alt.c index 59dc04fe..4b45a00a 100644 --- a/sound/soc/tegra-alt/tegra210_sfc_alt.c +++ b/sound/soc/tegra-alt/tegra210_sfc_alt.c @@ -23,12 +23,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include @@ -3555,16 +3553,12 @@ static int tegra210_sfc_platform_probe(struct platform_device *pdev) match = of_match_device(tegra210_sfc_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } - sfc = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_sfc), GFP_KERNEL); - if (!sfc) { - dev_err(&pdev->dev, "Can't allocate sfc\n"); - ret = -ENOMEM; - goto err; - } + sfc = devm_kzalloc(&pdev->dev, sizeof(*sfc), GFP_KERNEL); + if (!sfc) + return -ENOMEM; sfc->is_shutdown = false; @@ -3585,39 +3579,25 @@ static int tegra210_sfc_platform_probe(struct platform_device *pdev) } regcache_cache_only(sfc->regmap, true); - if (of_property_read_u32(pdev->dev.of_node, - "nvidia,ahub-sfc-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-sfc-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(pdev->dev.of_node, + "nvidia,ahub-sfc-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-sfc-id\n"); + return ret; } pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra210_sfc_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - ret = snd_soc_register_codec(&pdev->dev, &tegra210_sfc_codec, tegra210_sfc_dais, ARRAY_SIZE(tegra210_sfc_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra210_sfc_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; } static void tegra210_sfc_platform_shutdown(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra210_spdif_alt.c b/sound/soc/tegra-alt/tegra210_spdif_alt.c index 30485dc2..2fd8176b 100644 --- a/sound/soc/tegra-alt/tegra210_spdif_alt.c +++ b/sound/soc/tegra-alt/tegra210_spdif_alt.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -424,17 +423,12 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev) match = of_match_device(tegra210_spdif_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } - spdif = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_spdif), - GFP_KERNEL); - if (!spdif) { - dev_err(&pdev->dev, "Can't allocate tegra210_spdif\n"); - ret = -ENOMEM; - goto err; - } + spdif = devm_kzalloc(&pdev->dev, sizeof(*spdif), GFP_KERNEL); + if (!spdif) + return -ENOMEM; spdif->is_shutdown = false; dev_set_drvdata(&pdev->dev, spdif); @@ -443,29 +437,25 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev) spdif->clk_pll_a_out0 = devm_clk_get(&pdev->dev, "pll_a_out0"); if (IS_ERR(spdif->clk_pll_a_out0)) { dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n"); - ret = PTR_ERR(spdif->clk_pll_a_out0); - goto err; + return PTR_ERR(spdif->clk_pll_a_out0); } spdif->clk_pll_p_out0 = devm_clk_get(&pdev->dev, "pll_p_out0"); if (IS_ERR(spdif->clk_pll_p_out0)) { dev_err(&pdev->dev, "Can't retrieve pll_p_out0 clock\n"); - ret = PTR_ERR(spdif->clk_pll_p_out0); - goto err; + return PTR_ERR(spdif->clk_pll_p_out0); } spdif->clk_spdif_out = devm_clk_get(&pdev->dev, "spdif_out"); if (IS_ERR(spdif->clk_spdif_out)) { dev_err(&pdev->dev, "Can't retrieve spdif clock\n"); - ret = PTR_ERR(spdif->clk_spdif_out); - goto err; + return PTR_ERR(spdif->clk_spdif_out); } spdif->clk_spdif_in = devm_clk_get(&pdev->dev, "spdif_in"); if (IS_ERR(spdif->clk_spdif_in)) { dev_err(&pdev->dev, "Can't retrieve spdif clock\n"); - ret = PTR_ERR(spdif->clk_spdif_in); - goto err; + return PTR_ERR(spdif->clk_spdif_in); } } @@ -481,79 +471,64 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev) } regcache_cache_only(spdif->regmap, true); - if (of_property_read_u32(np, "nvidia,ahub-spdif-id", - &pdev->dev.id) < 0) { - dev_err(&pdev->dev, - "Missing property nvidia,ahub-spdif-id\n"); - ret = -ENODEV; - goto err; + ret = of_property_read_u32(np, "nvidia,ahub-spdif-id", + &pdev->dev.id); + if (ret < 0) { + dev_err(&pdev->dev, "Missing property nvidia,ahub-spdif-id\n"); + return ret; } pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra210_spdif_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; - } - ret = snd_soc_register_codec(&pdev->dev, &tegra210_spdif_codec, tegra210_spdif_dais, ARRAY_SIZE(tegra210_spdif_dais)); if (ret != 0) { dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); - goto err_suspend; + pm_runtime_disable(&pdev->dev); + return ret; } if (of_property_read_string(np, "prod-name", &prod_name) == 0) { ret = tegra_pinctrl_config_prod(&pdev->dev, prod_name); if (ret < 0) dev_warn(&pdev->dev, "Failed to set %s setting\n", - prod_name); + prod_name); } if (of_property_read_u32(np, "nvidia,is-pinctrl", - &spdif->is_pinctrl) < 0) + &spdif->is_pinctrl) < 0) spdif->is_pinctrl = 0; if (spdif->is_pinctrl) { spdif->pinctrl = devm_pinctrl_get(&pdev->dev); if (IS_ERR(spdif->pinctrl)) { dev_warn(&pdev->dev, "Missing pinctrl device\n"); - goto err_dap; + return 0; } spdif->pin_active_state = pinctrl_lookup_state(spdif->pinctrl, "dap_active"); if (IS_ERR(spdif->pin_active_state)) { dev_dbg(&pdev->dev, "Missing dap-active state\n"); - goto err_dap; + return 0; } spdif->pin_idle_state = pinctrl_lookup_state(spdif->pinctrl, "dap_inactive"); if (IS_ERR(spdif->pin_idle_state)) { dev_dbg(&pdev->dev, "Missing dap-inactive state\n"); - goto err_dap; + return 0; } ret = pinctrl_select_state(spdif->pinctrl, spdif->pin_idle_state); if (ret < 0) { dev_err(&pdev->dev, "setting state failed\n"); - goto err_dap; + return 0; } } -err_dap: return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra210_spdif_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err: - return ret; } static void tegra210_spdif_platform_shutdown(struct platform_device *pdev) diff --git a/sound/soc/tegra-alt/tegra210_xbar_alt.c b/sound/soc/tegra-alt/tegra210_xbar_alt.c index 09525ebc..6d01aff3 100644 --- a/sound/soc/tegra-alt/tegra210_xbar_alt.c +++ b/sound/soc/tegra-alt/tegra210_xbar_alt.c @@ -23,9 +23,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -1338,21 +1336,9 @@ static int tegra186_xbar_registration(struct platform_device *pdev) return -EBUSY; } - ret = pm_runtime_get_sync(&pdev->dev); - if (ret < 0) { - dev_err(&pdev->dev, "pm_runtime_get failed. ret: %d\n", ret); - return ret; - } - of_platform_populate(pdev->dev.of_node, NULL, tegra186_xbar_auxdata, &pdev->dev); - ret = pm_runtime_put_sync(&pdev->dev); - if (ret < 0) { - dev_err(&pdev->dev, "pm_runtime_put failed. ret: %d\n", ret); - return ret; - } - return 0; } @@ -1388,26 +1374,21 @@ static int tegra_dev_xbar_probe(struct platform_device *pdev) { const struct of_device_id *match; struct tegra_xbar_soc_data *soc_data; - int ret; /* required to register the xbar codec with generic name */ if (dev_set_name(&pdev->dev, "%s", DRV_NAME) < 0) { dev_err(&pdev->dev, "error in setting xbar device name\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } match = of_match_device(tegra_xbar_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } soc_data = (struct tegra_xbar_soc_data *)match->data; - ret = tegra_xbar_probe(pdev, soc_data); -err: - return ret; + return tegra_xbar_probe(pdev, soc_data); } static const struct dev_pm_ops tegra_xbar_pm_ops = { diff --git a/sound/soc/tegra-alt/utils/tegra210_xbar_utils_alt.c b/sound/soc/tegra-alt/utils/tegra210_xbar_utils_alt.c index e916fd2e..2d72e8a3 100644 --- a/sound/soc/tegra-alt/utils/tegra210_xbar_utils_alt.c +++ b/sound/soc/tegra-alt/utils/tegra210_xbar_utils_alt.c @@ -23,9 +23,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -305,8 +303,6 @@ int tegra_xbar_remove(struct platform_device *pdev) if (!pm_runtime_status_suspended(&pdev->dev)) tegra_xbar_runtime_suspend(&pdev->dev); - tegra_pd_remove_device(&pdev->dev); - return 0; } EXPORT_SYMBOL_GPL(tegra_xbar_remove); @@ -320,11 +316,8 @@ int tegra_xbar_probe(struct platform_device *pdev, int ret; xbar = devm_kzalloc(&pdev->dev, sizeof(*xbar), GFP_KERNEL); - if (!xbar) { - dev_err(&pdev->dev, "Can't allocate xbar\n"); - ret = -ENOMEM; - goto err; - } + if (!xbar) + return -ENOMEM; xbar->soc_data = soc_data; xbar->is_shutdown = false; @@ -335,44 +328,39 @@ int tegra_xbar_probe(struct platform_device *pdev, xbar->clk = devm_clk_get(&pdev->dev, "ahub"); if (IS_ERR(xbar->clk)) { dev_err(&pdev->dev, "Can't retrieve ahub clock\n"); - ret = PTR_ERR(xbar->clk); - goto err; + return PTR_ERR(xbar->clk); } xbar->clk_parent = devm_clk_get(&pdev->dev, "pll_a_out0"); if (IS_ERR(xbar->clk_parent)) { dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n"); - ret = PTR_ERR(xbar->clk_parent); - goto err; + return PTR_ERR(xbar->clk_parent); } xbar->clk_apb2ape = devm_clk_get(&pdev->dev, "apb2ape"); if (IS_ERR(xbar->clk_apb2ape)) { dev_err(&pdev->dev, "Can't retrieve apb2ape clock\n"); - ret = PTR_ERR(xbar->clk_apb2ape); - goto err; + return PTR_ERR(xbar->clk_apb2ape); } xbar->clk_ape = devm_clk_get(&pdev->dev, "xbar.ape"); if (IS_ERR(xbar->clk_ape)) { dev_err(&pdev->dev, "Can't retrieve ape clock\n"); - ret = PTR_ERR(xbar->clk_ape); - goto err; + return PTR_ERR(xbar->clk_ape); } } parent_clk = clk_get_parent(xbar->clk); if (IS_ERR(parent_clk)) { dev_err(&pdev->dev, "Can't get parent clock for xbar\n"); - ret = PTR_ERR(parent_clk); - goto err; + return PTR_ERR(parent_clk); } if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { ret = clk_set_parent(xbar->clk, xbar->clk_parent); if (ret) { dev_err(&pdev->dev, "Failed to set parent clock with pll_a_out0\n"); - goto err; + return ret; } } @@ -388,29 +376,14 @@ int tegra_xbar_probe(struct platform_device *pdev, } regcache_cache_only(xbar->regmap, true); - tegra_pd_add_device(&pdev->dev); - pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra_xbar_runtime_resume(&pdev->dev); - if (ret) - goto err_pm_disable; + ret = soc_data->xbar_registration(pdev); + if (ret) { + pm_runtime_disable(&pdev->dev); + return ret; } - ret = soc_data->xbar_registration(pdev); - if (ret == -EBUSY) - goto err_suspend; - return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra_xbar_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); - tegra_pd_remove_device(&pdev->dev); -err: - return ret; } EXPORT_SYMBOL_GPL(tegra_xbar_probe); MODULE_LICENSE("GPL");