diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-19 09:31:30 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-20 11:46:30 +0100 |
commit | 1018f6c694f0561028af3496530316e9db32e3a4 (patch) | |
tree | af8414168118d57cab6bb7f572709c4e47321997 /common/partitions/efi.c | |
parent | 4accc68d2d5155074455109f5889f8c00b30eafc (diff) | |
download | barebox-1018f6c694f0561028af3496530316e9db32e3a4.tar.gz barebox-1018f6c694f0561028af3496530316e9db32e3a4.tar.xz |
partition: allocate struct partition_desc in parser
Allocate struct partition_desc in parser rather than in the core. Doing
so allows the efi/dos partition code to embed the struct partition_desc
is a efi/dos specific struct type.
Link: https://lore.barebox.org/20240219083140.2713047-3-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/partitions/efi.c')
-rw-r--r-- | common/partitions/efi.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/common/partitions/efi.c b/common/partitions/efi.c index d0e14d5abb..effe512949 100644 --- a/common/partitions/efi.c +++ b/common/partitions/efi.c @@ -431,14 +431,14 @@ static void part_set_efi_name(gpt_entry *pte, char *dest) dest[i] = 0; } -static void efi_partition(void *buf, struct block_device *blk, - struct partition_desc *pd) +static struct partition_desc *efi_partition(void *buf, struct block_device *blk) { gpt_header *gpt = NULL; gpt_entry *ptes = NULL; int i = 0; int nb_part; struct partition *pentry; + struct partition_desc *pd; if (!find_valid_gpt(buf, blk, &gpt, &ptes) || !gpt || !ptes) goto out; @@ -456,6 +456,8 @@ static void efi_partition(void *buf, struct block_device *blk, nb_part = MAX_PARTITION; } + pd = xzalloc(sizeof(*pd)); + for (i = 0; i < nb_part; i++) { if (!is_pte_valid(&ptes[i], last_lba(blk))) { dev_dbg(blk->dev, "Invalid pte %d\n", i); @@ -474,10 +476,18 @@ static void efi_partition(void *buf, struct block_device *blk, out: kfree(gpt); kfree(ptes); + + return pd; +} + +static void efi_partition_free(struct partition_desc *pd) +{ + free(pd); } static struct partition_parser efi_partition_parser = { .parse = efi_partition, + .partition_free = efi_partition_free, .type = filetype_gpt, }; |