ASoC: tegra-alt: Set device data before initialising RPM

The device data for a given driver must be set before enabling
runtime-pm otherwise this could results in a crash if the runtime-pm
callback is called before the device data is set where it is expected
that the device data has been initialised.

Furthermore, most drivers will directly call the runtime-pm callback
to power-up the device if runtime-pm is not enabled in the kernel
config and so many drivers would crash if runtime-pm is not enabled.

Fix this by setting the device data early in the driver probe.

Bug 2478690

Change-Id: I5beb1607aa4715651cf4b9ac8e8068e7f8e3a2a7
Signed-off-by: Jonathan Hunter <jonathanh@nvidia.com>
(cherry picked from commit 9d656fcc96e85d38d120a430f83f2b734e19fe07)
Reviewed-on: https://git-master.nvidia.com/r/1991204
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jonathan Hunter
2019-01-04 10:16:18 +00:00
committed by Sameer Pujar
parent 5e0682c2e7
commit eabaeedaa6
12 changed files with 27 additions and 39 deletions

View File

@@ -1,7 +1,7 @@
/* /*
* tegra186_arad_alt.c - Tegra186 ARAD driver * tegra186_arad_alt.c - Tegra186 ARAD driver
* *
* Copyright (c) 2015-2018, NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2015-2019, NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -799,9 +799,10 @@ static int tegra186_arad_platform_probe(struct platform_device *pdev)
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
} }
arad_dev = &pdev->dev;
arad_dev = &pdev->dev;
arad->soc_data = soc_data; arad->soc_data = soc_data;
dev_set_drvdata(&pdev->dev, arad);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) { if (!mem) {
@@ -862,8 +863,6 @@ static int tegra186_arad_platform_probe(struct platform_device *pdev)
TEGRA186_AHC_ARAD1_CB, &pdev->dev); TEGRA186_AHC_ARAD1_CB, &pdev->dev);
#endif #endif
#endif #endif
dev_set_drvdata(&pdev->dev, arad);
return 0; return 0;
err_suspend: err_suspend:

View File

@@ -1,7 +1,7 @@
/* /*
* tegra186_asrc_alt.c - Tegra186 ASRC driver * tegra186_asrc_alt.c - Tegra186 ASRC driver
* *
* Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2015-2019, NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -1142,6 +1142,7 @@ static int tegra186_asrc_platform_probe(struct platform_device *pdev)
asrc->soc_data = soc_data; asrc->soc_data = soc_data;
asrc->is_shutdown = false; asrc->is_shutdown = false;
dev_set_drvdata(&pdev->dev, asrc);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) { if (!mem) {
@@ -1220,8 +1221,6 @@ static int tegra186_asrc_platform_probe(struct platform_device *pdev)
goto err_suspend; goto err_suspend;
} }
dev_set_drvdata(&pdev->dev, asrc);
return 0; return 0;
err_suspend: err_suspend:

View File

@@ -1,7 +1,7 @@
/* /*
* tegra210_admaif_alt.c - Tegra ADMAIF driver * tegra210_admaif_alt.c - Tegra ADMAIF driver
* *
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2014-2019 NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -1135,9 +1135,9 @@ static int tegra_admaif_probe(struct platform_device *pdev)
admaif->refcnt = 0; admaif->refcnt = 0;
admaif->dev = &pdev->dev; admaif->dev = &pdev->dev;
admaif->soc_data = (struct tegra_admaif_soc_data *)match->data; admaif->soc_data = (struct tegra_admaif_soc_data *)match->data;
admaif->is_shutdown = false; admaif->is_shutdown = false;
dev_set_drvdata(&pdev->dev, admaif);
admaif->capture_dma_data = devm_kzalloc(&pdev->dev, admaif->capture_dma_data = devm_kzalloc(&pdev->dev,
sizeof(struct tegra_alt_pcm_dma_params) * sizeof(struct tegra_alt_pcm_dma_params) *
@@ -1300,9 +1300,6 @@ static int tegra_admaif_probe(struct platform_device *pdev)
goto err_unregister_codec; goto err_unregister_codec;
} }
/* Driver data should be set before any reg r/w operation */
dev_set_drvdata(&pdev->dev, admaif);
regmap_update_bits(admaif->regmap, regmap_update_bits(admaif->regmap,
admaif->soc_data->reg_offsets.global_enable, 1, 1); admaif->soc_data->reg_offsets.global_enable, 1, 1);

