lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190924181244.7159-3-nsaenzjulienne@suse.de>
Date:   Tue, 24 Sep 2019 20:12:33 +0200
From:   Nicolas Saenz Julienne <nsaenzjulienne@...e.de>
To:     robh+dt@...nel.org, devicetree@...r.kernel.org,
        frowand.list@...il.com, linux-arm-kernel@...ts.infradead.org,
        linux-wireless@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-msm@...r.kernel.org, dmaengine@...r.kernel.org,
        etnaviv@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
        xen-devel@...ts.xenproject.org, linux-tegra@...r.kernel.org,
        linux-media@...r.kernel.org, linux-pci@...r.kernel.org
Cc:     mbrugger@...e.com, robin.murphy@....com, f.fainelli@...il.com,
        james.quinlan@...adcom.com, wahrenst@....net,
        Nicolas Saenz Julienne <nsaenzjulienne@...e.de>
Subject: [PATCH 02/11] of: base: introduce __of_n_*_cells_parent()

Master PCI devices might not appear in the device tree, yet they still
need to get the underlying cells properties in order to calculate the
bus DMA constraints. This conflicts with of_n_*_cells() as it's designed
under the assumption it'll receive a device OF node.

Create __of_n_*_cells_parent() in order to deal with this limitation.
For now, it'll only be available privately to OF code.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@...e.de>
---

 drivers/of/base.c       | 44 +++++++++++++++++++++++++++++------------
 drivers/of/of_private.h |  3 +++
 2 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 1d667eb730e1..94f83051910c 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -86,34 +86,52 @@ static bool __of_node_is_type(const struct device_node *np, const char *type)
 	return np && match && type && !strcmp(match, type);
 }
 
-int of_n_addr_cells(struct device_node *np)
+int __of_n_addr_cells_parent(struct device_node *parent)
 {
 	u32 cells;
 
-	do {
-		if (np->parent)
-			np = np->parent;
-		if (!of_property_read_u32(np, "#address-cells", &cells))
+	while (parent) {
+		if (!of_property_read_u32(parent, "#address-cells", &cells))
 			return cells;
-	} while (np->parent);
+
+		parent = parent->parent;
+	}
+
 	/* No #address-cells property for the root node */
 	return OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
 }
+
+int of_n_addr_cells(struct device_node *np)
+{
+	if (np->parent)
+		np = np->parent;
+
+	return __of_n_addr_cells_parent(np);
+}
 EXPORT_SYMBOL(of_n_addr_cells);
 
-int of_n_size_cells(struct device_node *np)
+int __of_n_size_cells_parent(struct device_node *parent)
 {
 	u32 cells;
 
-	do {
-		if (np->parent)
-			np = np->parent;
-		if (!of_property_read_u32(np, "#size-cells", &cells))
+	while (parent) {
+		if (!of_property_read_u32(parent, "#size-cells", &cells))
 			return cells;
-	} while (np->parent);
-	/* No #size-cells property for the root node */
+
+		parent = parent->parent;
+	}
+
+	/* No #address-cells property for the root node */
 	return OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
 }
+
+int of_n_size_cells(struct device_node *np)
+{
+	if (np->parent)
+		np = np->parent;
+
+	return __of_n_size_cells_parent(np);
+}
 EXPORT_SYMBOL(of_n_size_cells);
 
 #ifdef CONFIG_NUMA
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 24786818e32e..b528304be244 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -39,6 +39,9 @@ extern struct mutex of_mutex;
 extern struct list_head aliases_lookup;
 extern struct kset *of_kset;
 
+int __of_n_addr_cells_parent(struct device_node *parent);
+int __of_n_size_cells_parent(struct device_node *parent);
+
 #if defined(CONFIG_OF_DYNAMIC)
 extern int of_property_notify(int action, struct device_node *np,
 			      struct property *prop, struct property *old_prop);
-- 
2.23.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