summaryrefslogtreecommitdiffstats
path: root/drivers/memory/tegra/tegra124-emc.c
diff options
context:
space:
mode:
authorDmitry Osipenko <digetx@gmail.com>2020-11-04 17:49:04 +0100
committerKrzysztof Kozlowski <krzk@kernel.org>2020-11-26 18:50:29 +0100
commit6c6bd2075f01f8c8ae4bc803ba5cd23a3d3db533 (patch)
tree0d84c1b81d5a71b5a6d4847df251477be329aeec /drivers/memory/tegra/tegra124-emc.c
parentMerge tag 'tegra-soc-clk-drivers-5.11' into for-v5.11/tegra-mc (diff)
downloadlinux-6c6bd2075f01f8c8ae4bc803ba5cd23a3d3db533.tar.xz
linux-6c6bd2075f01f8c8ae4bc803ba5cd23a3d3db533.zip
memory: tegra: Add and use devm_tegra_memory_controller_get()
Multiple Tegra drivers need to retrieve Memory Controller and there is duplication of the retrieval code among the drivers. Add new devm_tegra_memory_controller_get() helper to remove the code's duplication and to fix put_device() which was missed in the duplicated code. Make EMC drivers to use the new helper. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Link: https://lore.kernel.org/r/20201104164923.21238-29-digetx@gmail.com Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Diffstat (limited to 'drivers/memory/tegra/tegra124-emc.c')
-rw-r--r--drivers/memory/tegra/tegra124-emc.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/drivers/memory/tegra/tegra124-emc.c b/drivers/memory/tegra/tegra124-emc.c
index 76ace42a688a..35dbceb7f841 100644
--- a/drivers/memory/tegra/tegra124-emc.c
+++ b/drivers/memory/tegra/tegra124-emc.c
@@ -1177,7 +1177,6 @@ static void emc_debugfs_init(struct device *dev, struct tegra_emc *emc)
static int tegra_emc_probe(struct platform_device *pdev)
{
- struct platform_device *mc;
struct device_node *np;
struct tegra_emc *emc;
struct resource *res;
@@ -1195,20 +1194,9 @@ static int tegra_emc_probe(struct platform_device *pdev)
if (IS_ERR(emc->regs))
return PTR_ERR(emc->regs);
- np = of_parse_phandle(pdev->dev.of_node, "nvidia,memory-controller", 0);
- if (!np) {
- dev_err(&pdev->dev, "could not get memory controller\n");
- return -ENOENT;
- }
-
- mc = of_find_device_by_node(np);
- of_node_put(np);
- if (!mc)
- return -ENOENT;
-
- emc->mc = platform_get_drvdata(mc);
- if (!emc->mc)
- return -EPROBE_DEFER;
+ emc->mc = devm_tegra_memory_controller_get(&pdev->dev);
+ if (IS_ERR(emc->mc))
+ return PTR_ERR(emc->mc);
ram_code = tegra_read_ram_code();