diff --git a/package/kernel/mac80211/patches/subsys/400-allow-ibss-mixed.patch b/package/kernel/mac80211/patches/subsys/220-allow-ibss-mixed.patch similarity index 100% rename from package/kernel/mac80211/patches/subsys/400-allow-ibss-mixed.patch rename to package/kernel/mac80211/patches/subsys/220-allow-ibss-mixed.patch diff --git a/package/kernel/mac80211/patches/subsys/780-avoid-crashing-missing-band.patch b/package/kernel/mac80211/patches/subsys/230-avoid-crashing-missing-band.patch similarity index 93% rename from package/kernel/mac80211/patches/subsys/780-avoid-crashing-missing-band.patch rename to package/kernel/mac80211/patches/subsys/230-avoid-crashing-missing-band.patch index ae400b78a1..9e9e3844b7 100644 --- a/package/kernel/mac80211/patches/subsys/780-avoid-crashing-missing-band.patch +++ b/package/kernel/mac80211/patches/subsys/230-avoid-crashing-missing-band.patch @@ -18,7 +18,7 @@ Signed-off-by: David Bauer --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c -@@ -2455,6 +2455,13 @@ static void sta_stats_decode_rate(struct +@@ -2439,6 +2439,13 @@ static void sta_stats_decode_rate(struct sband = local->hw.wiphy->bands[band]; diff --git a/package/kernel/mac80211/patches/subsys/320-cfg80211-allow-grace-period-for-DFS-available-after-.patch b/package/kernel/mac80211/patches/subsys/310-cfg80211-allow-grace-period-for-DFS-available-after-.patch similarity index 100% rename from package/kernel/mac80211/patches/subsys/320-cfg80211-allow-grace-period-for-DFS-available-after-.patch rename to package/kernel/mac80211/patches/subsys/310-cfg80211-allow-grace-period-for-DFS-available-after-.patch diff --git a/package/kernel/mac80211/patches/subsys/330-mac80211-add-AQL-support-for-broadcast-packets.patch b/package/kernel/mac80211/patches/subsys/320-mac80211-add-AQL-support-for-broadcast-packets.patch similarity index 100% rename from package/kernel/mac80211/patches/subsys/330-mac80211-add-AQL-support-for-broadcast-packets.patch rename to package/kernel/mac80211/patches/subsys/320-mac80211-add-AQL-support-for-broadcast-packets.patch diff --git a/package/kernel/mac80211/patches/subsys/350-wifi-mac80211-introduce-EHT-rate-support-in-AQL-airt.patch b/package/kernel/mac80211/patches/subsys/330-wifi-mac80211-introduce-EHT-rate-support-in-AQL-airt.patch similarity index 100% rename from package/kernel/mac80211/patches/subsys/350-wifi-mac80211-introduce-EHT-rate-support-in-AQL-airt.patch rename to package/kernel/mac80211/patches/subsys/330-wifi-mac80211-introduce-EHT-rate-support-in-AQL-airt.patch diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile index 6abb4a2481..f17adf9213 100644 --- a/package/kernel/mt76/Makefile +++ b/package/kernel/mt76/Makefile @@ -8,9 +8,9 @@ PKG_LICENSE_FILES:= PKG_SOURCE_URL:=https://github.com/openwrt/mt76 PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2024-09-05 -PKG_SOURCE_VERSION:=65cc3daf2a332cc658e9f7438cdadde4392e672e -PKG_MIRROR_HASH:=c29c4f883051a6360119156a03e010ac11573011b23d9e873f83c720600970e7 +PKG_SOURCE_DATE:=2024-09-29 +PKG_SOURCE_VERSION:=680bc70f161fde0f167e2ae50c771be4775eb50a +PKG_MIRROR_HASH:=bcdb95e40cfceba56a565ad6b6d9f92a122e7230d0f7f950b3d39e4280723cca PKG_MAINTAINER:=Felix Fietkau PKG_USE_NINJA:=0 @@ -326,10 +326,34 @@ define KernelPackage/mt7996e AUTOLOAD:=$(call AutoProbe,mt7996e) endef +define KernelPackage/mt7992-firmware + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7992 firmware + DEPENDS+=+kmod-mt7996e +endef + +define KernelPackage/mt7992-23-firmware + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7996 firmware (2+3 antenna variant) + DEPENDS+=+kmod-mt7996e +endef + +define KernelPackage/mt7996-firmware-common + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7996 firmware (common files) + HIDDEN:=1 +endef + define KernelPackage/mt7996-firmware $(KernelPackage/mt76-default) TITLE:=MediaTek MT7996 firmware - DEPENDS+=+kmod-mt7996e + DEPENDS+=+kmod-mt7996e +kmod-mt7996-firmware-common +endef + +define KernelPackage/mt7996-233-firmware + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7996 firmware (2+3+3 antenna variant) + DEPENDS+=+kmod-mt7996e +kmod-mt7996-firmware-common endef define KernelPackage/mt7925-firmware @@ -633,17 +657,59 @@ define KernelPackage/mt7925-firmware/install $(1)/lib/firmware/mediatek/mt7925 endef -define KernelPackage/mt7996-firmware/install +define KernelPackage/mt7992-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/mediatek/mt7996 + cp \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7992_dsp.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7992_eeprom.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7992_eeprom_2i5i.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7992_rom_patch.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7992_wa.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7992_wm.bin \ + $(1)/lib/firmware/mediatek/mt7996 +endef + +define KernelPackage/mt7992-23-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/mediatek/mt7996 + cp \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7992_dsp_23.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7992_eeprom_23.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7992_eeprom_23_2i5i.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7992_rom_patch_23.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7992_wa_23.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7992_wm_23.bin \ + $(1)/lib/firmware/mediatek/mt7996 +endef + +define KernelPackage/mt7996-firmware-common/install $(INSTALL_DIR) $(1)/lib/firmware/mediatek/mt7996 cp \ $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_dsp.bin \ + $(1)/lib/firmware/mediatek/mt7996 +endef + +define KernelPackage/mt7996-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/mediatek/mt7996 + cp \ $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_eeprom.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_eeprom_2i5i6i.bin \ $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_rom_patch.bin \ $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_wa.bin \ $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_wm.bin \ $(1)/lib/firmware/mediatek/mt7996 endef +define KernelPackage/mt7996-233-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/mediatek/mt7996 + cp \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_eeprom_233.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_eeprom_233_2i5i6i.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_rom_patch_233.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_wa_233.bin \ + $(PKG_BUILD_DIR)/firmware/mt7996/mt7996_wm_233.bin \ + $(1)/lib/firmware/mediatek/mt7996 +endef + define Package/mt76-test/install mkdir -p $(1)/usr/sbin $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/mt76-test $(1)/usr/sbin @@ -694,6 +760,10 @@ $(eval $(call KernelPackage,mt7921e)) $(eval $(call KernelPackage,mt7925u)) $(eval $(call KernelPackage,mt7925e)) $(eval $(call KernelPackage,mt7996e)) +$(eval $(call KernelPackage,mt7992-firmware)) +$(eval $(call KernelPackage,mt7992-23-firmware)) +$(eval $(call KernelPackage,mt7996-firmware-common)) $(eval $(call KernelPackage,mt7996-firmware)) +$(eval $(call KernelPackage,mt7996-233-firmware)) $(eval $(call KernelPackage,mt76)) $(eval $(call BuildPackage,mt76-test)) diff --git a/package/kernel/mt76/patches/100-api_update.patch b/package/kernel/mt76/patches/100-api_update.patch deleted file mode 100644 index 30f2eebcfa..0000000000 --- a/package/kernel/mt76/patches/100-api_update.patch +++ /dev/null @@ -1,216 +0,0 @@ ---- a/mt76.h -+++ b/mt76.h -@@ -14,6 +14,7 @@ - #include - #include - #include -+#include - #include - #if LINUX_VERSION_CODE < KERNEL_VERSION(6,6,0) - #include -@@ -1475,6 +1476,7 @@ static inline void mt76_testmode_reset(s - #endif - } - -+extern const struct nla_policy mt76_tm_policy[NUM_MT76_TM_ATTRS]; - - /* internal */ - static inline struct ieee80211_hw * ---- a/mt7603/main.c -+++ b/mt7603/main.c -@@ -23,7 +23,7 @@ mt7603_start(struct ieee80211_hw *hw) - } - - static void --mt7603_stop(struct ieee80211_hw *hw) -+mt7603_stop(struct ieee80211_hw *hw, bool suspend) - { - struct mt7603_dev *dev = hw->priv; - ---- a/mt7615/main.c -+++ b/mt7615/main.c -@@ -91,7 +91,7 @@ out: - return ret; - } - --static void mt7615_stop(struct ieee80211_hw *hw) -+static void mt7615_stop(struct ieee80211_hw *hw, bool suspend) - { - struct mt7615_dev *dev = mt7615_hw_dev(hw); - struct mt7615_phy *phy = mt7615_hw_phy(hw); ---- a/mt7615/usb.c -+++ b/mt7615/usb.c -@@ -79,7 +79,7 @@ static void mt7663u_copy(struct mt76_dev - mutex_unlock(&usb->usb_ctrl_mtx); - } - --static void mt7663u_stop(struct ieee80211_hw *hw) -+static void mt7663u_stop(struct ieee80211_hw *hw, bool suspend) - { - struct mt7615_phy *phy = mt7615_hw_phy(hw); - struct mt7615_dev *dev = hw->priv; ---- a/mt76x0/pci.c -+++ b/mt76x0/pci.c -@@ -44,7 +44,7 @@ static void mt76x0e_stop_hw(struct mt76x - mt76_clear(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_RX_DMA_EN); - } - --static void mt76x0e_stop(struct ieee80211_hw *hw) -+static void mt76x0e_stop(struct ieee80211_hw *hw, bool suspend) - { - struct mt76x02_dev *dev = hw->priv; - ---- a/mt76x0/usb.c -+++ b/mt76x0/usb.c -@@ -77,7 +77,7 @@ static void mt76x0u_cleanup(struct mt76x - mt76u_queues_deinit(&dev->mt76); - } - --static void mt76x0u_stop(struct ieee80211_hw *hw) -+static void mt76x0u_stop(struct ieee80211_hw *hw, bool suspend) - { - struct mt76x02_dev *dev = hw->priv; - ---- a/mt76x2/pci_main.c -+++ b/mt76x2/pci_main.c -@@ -24,7 +24,7 @@ mt76x2_start(struct ieee80211_hw *hw) - } - - static void --mt76x2_stop(struct ieee80211_hw *hw) -+mt76x2_stop(struct ieee80211_hw *hw, bool suspend) - { - struct mt76x02_dev *dev = hw->priv; - ---- a/mt76x2/usb_main.c -+++ b/mt76x2/usb_main.c -@@ -22,7 +22,7 @@ static int mt76x2u_start(struct ieee8021 - return 0; - } - --static void mt76x2u_stop(struct ieee80211_hw *hw) -+static void mt76x2u_stop(struct ieee80211_hw *hw, bool suspend) - { - struct mt76x02_dev *dev = hw->priv; - ---- a/mt7915/main.c -+++ b/mt7915/main.c -@@ -108,7 +108,7 @@ static int mt7915_start(struct ieee80211 - return ret; - } - --static void mt7915_stop(struct ieee80211_hw *hw) -+static void mt7915_stop(struct ieee80211_hw *hw, bool suspend) - { - struct mt7915_dev *dev = mt7915_hw_dev(hw); - struct mt7915_phy *phy = mt7915_hw_phy(hw); ---- a/mt7915/mcu.c -+++ b/mt7915/mcu.c -@@ -335,7 +335,7 @@ mt7915_mcu_cca_finish(void *priv, u8 *ma - if (!vif->bss_conf.color_change_active || vif->type == NL80211_IFTYPE_STATION) - return; - -- ieee80211_color_change_finish(vif); -+ ieee80211_color_change_finish(vif, 0); - } - - static void ---- a/mt7921/main.c -+++ b/mt7921/main.c -@@ -268,7 +268,7 @@ static int mt7921_start(struct ieee80211 - return err; - } - --static void mt7921_stop(struct ieee80211_hw *hw) -+static void mt7921_stop(struct ieee80211_hw *hw, bool suspend) - { - struct mt792x_dev *dev = mt792x_hw_dev(hw); - int err = 0; -@@ -281,7 +281,7 @@ static void mt7921_stop(struct ieee80211 - return; - } - -- mt792x_stop(hw); -+ mt792x_stop(hw, false); - } - - static int ---- a/mt792x.h -+++ b/mt792x.h -@@ -337,7 +337,7 @@ static inline bool mt792x_dma_need_reini - #define mt792x_mutex_release(dev) \ - mt76_connac_mutex_release(&(dev)->mt76, &(dev)->pm) - --void mt792x_stop(struct ieee80211_hw *hw); -+void mt792x_stop(struct ieee80211_hw *hw, bool suspend); - void mt792x_pm_wake_work(struct work_struct *work); - void mt792x_pm_power_save_work(struct work_struct *work); - void mt792x_reset(struct mt76_dev *mdev); -@@ -457,7 +457,7 @@ void mt792xu_wr(struct mt76_dev *dev, u3 - u32 mt792xu_rmw(struct mt76_dev *dev, u32 addr, u32 mask, u32 val); - void mt792xu_copy(struct mt76_dev *dev, u32 offset, const void *data, int len); - void mt792xu_disconnect(struct usb_interface *usb_intf); --void mt792xu_stop(struct ieee80211_hw *hw); -+void mt792xu_stop(struct ieee80211_hw *hw, bool suspend); - - static inline void - mt792x_skb_add_usb_sdio_hdr(struct mt792x_dev *dev, struct sk_buff *skb, ---- a/mt792x_core.c -+++ b/mt792x_core.c -@@ -113,7 +113,7 @@ void mt792x_tx(struct ieee80211_hw *hw, - } - EXPORT_SYMBOL_GPL(mt792x_tx); - --void mt792x_stop(struct ieee80211_hw *hw) -+void mt792x_stop(struct ieee80211_hw *hw, bool suspend) - { - struct mt792x_dev *dev = mt792x_hw_dev(hw); - struct mt792x_phy *phy = mt792x_hw_phy(hw); ---- a/mt792x_usb.c -+++ b/mt792x_usb.c -@@ -285,12 +285,12 @@ int mt792xu_init_reset(struct mt792x_dev - } - EXPORT_SYMBOL_GPL(mt792xu_init_reset); - --void mt792xu_stop(struct ieee80211_hw *hw) -+void mt792xu_stop(struct ieee80211_hw *hw, bool suspend) - { - struct mt792x_dev *dev = mt792x_hw_dev(hw); - - mt76u_stop_tx(&dev->mt76); -- mt792x_stop(hw); -+ mt792x_stop(hw, false); - } - EXPORT_SYMBOL_GPL(mt792xu_stop); - ---- a/mt7996/main.c -+++ b/mt7996/main.c -@@ -93,7 +93,7 @@ static int mt7996_start(struct ieee80211 - return ret; - } - --static void mt7996_stop(struct ieee80211_hw *hw) -+static void mt7996_stop(struct ieee80211_hw *hw, bool suspend) - { - struct mt7996_dev *dev = mt7996_hw_dev(hw); - struct mt7996_phy *phy = mt7996_hw_phy(hw); ---- a/mt7996/mcu.c -+++ b/mt7996/mcu.c -@@ -421,7 +421,7 @@ mt7996_mcu_cca_finish(void *priv, u8 *ma - if (!vif->bss_conf.color_change_active || vif->type == NL80211_IFTYPE_STATION) - return; - -- ieee80211_color_change_finish(vif); -+ ieee80211_color_change_finish(vif, 0); - } - - static void ---- a/testmode.h -+++ b/testmode.h -@@ -193,6 +193,4 @@ enum mt76_testmode_tx_mode { - MT76_TM_TX_MODE_MAX = NUM_MT76_TM_TX_MODES - 1, - }; - --extern const struct nla_policy mt76_tm_policy[NUM_MT76_TM_ATTRS]; -- - #endif diff --git a/target/linux/generic/backport-6.6/900-v6.11-net-free_netdev-exit-earlier-if-dummy.patch b/target/linux/generic/backport-6.6/900-v6.11-net-free_netdev-exit-earlier-if-dummy.patch new file mode 100644 index 0000000000..31beb11d54 --- /dev/null +++ b/target/linux/generic/backport-6.6/900-v6.11-net-free_netdev-exit-earlier-if-dummy.patch @@ -0,0 +1,35 @@ +From f8d05679fb3faae478d604177b0c188b340371cd Mon Sep 17 00:00:00 2001 +From: Breno Leitao +Date: Mon, 22 Apr 2024 05:38:55 -0700 +Subject: [PATCH] net: free_netdev: exit earlier if dummy + +For dummy devices, exit earlier at free_netdev() instead of executing +the whole function. This is necessary, because dummy devices are +special, and shouldn't have the second part of the function executed. + +Otherwise reg_state, which is NETREG_DUMMY, will be overwritten and +there will be no way to identify that this is a dummy device. Also, this +device do not need the final put_device(), since dummy devices are not +registered (through register_netdevice()), where the device reference is +increased (at netdev_register_kobject()/device_add()). + +Suggested-by: Jakub Kicinski +Signed-off-by: Breno Leitao +Reviewed-by: Ido Schimmel +Signed-off-by: David S. Miller +--- + net/core/dev.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -10966,7 +10966,8 @@ void free_netdev(struct net_device *dev) + dev->xdp_bulkq = NULL; + + /* Compatibility with error handling in drivers */ +- if (dev->reg_state == NETREG_UNINITIALIZED) { ++ if (dev->reg_state == NETREG_UNINITIALIZED || ++ dev->reg_state == NETREG_DUMMY) { + netdev_freemem(dev); + return; + } diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 02ad496695..76d445d0a9 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -213,7 +213,7 @@ define Device/smartrg_sdg-8733a $(call Device/adtran_smartrg) DEVICE_MODEL := SDG-8733A DEVICE_DTS := mt7988d-smartrg-SDG-8733A - DEVICE_PACKAGES += mt7988-2p5g-phy-firmware kmod-mt7996-firmware kmod-phy-aquantia + DEVICE_PACKAGES += mt7988-2p5g-phy-firmware kmod-mt7996-233-firmware kmod-phy-aquantia endef TARGET_DEVICES += smartrg_sdg-8733a @@ -376,7 +376,7 @@ define Device/bananapi_bpi-r4-common DEVICE_DTS_LOADADDR := 0x45f00000 DEVICE_DTS_OVERLAY:= mt7988a-bananapi-bpi-r4-emmc mt7988a-bananapi-bpi-r4-rtc mt7988a-bananapi-bpi-r4-sd mt7988a-bananapi-bpi-r4-wifi-mt7996a DEVICE_DTC_FLAGS := --pad 4096 - DEVICE_PACKAGES := kmod-hwmon-pwmfan kmod-i2c-mux-pca954x kmod-eeprom-at24 kmod-mt7996-firmware \ + DEVICE_PACKAGES := kmod-hwmon-pwmfan kmod-i2c-mux-pca954x kmod-eeprom-at24 kmod-mt7996-firmware kmod-mt7996-233-firmware \ kmod-rtc-pcf8563 kmod-sfp kmod-usb3 e2fsprogs f2fsck mkf2fs IMAGES := sysupgrade.itb KERNEL_LOADADDR := 0x46000000 diff --git a/tools/elfutils/patches/100-portability.patch b/tools/elfutils/patches/100-portability.patch index be97f95faa..2cc8a4c56e 100644 --- a/tools/elfutils/patches/100-portability.patch +++ b/tools/elfutils/patches/100-portability.patch @@ -288,3 +288,13 @@ /* Definitions of arguments for argp functions. */ static const struct argp_option options[] = +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -92,6 +92,7 @@ strings_LDADD = $(libelf) $(libeu) $(arg + ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) + unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) + stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib) ++EXTRA_stack_DEPENDENCIES = $(if $(findstring srcfiles,$(bin_PROGRAMS)),$(srcfiles_OBJECTS)) + elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) + elfclassify_LDADD = $(libelf) $(libdw) $(libeu) $(argp_LDADD) + srcfiles_SOURCES = srcfiles.cxx diff --git a/tools/yafut/patches/100-portability.patch b/tools/yafut/patches/100-portability.patch new file mode 100644 index 0000000000..18fda407af --- /dev/null +++ b/tools/yafut/patches/100-portability.patch @@ -0,0 +1,289 @@ +--- a/lib/yaffs2/direct/yportenv.h ++++ b/lib/yaffs2/direct/yportenv.h +@@ -32,10 +32,13 @@ + #define CONFIG_YAFFS_DEFINES_TYPES 1 + #define CONFIG_YAFFS_USE_32_BIT_TIME_T 1 + #define NO_Y_INLINE 1 +-#define loff_t off_t + + #endif /* __rtems__ */ + ++#ifndef linux ++#define loff_t off_t ++#endif ++ + /* Definition of types */ + #ifdef CONFIG_YAFFS_DEFINES_TYPES + typedef unsigned char u8; +--- a/src/ioctl.c ++++ b/src/ioctl.c +@@ -21,5 +21,9 @@ + * integer overflow when building against e.g. musl. + */ + int linux_ioctl(int fd, unsigned long request, void *ptr) { ++#ifdef linux + return syscall(SYS_ioctl, fd, request, ptr); ++#else ++ return -1; ++#endif + } +--- a/src/ioctl.h ++++ b/src/ioctl.h +@@ -12,7 +12,9 @@ int linux_ioctl(int fd, unsigned long re + * time, as the definition of the MEMREAD ioctl trickles down into kernel + * headers distributed out there. + */ ++#ifdef linux + #include ++ + #ifndef MEMREAD + #include + +@@ -35,3 +37,4 @@ struct mtd_read_req { + + #define MEMREAD _IOWR('M', 26, struct mtd_read_req) + #endif /* MEMREAD */ ++#endif +--- a/src/mtd.c ++++ b/src/mtd.c +@@ -4,7 +4,9 @@ + + #include + #include ++#ifdef linux + #include ++#endif + #include + #include + #include +@@ -82,6 +84,7 @@ static void mtd_debug_location(const cha + va_end(args); + } + ++#ifdef linux + /* + * Read the raw contents of the sysfs attribute at the provided 'sysfs_path' + * into 'buf', which is 'buf_len' bytes large. The given sysfs attribute is +@@ -179,6 +182,7 @@ static int discover_mtd_parameters(const + + return 0; + } ++#endif + + /* + * Initialize 'geometry' with 'chunk_size' and 'block_size' set to the default +@@ -203,6 +207,7 @@ static void init_yaffs_geometry_default( + * Initialize 'geometry' with 'chunk_size' and 'block_size' set to the relevant + * MTD parameters provided in 'mtd' and 'mtd_type' set to the provided value. + */ ++#ifdef linux + static void init_yaffs_geometry_autodetected(const struct mtd_ctx *ctx, + const struct mtd_info_user *mtd, + struct mtd_geometry *geometry, +@@ -217,6 +222,7 @@ static void init_yaffs_geometry_autodete + .block_size = mtd->erasesize, + }; + } ++#endif + + /* + * Update 'chunk_size' and 'block_size' in 'geometry' to the values provided in +@@ -280,6 +286,7 @@ static int init_yaffs_geometry_file(cons + * 2. If -C and/or -B were used, override any default values with those + * provided on the command line. + */ ++#ifdef linux + static void init_yaffs_geometry_nand_or_nor(const struct mtd_ctx *ctx, + const struct mtd_info_user *mtd, + const struct opts *opts, +@@ -297,6 +304,7 @@ static void init_yaffs_geometry_nand_or_ + + geometry->block_count = mtd->size / geometry->block_size; + } ++#endif + + /* + * Determine the type of the provided MTD (which can be either NAND/NOR flash +@@ -317,6 +325,7 @@ static int init_yaffs_geometry(const str + geometry->oob_size = 0; + geometry->oobavail = 0; + } else { ++#ifdef linux + struct mtd_info_user mtd; + unsigned int oobavail; + +@@ -329,6 +338,9 @@ static int init_yaffs_geometry(const str + + geometry->oob_size = mtd.oobsize; + geometry->oobavail = oobavail; ++#else ++ return -1; ++#endif + } + + return 0; +--- a/src/ydrv.c ++++ b/src/ydrv.c +@@ -3,7 +3,9 @@ + // SPDX-License-Identifier: GPL-2.0-only + + #include ++#ifdef linux + #include ++#endif + #include + #include + #include +@@ -122,6 +124,7 @@ static long long ydrv_get_data_offset_fo + /* + * Check whether the given MTD block is a bad one on NAND or NOR flash. + */ ++#ifdef linux + static int ydrv_check_bad_nand_or_nor(const struct ydrv_ctx *ctx, + int block_no) { + long long offset = block_no * ctx->block_size; +@@ -139,6 +142,7 @@ static int ydrv_check_bad_nand_or_nor(co + + return (ret == 0 ? YAFFS_OK : YAFFS_FAIL); + } ++#endif + + /* + * Check whether the given MTD block is a bad one. +@@ -154,9 +158,11 @@ static int ydrv_check_bad(struct yaffs_d + } + + switch (ctx->mtd_type) { ++#ifdef linux + case MTD_TYPE_NAND: + case MTD_TYPE_NOR: + return ydrv_check_bad_nand_or_nor(ctx, block_no); ++#endif + case MTD_TYPE_FILE: + ydrv_debug("file is assumed to only contain good blocks"); + return YAFFS_OK; +@@ -169,6 +175,7 @@ static int ydrv_check_bad(struct yaffs_d + /* + * Erase the given MTD block on NAND or NOR flash. + */ ++#ifdef linux + static int ydrv_erase_block_nand_or_nor(const struct ydrv_ctx *ctx, + int block_no) { + long long offset = block_no * ctx->block_size; +@@ -196,6 +203,7 @@ static int ydrv_erase_block_nand_or_nor( + + return YAFFS_OK; + } ++#endif + + /* + * Erase the given MTD block in a file. +@@ -247,9 +255,11 @@ static int ydrv_erase_block(struct yaffs + } + + switch (ctx->mtd_type) { ++#ifdef linux + case MTD_TYPE_NAND: + case MTD_TYPE_NOR: + return ydrv_erase_block_nand_or_nor(ctx, block_no); ++#endif + case MTD_TYPE_FILE: + return ydrv_erase_block_file(ctx, block_no); + default: +@@ -261,6 +271,7 @@ static int ydrv_erase_block(struct yaffs + /* + * Mark the given MTD block as bad on NAND or NOR flash. + */ ++#ifdef linux + static int ydrv_mark_bad_nand_or_nor(const struct ydrv_ctx *ctx, int block_no) { + long long offset = block_no * ctx->block_size; + int err = 0; +@@ -281,6 +292,7 @@ static int ydrv_mark_bad_nand_or_nor(con + + return YAFFS_OK; + } ++#endif + + /* + * Mark the given MTD block as bad. +@@ -296,9 +308,11 @@ static int ydrv_mark_bad(struct yaffs_de + } + + switch (ctx->mtd_type) { ++#ifdef linux + case MTD_TYPE_NAND: + case MTD_TYPE_NOR: + return ydrv_mark_bad_nand_or_nor(ctx, block_no); ++#endif + case MTD_TYPE_FILE: + ydrv_debug("file is assumed to only contain good blocks"); + return YAFFS_FAIL; +@@ -315,9 +329,11 @@ static int ydrv_mark_bad(struct yaffs_de + */ + static int ydrv_ecc_result(int read_result, enum yaffs_ecc_result *ecc_result) { + switch (read_result) { ++#ifdef linux + case -EUCLEAN: + *ecc_result = YAFFS_ECC_RESULT_FIXED; + return YAFFS_OK; ++#endif + case -EBADMSG: + *ecc_result = YAFFS_ECC_RESULT_UNFIXED; + return YAFFS_FAIL; +@@ -333,6 +349,7 @@ static int ydrv_ecc_result(int read_resu + /* + * Read a data+OOB chunk from NAND flash. + */ ++#ifdef linux + static int ydrv_read_chunk_nand(const struct ydrv_ctx *ctx, int chunk, u8 *data, + int data_len, u8 *oob, int oob_len, + enum yaffs_ecc_result *ecc_result_out, +@@ -371,6 +388,7 @@ static int ydrv_read_chunk_nand(const st + + return ret; + } ++#endif + + /* + * Read a data chunk from NOR flash. +@@ -420,10 +438,12 @@ static int ydrv_read_chunk(struct yaffs_ + } + + switch (ctx->mtd_type) { ++#ifdef linux + case MTD_TYPE_NAND: + return ydrv_read_chunk_nand(ctx, chunk, data, data_len, oob, + oob_len, ecc_result_out, + dev->param.is_yaffs2); ++#endif + case MTD_TYPE_NOR: + case MTD_TYPE_FILE: + return ydrv_read_chunk_nor_or_file(ctx, chunk, data, data_len, +@@ -438,6 +458,7 @@ static int ydrv_read_chunk(struct yaffs_ + /* + * Write a data+OOB chunk to NAND flash. + */ ++#ifdef linux + static int ydrv_write_chunk_nand(const struct ydrv_ctx *ctx, int chunk, + const u8 *data, int data_len, const u8 *oob, + int oob_len, bool is_yaffs2) { +@@ -472,6 +493,7 @@ static int ydrv_write_chunk_nand(const s + + return YAFFS_OK; + } ++#endif + + /* + * Write a data chunk to NOR flash. +@@ -516,9 +538,11 @@ static int ydrv_write_chunk(struct yaffs + } + + switch (ctx->mtd_type) { ++#ifdef linux + case MTD_TYPE_NAND: + return ydrv_write_chunk_nand(ctx, chunk, data, data_len, oob, + oob_len, dev->param.is_yaffs2); ++#endif + case MTD_TYPE_NOR: + case MTD_TYPE_FILE: + return ydrv_write_chunk_nor_or_file(ctx, chunk, data, data_len);