treewide: sysupgrade: get rid of platform_nand_pre_upgrade()
authorRafał Miłecki <rafal@milecki.pl>
Wed, 17 Jul 2019 09:32:54 +0000 (11:32 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Mon, 22 Jul 2019 12:27:37 +0000 (14:27 +0200)
1) nand_do_upgrade() is always called by a target code
2) nand_do_upgrade() starts with calling platform_nand_pre_upgrade()

It means there is no need for the platform_nand_pre_upgrade() callback
at all. All code that was present there could bo moved & simplly called
by a target right before the nand_do_upgrade().

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
target/linux/ar71xx/base-files/lib/upgrade/platform.sh
target/linux/ipq40xx/base-files/lib/upgrade/platform.sh
target/linux/ipq806x/base-files/lib/upgrade/platform.sh
target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
target/linux/pistachio/base-files/lib/upgrade/platform.sh
target/linux/ramips/base-files/lib/upgrade/platform.sh
target/linux/ramips/base-files/lib/upgrade/ubnt.sh
target/linux/rb532/base-files/lib/upgrade/platform.sh

index 5de7af667fa940e57818f4e6b1a6d7d4ef122a71..6898c0e0c21a825d48eb9a997856caaa9e6233d1 100755 (executable)
@@ -746,36 +746,35 @@ platform_check_image() {
        return 1
 }
 
-platform_nand_pre_upgrade() {
-       local board=$(board_name)
+platform_do_upgrade_mikrotik_rb() {
+       CI_KERNPART=none
+       local fw_mtd=$(find_mtd_part kernel)
+       fw_mtd="${fw_mtd/block/}"
+       [ -n "$fw_mtd" ] || return
+       mtd erase kernel
+       tar xf "$1" sysupgrade-routerboard/kernel -O | nandwrite -o "$fw_mtd" -
+
+       nand_do_upgrade "$1"
+}
 
-       case "$board" in
-       rb*)
-               CI_KERNPART=none
-               local fw_mtd=$(find_mtd_part kernel)
-               fw_mtd="${fw_mtd/block/}"
-               [ -n "$fw_mtd" ] || return
-               mtd erase kernel
-               tar xf "$1" sysupgrade-routerboard/kernel -O | nandwrite -o "$fw_mtd" -
+platform_do_upgrade_nokia() {
+       case "$(fw_printenv -n dualPartition)" in
+               imgA)
+                       fw_setenv dualPartition imgB
+                       fw_setenv ActImg NokiaImageB
                ;;
-       wi2a-ac200i)
-               case "$(fw_printenv -n dualPartition)" in
-                       imgA)
-                               fw_setenv dualPartition imgB
-                               fw_setenv ActImg NokiaImageB
-                       ;;
-                       imgB)
-                               fw_setenv dualPartition imgA
-                               fw_setenv ActImg NokiaImageA
-                       ;;
-               esac
-               ubiblock -r /dev/ubiblock0_0 2>/dev/null >/dev/null
-               rm -f /dev/ubiblock0_0
-               ubidetach -d 0 2>/dev/null >/dev/null
-               CI_UBIPART=ubi_alt
-               CI_KERNPART=kernel_alt
+               imgB)
+                       fw_setenv dualPartition imgA
+                       fw_setenv ActImg NokiaImageA
                ;;
        esac
+       ubiblock -r /dev/ubiblock0_0 2>/dev/null >/dev/null
+       rm -f /dev/ubiblock0_0
+       ubidetach -d 0 2>/dev/null >/dev/null
+       CI_UBIPART=ubi_alt
+       CI_KERNPART=kernel_alt
+
+       nand_do_upgrade "$1"
 }
 
 platform_do_upgrade() {
@@ -859,6 +858,14 @@ platform_do_upgrade() {
        nbg6716|\
        r6100|\
        rambutan|\
+       wndr3700v4|\
+       wndr4300)
+               nand_do_upgrade "$1"
+               ;;
+       mr18|\
+       z1)
+               merakinand_do_upgrade "$1"
+               ;;
        rb-411|\
        rb-411u|\
        rb-433|\
@@ -890,21 +897,17 @@ platform_do_upgrade() {
        rb-2011uias-2hnd|\
        rb-2011uias-2hnd-r2|\
        rb-sxt2n|\
-       rb-sxt5n|\
-       wi2a-ac200i|\
-       wndr3700v4|\
-       wndr4300)
-               nand_do_upgrade "$1"
-               ;;
-       mr18|\
-       z1)
-               merakinand_do_upgrade "$1"
+       rb-sxt5n)
+               platform_do_upgrade_mikrotik_rb "$1"
                ;;
        uap-pro|\
        unifi-outdoor-plus)
                MTD_CONFIG_ARGS="-s 0x180000"
                default_do_upgrade "$1"
                ;;
+       wi2a-ac200i)
+               platform_do_upgrade_nokia "$1"
+               ;;
        wp543|\
        wpe72)
                platform_do_upgrade_compex "$1"
index a5e39c280c5f2b8fcedb3170b52fd9164f747e77..dac773d2fe1101b2eadcdbe9e9d76249f318545f 100644 (file)
@@ -47,12 +47,22 @@ zyxel_do_upgrade() {
 platform_do_upgrade() {
        case "$(board_name)" in
        8dev,jalapeno |\
-       alfa-network,ap120c-ac |\
        avm,fritzbox-7530 |\
        avm,fritzrepeater-3000 |\
        qxwlan,e2600ac-c2)
                nand_do_upgrade "$1"
                ;;
+       alfa-network,ap120c-ac)
+               part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
+               if [ "$part" = "rootfs1" ]; then
+                       fw_setenv active 2 || exit 1
+                       CI_UBIPART="rootfs2"
+               else
+                       fw_setenv active 1 || exit 1
+                       CI_UBIPART="rootfs1"
+               fi
+               nand_do_upgrade "$1"
+               ;;
        asus,map-ac2200)
                CI_KERNPART="linux"
                nand_do_upgrade "$1"
