mtd: fix build with GCC 14
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 611-v6.3-net-add-helper-eth_addr_add.patch
1 From 7390609b0121a1b982c5ecdfcd72dc328e5784ee Mon Sep 17 00:00:00 2001
2 From: Michael Walle <michael@walle.cc>
3 Date: Mon, 6 Feb 2023 13:43:42 +0000
4 Subject: [PATCH] net: add helper eth_addr_add()
5
6 Add a helper to add an offset to a ethernet address. This comes in handy
7 if you have a base ethernet address for multiple interfaces.
8
9 Signed-off-by: Michael Walle <michael@walle.cc>
10 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
11 Acked-by: Jakub Kicinski <kuba@kernel.org>
12 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
13 Link: https://lore.kernel.org/r/20230206134356.839737-9-srinivas.kandagatla@linaro.org
14 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
15 ---
16 include/linux/etherdevice.h | 14 ++++++++++++++
17 1 file changed, 14 insertions(+)
18
19 --- a/include/linux/etherdevice.h
20 +++ b/include/linux/etherdevice.h
21 @@ -508,6 +508,20 @@ static inline void eth_addr_inc(u8 *addr
22 }
23
24 /**
25 + * eth_addr_add() - Add (or subtract) an offset to/from the given MAC address.
26 + *
27 + * @offset: Offset to add.
28 + * @addr: Pointer to a six-byte array containing Ethernet address to increment.
29 + */
30 +static inline void eth_addr_add(u8 *addr, long offset)
31 +{
32 + u64 u = ether_addr_to_u64(addr);
33 +
34 + u += offset;
35 + u64_to_ether_addr(u, addr);
36 +}
37 +
38 +/**
39 * is_etherdev_addr - Tell if given Ethernet address belongs to the device.
40 * @dev: Pointer to a device structure
41 * @addr: Pointer to a six-byte array containing the Ethernet address