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 5de7af6..6898c0e 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 a5e39c2..dac773d 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 5919613..b61047f 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 ba8e825..33cd983 100644 (file)
@@ -118,5 +118,7 @@ zyxel_do_upgrade() {
 
        zyxel_do_flash $tar_file $kernel $rootfs $dualflagmtd
 
+       nand_do_upgrade "$1"
+
        return 0
 }
index 4de019a..174c321 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 ae7a72c..a65492a 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 316a704..748ec8e 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 a6a6e9b..334d6e2 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"
 }