From abd01a78093115aed3c02e2356fd04e51a5c8aa3 Mon Sep 17 00:00:00 2001
From: Daniel Barlow <dan@telent.net>
Date: Tue, 26 Sep 2023 18:40:22 +0100
Subject: [PATCH] apply mtdpslit patch only for openwrt kernel

it doesn't apply to mainline because there's no mtdsplit
in mainline
---
 pkgs/kernel/default.nix                                      | 1 -
 pkgs/openwrt/default.nix                                     | 1 +
 .../make-mtdsplit-jffs2-endian-agnostic.patch                | 5 +++++
 3 files changed, 6 insertions(+), 1 deletion(-)
 rename pkgs/{kernel => openwrt}/make-mtdsplit-jffs2-endian-agnostic.patch (80%)

diff --git a/pkgs/kernel/default.nix b/pkgs/kernel/default.nix
index 224ed354..d2fec552 100644
--- a/pkgs/kernel/default.nix
+++ b/pkgs/kernel/default.nix
@@ -54,7 +54,6 @@ stdenv.mkDerivation rec {
 
   patches = [
     ./cmdline-cookie.patch
-    ./make-mtdsplit-jffs2-endian-agnostic.patch
   ];
 
   # this is here to work around what I think is a bug in nixpkgs
diff --git a/pkgs/openwrt/default.nix b/pkgs/openwrt/default.nix
index f2fd4f9a..e661c771 100644
--- a/pkgs/openwrt/default.nix
+++ b/pkgs/openwrt/default.nix
@@ -26,6 +26,7 @@ let
     patch --batch -p1 --reverse <  ${src}/target/linux/generic/pending-5.15/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch
     patches ${src}/target/linux/generic/hack-5.15/*.patch
     patches ${src}/target/linux/${family}/patches-5.15/*.patch
+    patches ${./make-mtdsplit-jffs2-endian-agnostic.patch}
   '';
 in {
   inherit src;
diff --git a/pkgs/kernel/make-mtdsplit-jffs2-endian-agnostic.patch b/pkgs/openwrt/make-mtdsplit-jffs2-endian-agnostic.patch
similarity index 80%
rename from pkgs/kernel/make-mtdsplit-jffs2-endian-agnostic.patch
rename to pkgs/openwrt/make-mtdsplit-jffs2-endian-agnostic.patch
index 2e7b784f..ff8beb6c 100644
--- a/pkgs/kernel/make-mtdsplit-jffs2-endian-agnostic.patch
+++ b/pkgs/openwrt/make-mtdsplit-jffs2-endian-agnostic.patch
@@ -1,3 +1,8 @@
+From 12345790 Tue Sep 26 18:30:44 2023
+From: Daniel Barlow <dan@telent.net>
+Date: Tue Sep 26 18:29:47 BST 2023
+Subject: mtdsplit: find magic of little-endian JFFS2
+
 On a little-endian CPU, the little-endian JFFS2 magic
 appears to be word-swapped.