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