openwrt/package/kernel/mac80211/patches/rt2x00/602-04-wifi-rt2x00-Support-EEPROM-swap-binding.patch
Christian Marangi bea4f50207
mac80211: rt2x00: improve EEPROM load patches
Improve EEPROME load patches. Reorganize and rework them.

The current patch are bugged and with the case of MTD loading, leaks and
never free the EEPROM read values.

Also add support for loading EEPROM using NVMEM cells.

As a cleanup, change the binding to swap EEPROM read from mtd to
ralink,eeprom-swap and generilize it.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2023-10-16 14:16:55 +02:00

45 lines
1.3 KiB
Diff

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