net: hns: use device_* APIs instead of of_* APIs
authorKejian Yan <yankejian@huawei.com>
Fri, 3 Jun 2016 02:55:13 +0000 (10:55 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 5 Jun 2016 01:32:40 +0000 (21:32 -0400)
OF series functions can be used only for DT case. Use unified
device property function instead to support both DT and ACPI.

Signed-off-by: Kejian Yan <yankejian@huawei.com>
Signed-off-by: Yisen Zhuang <Yisen.Zhuang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
drivers/net/ethernet/hisilicon/hns/hns_enet.c

index 1c2ddb25e77688cf6617d48ff73ad37db9f86c96..9afc5e665985a31c9496a6fd775843f592334848 100644 (file)
@@ -50,7 +50,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
        else
                dsaf_dev->dsaf_ver = AE_VERSION_2;
 
-       ret = of_property_read_string(np, "mode", &mode_str);
+       ret = device_property_read_string(dsaf_dev->dev, "mode", &mode_str);
        if (ret) {
                dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
                return ret;
@@ -142,7 +142,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
                }
        }
 
-       ret = of_property_read_u32(np, "desc-num", &desc_num);
+       ret = device_property_read_u32(dsaf_dev->dev, "desc-num", &desc_num);
        if (ret < 0 || desc_num < HNS_DSAF_MIN_DESC_CNT ||
            desc_num > HNS_DSAF_MAX_DESC_CNT) {
                dev_err(dsaf_dev->dev, "get desc-num(%d) fail, ret=%d!\n",
@@ -151,14 +151,15 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
        }
        dsaf_dev->desc_num = desc_num;
 
-       ret = of_property_read_u32(np, "reset-field-offset", &reset_offset);
+       ret = device_property_read_u32(dsaf_dev->dev, "reset-field-offset",
+                                      &reset_offset);
        if (ret < 0) {
                dev_dbg(dsaf_dev->dev,
                        "get reset-field-offset fail, ret=%d!\r\n", ret);
        }
        dsaf_dev->reset_offset = reset_offset;
 
-       ret = of_property_read_u32(np, "buf-size", &buf_size);
+       ret = device_property_read_u32(dsaf_dev->dev, "buf-size", &buf_size);
        if (ret < 0) {
                dev_err(dsaf_dev->dev,
                        "get buf-size fail, ret=%d!\r\n", ret);
index e621636e69b9e6b1f45a682e67027f1fb0003d21..8851420567505481dfd3435b463f556a24eefdb9 100644 (file)
@@ -1067,13 +1067,8 @@ void hns_nic_update_stats(struct net_device *netdev)
 static void hns_init_mac_addr(struct net_device *ndev)
 {
        struct hns_nic_priv *priv = netdev_priv(ndev);
-       struct device_node *node = priv->dev->of_node;
-       const void *mac_addr_temp;
 
-       mac_addr_temp = of_get_mac_address(node);
-       if (mac_addr_temp && is_valid_ether_addr(mac_addr_temp)) {
-               memcpy(ndev->dev_addr, mac_addr_temp, ndev->addr_len);
-       } else {
+       if (!device_get_mac_address(priv->dev, ndev->dev_addr, ETH_ALEN)) {
                eth_hw_addr_random(ndev);
                dev_warn(priv->dev, "No valid mac, use random mac %pM",
                         ndev->dev_addr);
@@ -1898,10 +1893,10 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
                goto out_read_prop_fail;
        }
        /* try to find port-idx-in-ae first */
-       ret = of_property_read_u32(node, "port-idx-in-ae", &port_id);
+       ret = device_property_read_u32(dev, "port-idx-in-ae", &port_id);
        if (ret) {
                /* only for old code compatible */
-               ret = of_property_read_u32(node, "port-id", &port_id);
+               ret = device_property_read_u32(dev, "port-id", &port_id);
                if (ret)
                        goto out_read_prop_fail;
                /* for old dts, we need to caculate the port offset */