1 From 9c9a3c27b96e057f3c3f47151d7a170d84e3bb5f Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Sun, 15 Oct 2023 15:31:47 +0200
4 Subject: [PATCH 4/5] wifi: rt2x00: Support EEPROM swap binding
6 Add binding "ralink,eeprom-swap" to swap bytes of EEPROM before using
9 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
11 drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c | 15 +++++++++++++++
12 1 file changed, 15 insertions(+)
14 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
15 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
17 #include "rt2x00soc.h"
19 #if IS_ENABLED(CONFIG_MTD)
20 +static void rt2800lib_eeprom_swap(struct rt2x00_dev *rt2x00dev)
22 + struct device_node *np = rt2x00dev->dev->of_node;
23 + size_t len = rt2x00dev->ops->eeprom_size;
26 + if (!of_find_property(np, "ralink,eeprom-swap", NULL))
29 + for (i = 0; i < len / sizeof(u16); i++)
30 + rt2x00dev->eeprom[i] = swab16(rt2x00dev->eeprom[i]);
33 static int rt2800lib_read_eeprom_mtd(struct rt2x00_dev *rt2x00dev)
36 @@ -66,6 +79,8 @@ static int rt2800lib_read_eeprom_mtd(str
40 + rt2800lib_eeprom_swap(rt2x00dev);
42 dev_info(rt2x00dev->dev, "loaded eeprom from mtd device \"%s\"\n", part);