[U-Boot] [PATCH v5 06/16] disk: part: efi: export internal function

Patrick Delaunay patrick.delaunay at st.com
Thu Apr 13 09:52:44 UTC 2017


export the needed functions for GPT over MTD

Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
Reviewed-by: Christophe KERELLO <christophe.kerello at st.com>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 disk/part_efi.c     | 32 +++++++++-----------------------
 disk/part_efi_int.h | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 23 deletions(-)
 create mode 100644 disk/part_efi_int.h

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 1f3f0ca..e27761b 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -21,22 +21,11 @@
 #include <part_efi.h>
 #include <linux/compiler.h>
 #include <linux/ctype.h>
+#include "part_efi_int.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef HAVE_BLOCK_DEVICE
-/**
- * efi_crc32() - EFI version of crc32 function
- * @buf: buffer to calculate crc32 of
- * @len - length of buf
- *
- * Description: Returns EFI-style CRC32 value for @buf
- */
-static inline u32 efi_crc32(const void *buf, u32 len)
-{
-	return crc32(0, buf, len);
-}
-
 /*
  * Private function prototypes
  */
@@ -47,7 +36,6 @@ static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
 				gpt_header *pgpt_head, gpt_entry **pgpt_pte);
 static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
 					 gpt_header *pgpt_head);
-static int is_pte_valid(gpt_entry * pte);
 
 static char *print_efiname(gpt_entry *pte)
 {
@@ -72,8 +60,7 @@ static inline int is_bootable(gpt_entry *p)
 			sizeof(efi_guid_t));
 }
 
-static int validate_gpt_header(gpt_header *gpt_h, lbaint_t lba,
-		lbaint_t lastlba)
+int validate_gpt_header(gpt_header *gpt_h, lbaint_t lba, lbaint_t lastlba)
 {
 	uint32_t crc32_backup = 0;
 	uint32_t calc_crc32;
@@ -135,7 +122,7 @@ static int validate_gpt_header(gpt_header *gpt_h, lbaint_t lba,
 	return 0;
 }
 
-static int validate_gpt_entries(gpt_header *gpt_h, gpt_entry *gpt_e)
+int validate_gpt_entries(gpt_header *gpt_h, gpt_entry *gpt_e)
 {
 	uint32_t calc_crc32;
 
@@ -155,8 +142,8 @@ static int validate_gpt_entries(gpt_header *gpt_h, gpt_entry *gpt_e)
 	return 0;
 }
 
-static void prepare_backup_gpt_header(gpt_header *gpt_h,
-				      const int pte_blk_cnt)
+void prepare_backup_gpt_header(gpt_header *gpt_h,
+			       const int pte_blk_cnt)
 {
 	uint32_t calc_crc32;
 	uint64_t val;
@@ -174,8 +161,7 @@ static void prepare_backup_gpt_header(gpt_header *gpt_h,
 }
 
 #if CONFIG_IS_ENABLED(EFI_PARTITION)
-static void part_print_gpt(gpt_header *gpt_head,
-			   gpt_entry *gpt_pte)
+void part_print_gpt(gpt_header *gpt_head, gpt_entry *gpt_pte)
 {
 	int i = 0;
 	char uuid[37];
@@ -209,8 +195,8 @@ static void part_print_gpt(gpt_header *gpt_head,
 	}
 }
 
-static void part_get_disk_info(int part, unsigned int blksz,
-			       gpt_entry *gpt_pte, disk_partition_t *info)
+void part_get_disk_info(int part, unsigned int blksz,
+			gpt_entry *gpt_pte, disk_partition_t *info)
 {
 	/* The 'lbaint_t' casting may limit the maximum disk size to 2 TB */
 	info->start = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].starting_lba);
@@ -969,7 +955,7 @@ static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
  *
  * Description: returns 1 if valid,  0 on error.
  */
-static int is_pte_valid(gpt_entry * pte)
+int is_pte_valid(gpt_entry *pte)
 {
 	efi_guid_t unused_guid;
 
diff --git a/disk/part_efi_int.h b/disk/part_efi_int.h
new file mode 100644
index 0000000..fb63908
--- /dev/null
+++ b/disk/part_efi_int.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 STMicroelectronics .
+ * Patrick Delaunay <patrick.delaunay at st.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _DISK_PART_EFI_INT_H
+#define _DISK_PART_EFI_INT_H
+
+/*
+ * efi_crc32() - EFI version of crc32 function
+ * @buf: buffer to calculate crc32 of
+ * @len - length of buf
+ *
+ * Description: Returns EFI-style CRC32 value for @buf
+ */
+static inline u32 efi_crc32(const void *buf, u32 len)
+{
+	return crc32(0, buf, len);
+}
+
+int validate_gpt_header(gpt_header *gpt_h, lbaint_t lba, lbaint_t lastlba);
+int validate_gpt_entries(gpt_header *gpt_h, gpt_entry *gpt_e);
+
+int is_pte_valid(gpt_entry *pte);
+
+void prepare_backup_gpt_header(gpt_header *gpt_h,
+			       const int pte_blk_cnt);
+
+void part_print_gpt(gpt_header *gpt_head, gpt_entry *gpt_pte);
+
+void part_get_disk_info(int part, unsigned int blksz,
+			gpt_entry *gpt_pte, disk_partition_t *info);
+
+#endif /* _DISK_PART_EFI_INT_H */
-- 
1.9.1



More information about the U-Boot mailing list