summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaveen Ramaraj <nramaraj@codeaurora.org>2016-05-09 21:17:33 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-05-09 21:17:33 +0000
commit7c0048ae2a99123d29320686cda1a225e0e48744 (patch)
treed54d6c6eb020d45df13562761143a20ebde48ecd
parent230353fe3bcadd1b7cf748005f1220c6c445963c (diff)
parent0101a647e4da4163e8438f35ece8485692abafc9 (diff)
downloadandroid_hardware_qcom_bootctrl-7c0048ae2a99123d29320686cda1a225e0e48744.tar.gz
android_hardware_qcom_bootctrl-7c0048ae2a99123d29320686cda1a225e0e48744.tar.bz2
android_hardware_qcom_bootctrl-7c0048ae2a99123d29320686cda1a225e0e48744.zip
bootcontrol: Update a check in set_active_boot_slot am: 710b9bfa09
am: 0101a647e4 * commit '0101a647e4da4163e8438f35ece8485692abafc9': bootcontrol: Update a check in set_active_boot_slot Change-Id: Ia048be7aea6c8a43268ac24c6055e94ea7f5c805
-rw-r--r--boot_control.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/boot_control.c b/boot_control.c
index 6fa066d..d5e2e4b 100644
--- a/boot_control.c
+++ b/boot_control.c
@@ -294,6 +294,38 @@ error:
return 0;
}
+static unsigned get_current_active_slot(struct boot_control_module *module)
+{
+ uint32_t num_slots = 0;
+ char bootPartition[MAX_GPT_NAME_SIZE + 1];
+ unsigned i = 0;
+ if (!module) {
+ ALOGE("%s: Invalid argument", __func__);
+ goto error;
+ }
+ num_slots = get_number_slots(module);
+ if (num_slots <= 1) {
+ //Slot 0 is the only slot around.
+ return 0;
+ }
+ //Iterate through a list of partitons named as boot+suffix
+ //and see which one is currently active.
+ for (i = 0; slot_suffix_arr[i] != NULL ; i++) {
+ memset(bootPartition, '\0', sizeof(bootPartition));
+ snprintf(bootPartition, sizeof(bootPartition) - 1,
+ "boot%s",
+ slot_suffix_arr[i]);
+ if (get_partition_attribute(bootPartition,
+ ATTR_SLOT_ACTIVE) == 1)
+ return i;
+ }
+error:
+ //The HAL spec requires that we return a number between
+ //0 to num_slots - 1. Since something went wrong here we
+ //are just going to return the default slot.
+ return 0;
+}
+
int mark_boot_successful(struct boot_control_module *module)
{
unsigned cur_slot = 0;
@@ -358,7 +390,7 @@ int set_active_boot_slot(struct boot_control_module *module, unsigned slot)
__func__);
goto error;
}
- current_slot = get_current_slot(module);
+ current_slot = get_current_active_slot(module);
if (current_slot == slot) {
//Nothing to do here. Just return
return 0;