Skip to content

Commit

Permalink
Skip registering erase blocks protocol if storage type is not virtual
Browse files Browse the repository at this point in the history
We only initialize erase blocks in virtual storage case, since there is
no callback function for other storage types(mmc, ufs and nvme).Otherwise
it will bring out "EFI_ERASE_BLOCK_PROTOCOL failed to erase block"
error log while erasing.

Change-Id: Iffb6582d81814cf7ef055221d66f08e265517165
Tracked-On: https://jira.devtools.intel.com/browse/OAM-83031
Signed-off-by: Yang, Kai <[email protected]>
Reviewed-on: https://android.intel.com:443/672993
  • Loading branch information
yang-kaix authored and buildslave committed Jun 27, 2019
1 parent b2f35ff commit 509c793
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/libefiwrapper/external.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void *memset(void *s, int c, size_t n);
char *strdup(const char *s);
size_t strlen(const char *s);
char *strncat(char *dest, const char *src, size_t n);
int strcmp(const char *s1, const char *s2);
int strncmp(const char *s1, const char *s2, size_t n);

/* stdio.h */
Expand Down
10 changes: 10 additions & 0 deletions libefiwrapper/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ EFI_STATUS storage_init(EFI_SYSTEM_TABLE *st, storage_t *storage,
EFI_HANDLE *handle)
{
EFI_STATUS ret, tmp_ret;
int res;
size_t i, j;
media_t *media;

Expand All @@ -171,6 +172,10 @@ EFI_STATUS storage_init(EFI_SYSTEM_TABLE *st, storage_t *storage,

*handle = NULL;
for (i = 0; i < ARRAY_SIZE(STORAGE_INTERFACES); i++) {
res = strcmp("eraseblock", STORAGE_INTERFACES[i].name);
if (!res && (boot_dev.type != STORAGE_VIRTUAL))
continue;

ret = STORAGE_INTERFACES[i].init(st, media, handle);
if (EFI_ERROR(ret)) {
ewerr("Failed to register %s interface",
Expand All @@ -196,11 +201,16 @@ EFI_STATUS storage_free(EFI_SYSTEM_TABLE *st, EFI_HANDLE handle)
{
EFI_STATUS ret;
size_t i;
int res;

if (!st || !handle)
return EFI_INVALID_PARAMETER;

for (i = 0; i < ARRAY_SIZE(STORAGE_INTERFACES); i++) {
res = strcmp("eraseblock", STORAGE_INTERFACES[i].name);
if (!res && (boot_dev.type != STORAGE_VIRTUAL))
continue;

ret = STORAGE_INTERFACES[i].free(st, handle);
if (EFI_ERROR(ret)) {
ewerr("Failed to unregister %s interface",
Expand Down

0 comments on commit 509c793

Please sign in to comment.