700-allocate_interface_by_label.patch 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From: Roman Kuzmitskii <[email protected]>
  2. Date: Wed, 28 Oct 2020 19:00:00 +0000
  3. Subject: [PATCH] staging: octeon: add net-labels support
  4. With this patch, device name can be set within dts file
  5. in the same way as dsa port can.
  6. Add label to pip interface node to use this feature:
  7. label = "lan0";
  8. Tested-by: Johannes Kimmel <[email protected]>
  9. Signed-off-by: Roman Kuzmitskii <[email protected]>
  10. --- a/drivers/staging/octeon/ethernet.c
  11. +++ b/drivers/staging/octeon/ethernet.c
  12. @@ -407,8 +407,12 @@ static int cvm_oct_common_set_mac_addres
  13. int cvm_oct_common_init(struct net_device *dev)
  14. {
  15. struct octeon_ethernet *priv = netdev_priv(dev);
  16. + const u8 *label = NULL;
  17. int ret;
  18. + if (priv->of_node)
  19. + label = of_get_property(priv->of_node, "label", NULL);
  20. +
  21. ret = of_get_ethdev_address(priv->of_node, dev);
  22. if (ret)
  23. eth_hw_addr_random(dev);
  24. @@ -441,6 +445,9 @@ int cvm_oct_common_init(struct net_devic
  25. if (dev->netdev_ops->ndo_stop)
  26. dev->netdev_ops->ndo_stop(dev);
  27. + if (!IS_ERR_OR_NULL(label))
  28. + dev_alloc_name(dev, label);
  29. +
  30. return 0;
  31. }