From 1c055e55a242a33e574e48be530e06770a210dcd Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Mon, 19 Feb 2024 03:26:26 +0000
Subject: [PATCH] add r8169 read mac form eeprom

---
 kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/linux_osl.c |   71 +++++++++++++++++++++++++++++++++--
 1 files changed, 67 insertions(+), 4 deletions(-)

diff --git a/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/linux_osl.c b/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/linux_osl.c
old mode 100644
new mode 100755
index 2dd9b38..621d3da
--- a/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/linux_osl.c
+++ b/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/linux_osl.c
@@ -1718,6 +1718,71 @@
 	return rand;
 }
 
+/* Linux Kernel: File Operations: start */
+void *
+osl_os_open_image(char *filename)
+{
+	struct file *fp;
+
+	fp = filp_open(filename, O_RDONLY, 0);
+	/*
+	 * 2.6.11 (FC4) supports filp_open() but later revs don't?
+	 * Alternative:
+	 * fp = open_namei(AT_FDCWD, filename, O_RD, 0);
+	 * ???
+	 */
+	if (IS_ERR(fp)) {
+		printf("ERROR %ld: Unable to open file %s\n", PTR_ERR(fp), filename);
+		fp = NULL;
+	}
+
+	return fp;
+}
+
+int
+osl_os_get_image_block(char *buf, int len, void *image)
+{
+	struct file *fp = (struct file *)image;
+	int rdlen;
+
+	if (fp == NULL) {
+		return 0;
+	}
+
+	rdlen = kernel_read_compat(fp, fp->f_pos, buf, len);
+	if (rdlen > 0) {
+		fp->f_pos += rdlen;
+	}
+
+	return rdlen;
+}
+
+void
+osl_os_close_image(void *image)
+{
+	struct file *fp = (struct file *)image;
+
+	if (fp != NULL) {
+		filp_close(fp, NULL);
+	}
+}
+
+int
+osl_os_image_size(void *image)
+{
+	int len = 0, curroffset;
+
+	if (image) {
+		/* store the current offset */
+		curroffset = generic_file_llseek(image, 0, 1);
+		/* goto end of file to get length */
+		len = generic_file_llseek(image, 0, 2);
+		/* restore back the offset */
+		generic_file_llseek(image, curroffset, 0);
+	}
+	return len;
+}
+
 /* Linux Kernel: File Operations: end */
 
 #if defined(AXI_TIMEOUTS_NIC)
@@ -1874,11 +1939,9 @@
 int
 kernel_read_compat(struct file *file, loff_t offset, char *addr, unsigned long count)
 {
-#ifdef DHD_SUPPORT_VFS_CALL
+	if (!IS_ENABLED(CONFIG_NO_GKI))
+		return -EPERM;
 	return (int)kernel_read(file, addr, (size_t)count, &offset);
-#else
-	return 0;
-#endif /* DHD_SUPPORT_VFS_CALL */
 }
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)) */
 

--
Gitblit v1.6.2