From: Thierry Reding <tred...@nvidia.com>

Registering as memory controller allows other drivers to obtain a
reference to it. This is mostly useful as a way of ordering probe
between devices depending on one another.

Signed-off-by: Thierry Reding <tred...@nvidia.com>
---
 drivers/memory/tegra/tegra186.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/tegra/tegra186.c b/drivers/memory/tegra/tegra186.c
index 5d53f11ca7b6..8c43702340e8 100644
--- a/drivers/memory/tegra/tegra186.c
+++ b/drivers/memory/tegra/tegra186.c
@@ -4,6 +4,7 @@
  */
 
 #include <linux/io.h>
+#include <linux/memory-controller.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/of_device.h>
@@ -32,6 +33,7 @@ struct tegra186_mc_soc {
 };
 
 struct tegra186_mc {
+       struct memory_controller base;
        struct device *dev;
        void __iomem *regs;
 
@@ -1532,13 +1534,18 @@ static int tegra186_mc_probe(struct platform_device 
*pdev)
                return -ENOMEM;
 
        mc->soc = of_device_get_match_data(&pdev->dev);
+       mc->dev = &pdev->dev;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        mc->regs = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(mc->regs))
                return PTR_ERR(mc->regs);
 
-       mc->dev = &pdev->dev;
+       mc->base.dev = &pdev->dev;
+
+       err = memory_controller_register(&mc->base);
+       if (err < 0)
+               return err;
 
        err = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
        if (err < 0)
-- 
2.24.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to