dm: core: Access device ofnode through functions
[platform/kernel/u-boot.git] / net / mdio-uclass.c
index f75e4df..697e5f8 100644 (file)
@@ -6,9 +6,13 @@
 
 #include <common.h>
 #include <dm.h>
+#include <log.h>
+#include <malloc.h>
 #include <miiphy.h>
 #include <dm/device-internal.h>
+#include <dm/device_compat.h>
 #include <dm/uclass-internal.h>
+#include <linux/compat.h>
 
 /* DT node properties for MAC-PHY interface */
 #define PHY_MODE_STR_CNT       2
@@ -36,8 +40,8 @@ static int dm_mdio_post_bind(struct udevice *dev)
        const char *dt_name;
 
        /* set a custom name for the MDIO device, if present in DT */
-       if (ofnode_valid(dev->node)) {
-               dt_name = ofnode_read_string(dev->node, "device-name");
+       if (dev_has_ofnode(dev)) {
+               dt_name = dev_read_string(dev, "device-name");
                if (dt_name) {
                        debug("renaming dev %s to %s\n", dev->name, dt_name);
                        device_set_name(dev, dt_name);
@@ -141,7 +145,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,
                        break;
 
        if (!ofnode_valid(phandle.node)) {
-               dev_dbg(dev, "can't find PHY node\n");
+               dev_dbg(ethdev, "can't find PHY node\n");
                return NULL;
        }
 
@@ -157,7 +161,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,
        if (uclass_get_device_by_ofnode(UCLASS_MDIO,
                                        ofnode_get_parent(phandle.node),
                                        &mdiodev)) {
-               dev_dbg(dev, "can't find MDIO bus for node %s\n",
+               dev_dbg(ethdev, "can't find MDIO bus for node %s\n",
                        ofnode_get_name(ofnode_get_parent(phandle.node)));
                return NULL;
        }
@@ -178,14 +182,14 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
        struct phy_device *phy;
        int i;
 
-       if (!ofnode_valid(ethdev->node)) {
+       if (!dev_has_ofnode(ethdev)) {
                debug("%s: supplied eth dev has no DT node!\n", ethdev->name);
                return NULL;
        }
 
        interface = PHY_INTERFACE_MODE_NONE;
        for (i = 0; i < PHY_MODE_STR_CNT; i++) {
-               if_str = ofnode_read_string(ethdev->node, phy_mode_str[i]);
+               if_str = dev_read_string(ethdev, phy_mode_str[i]);
                if (if_str) {
                        interface = phy_get_interface_by_name(if_str);
                        break;
@@ -212,5 +216,5 @@ UCLASS_DRIVER(mdio) = {
        .post_bind  = dm_mdio_post_bind,
        .post_probe = dm_mdio_post_probe,
        .pre_remove = dm_mdio_pre_remove,
-       .per_device_auto_alloc_size = sizeof(struct mdio_perdev_priv),
+       .per_device_auto        = sizeof(struct mdio_perdev_priv),
 };