@@ -83,25 +93,3 @@ platform_do_upgrade() {
                ;;
        esac
 }
-
-platform_nand_pre_upgrade() {
-       case "$(board_name)" in
-       alfa-network,ap120c-ac)
-               part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
-               if [ "$part" = "rootfs1" ]; then
-                       fw_setenv active 2 || exit 1
-                       CI_UBIPART="rootfs2"
-               else
-                       fw_setenv active 1 || exit 1
-                       CI_UBIPART="rootfs1"
-               fi
-               ;;
-       asus,rt-ac58u)
-               CI_UBIPART="UBI_DEV"
-               CI_KERNPART="linux"
-               ;;
-       meraki,mr33)
-               CI_KERNPART="part.safe"
-               ;;
-       esac
-}
index 5919613cb9fb3a345fda729dcce3e5cc2fcf876a..b61047ff7000f37d5bf67e17564166b4714434b3 100644 (file)
@@ -21,10 +21,12 @@ platform_do_upgrade() {
        netgear,r7500v2 |\
        netgear,r7800 |\
        qcom,ipq8064-ap148 |\
-       qcom,ipq8064-ap161 |\
-       zyxel,nbg6817)
+       qcom,ipq8064-ap161)
                nand_do_upgrade "$1"
                ;;
+       zyxel,nbg6817)
+               zyxel_do_upgrade "$1"
+               ;;
        linksys,ea8500)
                platform_do_upgrade_linksys "$1"
                ;;
@@ -44,11 +46,3 @@ platform_do_upgrade() {
                ;;
        esac
 }
-
-platform_nand_pre_upgrade() {
-       case "$(board_name)" in
-       zyxel,nbg6817)
-               zyxel_do_upgrade "$1"
-               ;;
-       esac
-}
index ba8e825956fbe6f8a488ad201fffef6e25d6ffb0..33cd98339c3df73208434de0279d9bb441191c68 100644 (file)
@@ -118,5 +118,7 @@ zyxel_do_upgrade() {
 
        zyxel_do_flash $tar_file $kernel $rootfs $dualflagmtd
 
+       nand_do_upgrade "$1"
+
        return 0
 }
index 4de019a27cad08edd24b2ba9821afeb5166f6868..174c321d3828cc5c505b36f7304019e013c07ea8 100755 (executable)
@@ -26,10 +26,7 @@ platform_do_upgrade() {
        # stage2 directly but need to refactor nand_upgrade_success
        # for this to work.
        #   Also the nand functions don't allow url to be used
-       nand_do_upgrade $1
-}
 
-platform_nand_pre_upgrade() {
        local board=$(board_name)
 
        case "$board" in
@@ -48,4 +45,6 @@ platform_nand_pre_upgrade() {
                echo "Upgrading partition $CI_UBIPART (/dev/mtd$(find_mtd_index $CI_UBIPART))"
                ;;
        esac
+
+       nand_do_upgrade $1
 }
index ae7a72c6494f24388ef6f2545c587020edecd2aa..a65492a309276ae1a0e7b059e219865960ca3cba 100755 (executable)
@@ -9,17 +9,6 @@ platform_check_image() {
        return 0
 }
 
-platform_nand_pre_upgrade() {
-       local board=$(board_name)
-
-       case "$board" in
-       ubiquiti,edgerouterx|\
-       ubiquiti,edgerouterx-sfp)
-               platform_upgrade_ubnt_erx "$1"
-               ;;
-       esac
-}
-
 platform_do_upgrade() {
        local board=$(board_name)
 
@@ -35,8 +24,6 @@ platform_do_upgrade() {
        hiwifi,hc5962|\
        netgear,r6220|\
        netgear,r6350|\
-       ubiquiti,edgerouterx|\
-       ubiquiti,edgerouterx-sfp|\
        xiaomi,mir3g|\
        xiaomi,mir3p)
                nand_do_upgrade "$1"
@@ -45,6 +32,10 @@ platform_do_upgrade() {
                MTD_ARGS="-t romfile"
                default_do_upgrade "$1"
                ;;
+       ubiquiti,edgerouterx|\
+       ubiquiti,edgerouterx-sfp)
+               platform_upgrade_ubnt_erx "$1"
+               ;;
        *)
                default_do_upgrade "$1"
                ;;
index 316a70444fee18b542bf885ca6da0ba41bcd17d0..748ec8e6286ee6acf0fe6957308088935653fe6d 100644 (file)
@@ -73,4 +73,6 @@ platform_upgrade_ubnt_erx() {
        fi
 
        ubnt_update_target_kernel ${factory_mtd} ${kernel_part} || exit 1
+
+       nand_do_upgrade "$1"
 }
index a6a6e9b8d34267e2aa41f2a960534e739caeda96..334d6e2ff6c885509cfe500cd0190f11ea06015d 100644 (file)
@@ -10,11 +10,8 @@ platform_check_image() {
        return 0;
 }
 
-platform_nand_pre_upgrade() {
+platform_do_upgrade() {
        mtd erase kernel
        tar xf "$1" "sysupgrade-$(board_name)/kernel" -O | nandwrite -o /dev/mtd0 -
-}
-
-platform_do_upgrade() {
        nand_do_upgrade "$1"
 }