mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 02:05:01 +00:00
Refactor LoadFirmware() and LoadKernel() to return VbError_t
BUG=chromium-os:18161 TEST=make && make runtests Change-Id: I1f60654fef84e26ee15fa8bdaacdb87fb1ddf69e Reviewed-on: http://gerrit.chromium.org/gerrit/4676 Reviewed-by: Stefan Reinauer <reinauer@chromium.org> Tested-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
@@ -342,7 +342,7 @@ static VbError_t VbCheckDisplayKey(VbCommonParams* cparams, uint32_t key) {
|
||||
* May return other VBERROR_ codes for other failures. */
|
||||
uint32_t VbTryLoadKernel(VbCommonParams* cparams, LoadKernelParams* p,
|
||||
uint32_t get_info_flags) {
|
||||
int lk_retval = LOAD_KERNEL_RECOVERY;
|
||||
int retval = VBERROR_UNKNOWN;
|
||||
VbDiskInfo* disk_info = NULL;
|
||||
uint32_t disk_count = 0;
|
||||
uint32_t i;
|
||||
@@ -369,38 +369,25 @@ uint32_t VbTryLoadKernel(VbCommonParams* cparams, LoadKernelParams* p,
|
||||
p->disk_handle = disk_info[i].handle;
|
||||
p->bytes_per_lba = disk_info[i].bytes_per_lba;
|
||||
p->ending_lba = disk_info[i].lba_count - 1;
|
||||
lk_retval = LoadKernel(p);
|
||||
VBDEBUG(("VbTryLoadKernel() LoadKernel() returned %d\n", lk_retval));
|
||||
retval = LoadKernel(p);
|
||||
VBDEBUG(("VbTryLoadKernel() LoadKernel() returned %d\n", retval));
|
||||
|
||||
/* Stop now if we found a kernel */
|
||||
/* TODO: If recovery requested, should track the farthest we get, instead
|
||||
* of just returning the value from the last disk attempted. */
|
||||
if (LOAD_KERNEL_SUCCESS == lk_retval)
|
||||
if (VBERROR_SUCCESS == retval)
|
||||
break;
|
||||
}
|
||||
|
||||
/* If we didn't succeed, don't return a disk handle */
|
||||
if (LOAD_KERNEL_SUCCESS != lk_retval)
|
||||
if (VBERROR_SUCCESS != retval)
|
||||
p->disk_handle = NULL;
|
||||
|
||||
VbExDiskFreeInfo(disk_info, p->disk_handle);
|
||||
|
||||
/* Translate return codes */
|
||||
switch (lk_retval) {
|
||||
case LOAD_KERNEL_SUCCESS:
|
||||
return VBERROR_SUCCESS;
|
||||
case LOAD_KERNEL_NOT_FOUND:
|
||||
VbSetRecoveryRequest(VBNV_RECOVERY_RW_NO_OS);
|
||||
return VBERROR_NO_KERNEL_FOUND;
|
||||
case LOAD_KERNEL_INVALID:
|
||||
VbSetRecoveryRequest(VBNV_RECOVERY_RW_INVALID_OS);
|
||||
return VBERROR_INVALID_KERNEL_FOUND;
|
||||
case LOAD_KERNEL_RECOVERY:
|
||||
return VBERROR_LOAD_KERNEL_RECOVERY;
|
||||
default:
|
||||
VbSetRecoveryRequest(VBNV_RECOVERY_RW_UNSPECIFIED);
|
||||
return VBERROR_LOAD_KERNEL;
|
||||
}
|
||||
/* Pass through return code. Recovery reason (if any) has already been set
|
||||
* by LoadKernel(). */
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user