|
|
@@ -24,15 +24,14 @@ Signed-off-by: Christian Marangi <[email protected]>
|
|
|
Supported chips: RT2880, RT3050, RT3052, RT3350, RT3352.
|
|
|
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
|
|
|
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
|
|
|
-@@ -10,11 +10,69 @@
|
|
|
-
|
|
|
+@@ -11,10 +11,66 @@
|
|
|
#include <linux/kernel.h>
|
|
|
#include <linux/module.h>
|
|
|
+ #include <linux/of.h>
|
|
|
+#if IS_ENABLED(CONFIG_MTD)
|
|
|
+#include <linux/mtd/mtd.h>
|
|
|
+#include <linux/mtd/partitions.h>
|
|
|
+#endif
|
|
|
- #include <linux/of.h>
|
|
|
|
|
|
#include "rt2x00.h"
|
|
|
#include "rt2x00soc.h"
|
|
|
@@ -40,8 +39,6 @@ Signed-off-by: Christian Marangi <[email protected]>
|
|
|
+#if IS_ENABLED(CONFIG_MTD)
|
|
|
+static int rt2800lib_read_eeprom_mtd(struct rt2x00_dev *rt2x00dev)
|
|
|
+{
|
|
|
-+ int ret = -EINVAL;
|
|
|
-+#ifdef CONFIG_OF
|
|
|
+ struct device_node *np = rt2x00dev->dev->of_node, *mtd_np = NULL;
|
|
|
+ int size, offset = 0;
|
|
|
+ struct mtd_info *mtd;
|
|
|
@@ -49,6 +46,7 @@ Signed-off-by: Christian Marangi <[email protected]>
|
|
|
+ const __be32 *list;
|
|
|
+ phandle phandle;
|
|
|
+ size_t retlen;
|
|
|
++ int ret;
|
|
|
+
|
|
|
+ list = of_get_property(np, "ralink,mtd-eeprom", &size);
|
|
|
+ if (!list)
|
|
|
@@ -79,13 +77,12 @@ Signed-off-by: Christian Marangi <[email protected]>
|
|
|
+ &retlen, (u_char *)rt2x00dev->eeprom);
|
|
|
+ put_mtd_device(mtd);
|
|
|
+
|
|
|
-+ if (retlen != rt2x00dev->ops->eeprom_size || ret) {
|
|
|
++ if (ret || retlen != rt2x00dev->ops->eeprom_size) {
|
|
|
+ dev_err(rt2x00dev->dev, "failed to load eeprom from device \"%s\"\n", part);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ dev_info(rt2x00dev->dev, "loaded eeprom from mtd device \"%s\"\n", part);
|
|
|
-+#endif
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
@@ -94,7 +91,7 @@ Signed-off-by: Christian Marangi <[email protected]>
|
|
|
static const char *
|
|
|
rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
|
|
|
{
|
|
|
-@@ -83,6 +141,14 @@ err_exit:
|
|
|
+@@ -74,6 +130,14 @@ err_exit:
|
|
|
|
|
|
int rt2x00lib_read_eeprom(struct rt2x00_dev *rt2x00dev)
|
|
|
{
|