kernel: drop "mac-address-increment-byte" DT property support
[openwrt/staging/hauke.git] / target / linux / generic / pending-6.1 / 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/net/core/of_net.c
18 +++ b/net/core/of_net.c
19 @@ -184,6 +184,11 @@ 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 DT property to make sure MAC
25 + * address would not get incremented more if this function is
26 + * stared again. */
27 + of_remove_property(np, of_find_property(np, "mac-address-increment", NULL));
28 }
29
30 of_add_mac_address(np, addr);