board: artik530_raptor: factor out update_partition_env
authorChanho Park <chanho61.park@samsung.com>
Mon, 24 Apr 2017 12:17:39 +0000 (21:17 +0900)
committerChanho Park <chanho61.park@samsung.com>
Mon, 24 Apr 2017 12:17:39 +0000 (21:17 +0900)
This patch factors out duplicate codes from ota codes of artik530.

Change-Id: I71cabd52f8dff216176e32668454a913a7e93e56
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
board/s5p4418/artik530_raptor/ota.c

index 06693409e1cbb4cde64eac739056e78d2041d38f..9f4f1f892164b8cd8d1de004da6a2b6efbb958da 100644 (file)
@@ -30,6 +30,14 @@ static struct boot_info *read_flag_partition(void)
                        CONFIG_FLAG_INFO_ADDR, sizeof(struct boot_info));
 }
 
+static inline void update_partition_env(enum boot_part part_num)
+{
+       if (part_num == PART0)
+               setenv("bootpart", __stringify(CONFIG_BOOT_PART));
+       else
+               setenv("bootpart", __stringify(CONFIG_BOOT1_PART));
+}
+
 int check_ota_update(void)
 {
        struct boot_info *boot;
@@ -73,10 +81,7 @@ int check_ota_update(void)
        switch (boot->state) {
        case BOOT_SUCCESS:
                printf("Booting State = Normal(%d)\n", boot->part_num);
-               if (boot->part_num == PART0)
-                       setenv("bootpart", __stringify(CONFIG_BOOT_PART));
-               else
-                       setenv("bootpart", __stringify(CONFIG_BOOT1_PART));
+               update_partition_env(boot->part_num);
                setenv("rescue", "0");
                break;
        case BOOT_UPDATED:
@@ -103,16 +108,13 @@ int check_ota_update(void)
                        }
                }
 
-               if (boot->part_num == PART0)
-                       setenv("bootpart", __stringify(CONFIG_BOOT_PART));
-               else
-                       setenv("bootpart", __stringify(CONFIG_BOOT1_PART));
+               update_partition_env(boot->part_num);
                write_flag_partition();
                break;
        case BOOT_FAILED:
        default:
                printf("Booting State = Abnormal\n");
-               setenv("bootpart", __stringify(CONFIG_BOOT_PART));
+               update_partition_env(PART0);
                return -1;
        }