diff mbox series

[v6,34/52] memory: tegra20-emc: Don't parse emc-stats node

Message ID 20201025221735.3062-35-digetx@gmail.com
State New
Headers show
Series [v6,01/52] clk: tegra: Export Tegra20 EMC kernel symbols | expand

Commit Message

Dmitry Osipenko Oct. 25, 2020, 10:17 p.m. UTC
EMC device-tree node now contains new emc-stats sub-node which needs to
be skipped when timing nodes are parsed by EMC driver, otherwise driver
will try to parse the emc-stats as a timing node and will error out.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/memory/tegra/tegra20-emc.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/memory/tegra/tegra20-emc.c b/drivers/memory/tegra/tegra20-emc.c
index 69ccb3fe5b0b..27242659dfd6 100644
--- a/drivers/memory/tegra/tegra20-emc.c
+++ b/drivers/memory/tegra/tegra20-emc.c
@@ -349,7 +349,10 @@  static int tegra_emc_load_timings_from_dt(struct tegra_emc *emc,
 	int child_count;
 	int err;
 
-	child_count = of_get_child_count(node);
+	child = of_find_node_by_name(node, "emc-stats");
+	of_node_put(child);
+
+	child_count = of_get_child_count(node) - (child ? 1 : 0);
 	if (!child_count) {
 		dev_err(emc->dev, "no memory timings in DT node: %pOF\n", node);
 		return -EINVAL;
@@ -364,6 +367,9 @@  static int tegra_emc_load_timings_from_dt(struct tegra_emc *emc,
 	timing = emc->timings;
 
 	for_each_child_of_node(node, child) {
+		if (of_device_is_compatible(child, "nvidia,tegra20-emc-statistics"))
+			continue;
+
 		err = load_one_timing_from_dt(emc, timing++, child);
 		if (err) {
 			of_node_put(child);
@@ -391,7 +397,11 @@  tegra_emc_find_node_by_ram_code(struct device *dev)
 	u32 value, ram_code;
 	int err;
 
-	if (of_get_child_count(dev->of_node) == 0) {
+	/* old device-trees don't have emc-stats node */
+	np = of_find_node_by_name(dev->of_node, "emc-stats");
+	of_node_put(np);
+
+	if (of_get_child_count(dev->of_node) == (np ? 1 : 0)) {
 		dev_info(dev, "device-tree doesn't have memory timings\n");
 		return NULL;
 	}