part_efi: update part_get_info_efi() to reuse part info
We use part_get_info_by_name to get partition, this will read MBR, GPT header and GPT entry every time, optimize to read only once. Change-Id: I4d6c508311f7cc661aa991b3c61460a2b8d63fac Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
This commit is contained in:
parent
9edad0e877
commit
db8cda52f5
|
|
@ -269,8 +269,15 @@ void part_print_efi(struct blk_desc *dev_desc)
|
||||||
int part_get_info_efi(struct blk_desc *dev_desc, int part,
|
int part_get_info_efi(struct blk_desc *dev_desc, int part,
|
||||||
disk_partition_t *info)
|
disk_partition_t *info)
|
||||||
{
|
{
|
||||||
ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz);
|
static gpt_entry *gpt_pte = NULL;
|
||||||
gpt_entry *gpt_pte = NULL;
|
static gpt_header *gpt_head = NULL;
|
||||||
|
|
||||||
|
if (!gpt_head)
|
||||||
|
gpt_head = memalign(ARCH_DMA_MINALIGN, dev_desc->blksz);
|
||||||
|
|
||||||
|
/* We suppose different dev have different size, eg. emmc vs sd */
|
||||||
|
if (!gpt_head && (gpt_head->last_usable_lba + 0x22) != dev_desc->lba)
|
||||||
|
gpt_pte = NULL;
|
||||||
|
|
||||||
/* "part" argument must be at least 1 */
|
/* "part" argument must be at least 1 */
|
||||||
if (part < 1) {
|
if (part < 1) {
|
||||||
|
|
@ -297,7 +304,6 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
|
||||||
!is_pte_valid(&gpt_pte[part - 1])) {
|
!is_pte_valid(&gpt_pte[part - 1])) {
|
||||||
debug("%s: *** ERROR: Invalid partition number %d ***\n",
|
debug("%s: *** ERROR: Invalid partition number %d ***\n",
|
||||||
__func__, part);
|
__func__, part);
|
||||||
free(gpt_pte);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,8 +330,6 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
|
||||||
debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s\n", __func__,
|
debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s\n", __func__,
|
||||||
info->start, info->size, info->name);
|
info->start, info->size, info->name);
|
||||||
|
|
||||||
/* Remember to free pte */
|
|
||||||
free(gpt_pte);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -939,6 +943,10 @@ static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Re-use pte if it's not NULL */
|
||||||
|
if (*pgpt_pte)
|
||||||
|
return 1;
|
||||||
|
|
||||||
ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, dev_desc->blksz);
|
ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, dev_desc->blksz);
|
||||||
|
|
||||||
/* Read MBR Header from device */
|
/* Read MBR Header from device */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue