684-of_net-do-mac-address-increment-only-once.patch 1.0 KB

123456789101112131415161718192021222324252627282930
  1. From dd07dd394d8bfdb5d527fab18ca54f20815ec4e4 Mon Sep 17 00:00:00 2001
  2. From: Will Moss <[email protected]>
  3. Date: Wed, 3 Aug 2022 13:48:55 +0000
  4. Subject: [PATCH] of_net: do mac-address-increment only once
  5. Remove mac-address-increment and mac-address-increment-byte
  6. DT property after incrementing process to make sure MAC address
  7. would not get incremented more if this function is stared again.
  8. It could happen if device initialization is deferred after
  9. unsuccessful attempt.
  10. Signed-off-by: Will Moss <[email protected]>
  11. ---
  12. drivers/of/of_net.c | 6 ++++++
  13. 1 file changed, 6 insertions(+)
  14. --- a/net/core/of_net.c
  15. +++ b/net/core/of_net.c
  16. @@ -184,6 +184,11 @@ found:
  17. addr[3] = (mac_val >> 16) & 0xff;
  18. addr[4] = (mac_val >> 8) & 0xff;
  19. addr[5] = (mac_val >> 0) & 0xff;
  20. +
  21. + /* Remove mac-address-increment DT property to make sure MAC
  22. + * address would not get incremented more if this function is
  23. + * stared again. */
  24. + of_remove_property(np, of_find_property(np, "mac-address-increment", NULL));
  25. }
  26. of_add_mac_address(np, addr);