uboot-envtools: ipq60xx: code simplification
authorRobert Marko <robimarko@gmail.com>
Fri, 7 Feb 2025 20:54:25 +0000 (21:54 +0100)
committerRobert Marko <robimarko@gmail.com>
Sun, 9 Feb 2025 19:34:40 +0000 (20:34 +0100)
Do the same code simplification as was done for ipq807x to avoid code
duplication.

Link: https://github.com/openwrt/openwrt/pull/17907
Signed-off-by: Robert Marko <robimarko@gmail.com>
package/boot/uboot-envtools/files/qualcommax_ipq60xx

index 1c1bfd1230e7778aaae2ffd8c35aa89ac46d9e67..2dc60bebe114e21e0f7476f7bb858f21bb574545 100644 (file)
@@ -7,33 +7,27 @@ touch /etc/config/ubootenv
 
 board=$(board_name)
 
+ubootenv_add_mtd() {
+       local idx="$(find_mtd_index "${1}")"
+       [ -n "$idx" ] && \
+               ubootenv_add_uci_config "/dev/mtd$idx" "${2}" "${3}" "${4}"
+}
+
 case "$board" in
 8devices,mango-dvk|\
 8devices,mango-dvk-sfp|\
 cambiumnetworks,xe3-4)
-       idx="$(find_mtd_index 0:APPSBLENV)"
-       [ -n "$idx" ] && \
-               ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x10000"
+       ubootenv_add_mtd "0:APPSBLENV" "0x0" "0x10000" "0x10000"
        ;;
 linksys,mr7350)
-       idx="$(find_mtd_index u_env)"
-       [ -n "$idx" ] && \
-               ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x40000" "0x20000"
-       ;;
-netgear,wax214)
-       idx="$(find_mtd_index 0:appsblenv)"
-       [ -n "$idx" ] && \
-               ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x40000" "0x20000"
+       ubootenv_add_mtd "u_env" "0x0" "0x40000" "0x20000"
        ;;
+netgear,wax214|\
 tplink,eap610-outdoor)
-       idx="$(find_mtd_index 0:appsblenv)"
-       [ -n "$idx" ] && \
-               ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x40000" "0x20000"
+       ubootenv_add_mtd "0:appsblenv" "0x0" "0x40000" "0x20000"
        ;;
 yuncore,fap650)
-       idx="$(find_mtd_index 0:appsblenv)"
-       [ -n "$idx" ] && \
-               ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x10000"
+       ubootenv_add_mtd "0:appsblenv" "0x0" "0x10000" "0x10000"
        ;;
 esac