View File

@@ -1,7 +1,7 @@
/* /*
* tegra210_adx_alt.c - Tegra210 ADX driver * tegra210_adx_alt.c - Tegra210 ADX driver
* *
* Copyright (c) 2014-2017 NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2014-2019 NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -653,6 +653,7 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
adx->soc_data = soc_data; adx->soc_data = soc_data;
adx->is_shutdown = false; adx->is_shutdown = false;
dev_set_drvdata(&pdev->dev, adx);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) { if (!mem) {
@@ -709,8 +710,6 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
goto err_suspend; goto err_suspend;
} }
dev_set_drvdata(&pdev->dev, adx);
return 0; return 0;
err_suspend: err_suspend:

View File

@@ -1,7 +1,7 @@
/* /*
* tegra210_amx_alt.c - Tegra210 AMX driver * tegra210_amx_alt.c - Tegra210 AMX driver
* *
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2014-2019 NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -932,6 +932,7 @@ static int tegra210_amx_platform_probe(struct platform_device *pdev)
amx->is_shutdown = false; amx->is_shutdown = false;
memset(amx->map, 0, sizeof(amx->map)); memset(amx->map, 0, sizeof(amx->map));
memset(amx->byte_mask, 0, sizeof(amx->byte_mask)); memset(amx->byte_mask, 0, sizeof(amx->byte_mask));
dev_set_drvdata(&pdev->dev, amx);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) { if (!mem) {
@@ -995,8 +996,6 @@ static int tegra210_amx_platform_probe(struct platform_device *pdev)
goto err_suspend; goto err_suspend;
} }
dev_set_drvdata(&pdev->dev, amx);
return 0; return 0;
err_suspend: err_suspend:

View File

@@ -1,7 +1,7 @@
/* /*
* tegra210_dmic_alt.c - Tegra210 DMIC driver * tegra210_dmic_alt.c - Tegra210 DMIC driver
* *
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2014-2019 NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -703,6 +703,7 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
dmic->soc_data = soc_data; dmic->soc_data = soc_data;
dmic->is_shutdown = false; dmic->is_shutdown = false;
dmic->prod_name = NULL; dmic->prod_name = NULL;
dev_set_drvdata(&pdev->dev, dmic);
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
dmic->clk_dmic = devm_clk_get(&pdev->dev, NULL); dmic->clk_dmic = devm_clk_get(&pdev->dev, NULL);
@@ -826,8 +827,6 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
} }
err_dap: err_dap:
dev_set_drvdata(&pdev->dev, dmic);
pdev_bkp[pdev->dev.id] = pdev; pdev_bkp[pdev->dev.id] = pdev;
return 0; return 0;

View File

@@ -1,7 +1,7 @@
/* /*
* tegra210_i2s.c - Tegra210 I2S driver * tegra210_i2s.c - Tegra210 I2S driver
* *
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2014-2019 NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -1098,6 +1098,7 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
i2s->loopback = 0; i2s->loopback = 0;
i2s->is_shutdown = false; i2s->is_shutdown = false;
i2s->prod_name = NULL; i2s->prod_name = NULL;
dev_set_drvdata(&pdev->dev, i2s);
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
i2s->clk_i2s = devm_clk_get(&pdev->dev, NULL); i2s->clk_i2s = devm_clk_get(&pdev->dev, NULL);
@@ -1261,8 +1262,6 @@ err_dap:
goto err_suspend; goto err_suspend;
} }
dev_set_drvdata(&pdev->dev, i2s);
return 0; return 0;
err_suspend: err_suspend:

View File

@@ -1,7 +1,7 @@
/* /*
* tegra210_iqc.c - Tegra210 IQC driver * tegra210_iqc.c - Tegra210 IQC driver
* *
* Copyright (c) 2014-2017 NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2014-2019 NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -347,6 +347,7 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev)
} }
iqc->soc_data = soc_data; iqc->soc_data = soc_data;
dev_set_drvdata(&pdev->dev, iqc);
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
iqc->clk_iqc = devm_clk_get(&pdev->dev, NULL); iqc->clk_iqc = devm_clk_get(&pdev->dev, NULL);
@@ -428,8 +429,6 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev)
goto err_suspend; goto err_suspend;
} }
dev_set_drvdata(&pdev->dev, iqc);
return 0; return 0;
err_suspend: err_suspend:

View File

@@ -1,7 +1,7 @@
/* /*
* tegra210_mixer_alt.c - Tegra210 MIXER driver * tegra210_mixer_alt.c - Tegra210 MIXER driver
* *
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2014-2019 NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -750,6 +750,7 @@ static int tegra210_mixer_platform_probe(struct platform_device *pdev)
mixer->gain_coeff[11] = 0; mixer->gain_coeff[11] = 0;
mixer->gain_coeff[12] = 0x400; mixer->gain_coeff[12] = 0x400;
mixer->gain_coeff[13] = 0x8000000; mixer->gain_coeff[13] = 0x8000000;
dev_set_drvdata(&pdev->dev, mixer);
for (i = 0; i < TEGRA210_MIXER_AXBAR_RX_MAX; i++) for (i = 0; i < TEGRA210_MIXER_AXBAR_RX_MAX; i++)
mixer->gain_value[i] = 0x10000; mixer->gain_value[i] = 0x10000;
@@ -809,8 +810,6 @@ static int tegra210_mixer_platform_probe(struct platform_device *pdev)
goto err_suspend; goto err_suspend;
} }
dev_set_drvdata(&pdev->dev, mixer);
return 0; return 0;
err_suspend: err_suspend:

View File

@@ -1,7 +1,7 @@
/* /*
* tegra210_mvc_alt.c - Tegra210 MVC driver * tegra210_mvc_alt.c - Tegra210 MVC driver
* *
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2014-2019 NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -674,6 +674,7 @@ static int tegra210_mvc_platform_probe(struct platform_device *pdev)
mvc->soc_data = soc_data; mvc->soc_data = soc_data;
mvc->is_shutdown = false; mvc->is_shutdown = false;
dev_set_drvdata(&pdev->dev, mvc);
mvc->poly_n1 = 16; mvc->poly_n1 = 16;
mvc->poly_n2 = 63; mvc->poly_n2 = 63;
@@ -746,8 +747,6 @@ static int tegra210_mvc_platform_probe(struct platform_device *pdev)
goto err_suspend; goto err_suspend;
} }
dev_set_drvdata(&pdev->dev, mvc);
return 0; return 0;
err_suspend: err_suspend:

View File

@@ -1,7 +1,7 @@
/* /*
* tegra210_sfc_alt.c - Tegra210 SFC driver * tegra210_sfc_alt.c - Tegra210 SFC driver
* *
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2014-2019 NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -899,6 +899,8 @@ static int tegra210_sfc_platform_probe(struct platform_device *pdev)
/* initialize default output srate */ /* initialize default output srate */
sfc->srate_out = TEGRA210_SFC_FS48; sfc->srate_out = TEGRA210_SFC_FS48;
dev_set_drvdata(&pdev->dev, sfc);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) { if (!mem) {
dev_err(&pdev->dev, "No memory resource\n"); dev_err(&pdev->dev, "No memory resource\n");
@@ -954,8 +956,6 @@ static int tegra210_sfc_platform_probe(struct platform_device *pdev)
goto err_suspend; goto err_suspend;
} }
dev_set_drvdata(&pdev->dev, sfc);
return 0; return 0;
err_suspend: err_suspend:

View File

@@ -1,7 +1,7 @@
/* /*
* tegra210_spdif_alt.c - Tegra210 SPDIF driver * tegra210_spdif_alt.c - Tegra210 SPDIF driver
* *
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2014-2019 NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -479,6 +479,8 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev)
spdif->soc_data = soc_data; spdif->soc_data = soc_data;
spdif->is_shutdown = false; spdif->is_shutdown = false;
dev_set_drvdata(&pdev->dev, spdif);
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
spdif->clk_pll_a_out0 = devm_clk_get(&pdev->dev, "pll_a_out0"); spdif->clk_pll_a_out0 = devm_clk_get(&pdev->dev, "pll_a_out0");
if (IS_ERR(spdif->clk_pll_a_out0)) { if (IS_ERR(spdif->clk_pll_a_out0)) {
@@ -604,8 +606,6 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev)
} }
err_dap: err_dap:
dev_set_drvdata(&pdev->dev, spdif);
return 0; return 0;
err_suspend: err_suspend: