Skip to contentSkip to conversation

net: octeontx: smi: use dt live tree API

PATCH In review Tim Harvey 2 participants 3 messages Jun 17, 2021 – Jun 18, 2021 Network drivers

lore
Share & tools
lore

Tim Harvey

author
#0 lore raw

PATCH v2 1/1 net: octeontx: smi: use dt live tree API

clean up octeontx_smi_probe by using the live-tree API.

---
v2: added reviewed-by tag

---
 drivers/net/octeontx/smi.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/net/octeontx/smi.c +11 -13
index 27f4423c6a..d70fa820c7 100644
@@ -314,10 +314,12 @@ read_error:
 
 int octeontx_smi_probe(struct udevice *dev)
 {
-	int ret, subnode, cnt = 0, node = dev_ofnode(dev).of_offset;
-	struct mii_dev *bus;
-	struct octeontx_smi_priv *priv;
 	pci_dev_t bdf = dm_pci_get_bdf(dev);
+	struct octeontx_smi_priv *priv;
+	struct mii_dev *bus;
+	int ret, cnt = 0;
+	ofnode subnode;
+	u64 baseaddr;
 
 	debug("SMI PCI device: %x\n", bdf);
 	if (!dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM)) {
@@ -325,14 +327,12 @@ int octeontx_smi_probe(struct udevice *dev)
 		return -1;
 	}
 
-	node = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
-					     "cavium,thunder-8890-mdio-nexus");
-	fdt_for_each_subnode(subnode, gd->fdt_blob, node) {
-		ret = fdt_node_check_compatible(gd->fdt_blob, subnode,
-						"cavium,thunder-8890-mdio");
-		if (ret)
+	dev_for_each_subnode(subnode, dev) {
+		if (!ofnode_device_is_compatible(subnode,
+						 "cavium,thunder-8890-mdio"))
+			continue;
+		if (ofnode_read_u64(subnode, "reg", &baseaddr))
 			continue;
-
 		bus = mdio_alloc();
 		priv = malloc(sizeof(*priv));
 		if (!bus || !priv) {
@@ -347,9 +347,7 @@ int octeontx_smi_probe(struct udevice *dev)
 		bus->priv = priv;
 
 		priv->mode = CLAUSE22;
-		priv->baseaddr = (void __iomem *)fdtdec_get_addr(gd->fdt_blob,
-								 subnode,
-								 "reg");
+		priv->baseaddr = (void __iomem *)baseaddr;
 		debug("mdio base addr %p\n", priv->baseaddr);
 
 		/* use given name or generate its own unique name */
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 63 lines · Tim Harvey

clean up octeontx_smi_probe by using the live-tree API.

---
v2: added reviewed-by tag

---
 drivers/net/octeontx/smi.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/net/octeontx/smi.c +11 -14
index 27f4423c6a..d70fa820c7 100644
@@ -314,10 +314,12 @@ read_error:
 
 int octeontx_smi_probe(struct udevice *dev)
 {
-       int ret, subnode, cnt = 0, node = dev_ofnode(dev).of_offset;
-       struct mii_dev *bus;
-       struct octeontx_smi_priv *priv;
        pci_dev_t bdf = dm_pci_get_bdf(dev);
+       struct octeontx_smi_priv *priv;
+       struct mii_dev *bus;
+       int ret, cnt = 0;
+       ofnode subnode;
+       u64 baseaddr;
 
        debug("SMI PCI device: %x\n", bdf);
        if (!dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM)) {
@@ -325,14 +327,12 @@ int octeontx_smi_probe(struct udevice *dev)
                return -1;
        }
 
-       node = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
-                                            "cavium,thunder-8890-mdio-nexus");
-       fdt_for_each_subnode(subnode, gd->fdt_blob, node) {
-               ret = fdt_node_check_compatible(gd->fdt_blob, subnode,
-                                               "cavium,thunder-8890-mdio");
-               if (ret)
+       dev_for_each_subnode(subnode, dev) {
+               if (!ofnode_device_is_compatible(subnode,
+                                                "cavium,thunder-8890-mdio"))
+                       continue;
+               if (ofnode_read_u64(subnode, "reg", &baseaddr))
                        continue;
-
                bus = mdio_alloc();
                priv = malloc(sizeof(*priv));
                if (!bus || !priv) {
@@ -347,9 +347,7 @@ int octeontx_smi_probe(struct udevice *dev)
                bus->priv = priv;
 
                priv->mode = CLAUSE22;
-               priv->baseaddr = (void __iomem *)fdtdec_get_addr(gd->fdt_blob,
-                                                                subnode,
-                                                                "reg");
+               priv->baseaddr = (void __iomem *)baseaddr;
                debug("mdio base addr %p\n", priv->baseaddr);
 
                /* use given name or generate its own unique name */
--
Quoted 2 lines

2.17.1

#2 lore raw
Quoted 63 lines · Ramon Fried
Quoted 61 lines · Tim Harvey

clean up octeontx_smi_probe by using the live-tree API.

---
v2: added reviewed-by tag

---
 drivers/net/octeontx/smi.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/net/octeontx/smi.c +11 -13
index 27f4423c6a..d70fa820c7 100644
@@ -314,10 +314,12 @@ read_error:
 
 int octeontx_smi_probe(struct udevice *dev)
 {
-       int ret, subnode, cnt = 0, node = dev_ofnode(dev).of_offset;
-       struct mii_dev *bus;
-       struct octeontx_smi_priv *priv;
        pci_dev_t bdf = dm_pci_get_bdf(dev);
+       struct octeontx_smi_priv *priv;
+       struct mii_dev *bus;
+       int ret, cnt = 0;
+       ofnode subnode;
+       u64 baseaddr;
 
        debug("SMI PCI device: %x\n", bdf);
        if (!dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM)) {
@@ -325,14 +327,12 @@ int octeontx_smi_probe(struct udevice *dev)
                return -1;
        }
 
-       node = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
-                                            "cavium,thunder-8890-mdio-nexus");
-       fdt_for_each_subnode(subnode, gd->fdt_blob, node) {
-               ret = fdt_node_check_compatible(gd->fdt_blob, subnode,
-                                               "cavium,thunder-8890-mdio");
-               if (ret)
+       dev_for_each_subnode(subnode, dev) {
+               if (!ofnode_device_is_compatible(subnode,
+                                                "cavium,thunder-8890-mdio"))
+                       continue;
+               if (ofnode_read_u64(subnode, "reg", &baseaddr))
                        continue;
-
                bus = mdio_alloc();
                priv = malloc(sizeof(*priv));
                if (!bus || !priv) {
@@ -347,9 +347,7 @@ int octeontx_smi_probe(struct udevice *dev)
                bus->priv = priv;
 
                priv->mode = CLAUSE22;
-               priv->baseaddr = (void __iomem *)fdtdec_get_addr(gd->fdt_blob,
-                                                                subnode,
-                                                                "reg");
+               priv->baseaddr = (void __iomem *)baseaddr;
                debug("mdio base addr %p\n", priv->baseaddr);
 
Quoted 5 lines
Quoted 4 lines
drivers/net/octeontx/smi.c +0 -1
                /* use given name or generate its own unique name */
--

2.17.1

applied to u-boot-net/master, thanks!

Best regards,
Ramon Fried