diff mbox series

[v2,4/4] EFI: FMP: Use a common GetImageInfo function for FIT and raw images

Message ID 20220601180041.340240-5-sughosh.ganu@linaro.org
State Accepted
Commit 556a12654a3350113edbd826cbcdde4c03cb7f20
Headers show
Series EFI: Miscellaneous capsule update fixes | expand

Commit Message

Sughosh Ganu June 1, 2022, 6 p.m. UTC
The GetImageInfo function definitions for the FIT images and raw
images are the same. Use a common function for the both the Firmware
Management Protocol(FMP) instances for raw and FIT images.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---

Changes since V1: None

 lib/efi_loader/efi_firmware.c | 80 ++++++-----------------------------
 1 file changed, 14 insertions(+), 66 deletions(-)
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
index 9cdefab41f..0ffee3fb1f 100644
--- a/lib/efi_loader/efi_firmware.c
+++ b/lib/efi_loader/efi_firmware.c
@@ -177,18 +177,8 @@  static efi_status_t efi_fill_image_desc_array(
 	return EFI_SUCCESS;
 }
 
-#ifdef CONFIG_EFI_CAPSULE_FIRMWARE_FIT
-/*
- * This FIRMWARE_MANAGEMENT_PROTOCOL driver provides a firmware update
- * method with existing FIT image format, and handles
- *   - multiple regions of firmware via DFU
- * but doesn't support
- *   - versioning of firmware image
- *   - package information
- */
-
 /**
- * efi_firmware_fit_get_image_info - return information about the current
+ * efi_firmware_get_image_info - return information about the current
  *				     firmware image
  * @this:			Protocol instance
  * @image_info_size:		Size of @image_info
@@ -206,7 +196,7 @@  static efi_status_t efi_fill_image_desc_array(
  * Return		status code
  */
 static
-efi_status_t EFIAPI efi_firmware_fit_get_image_info(
+efi_status_t EFIAPI efi_firmware_get_image_info(
 	struct efi_firmware_management_protocol *this,
 	efi_uintn_t *image_info_size,
 	struct efi_firmware_image_descriptor *image_info,
@@ -239,6 +229,16 @@  efi_status_t EFIAPI efi_firmware_fit_get_image_info(
 	return EFI_EXIT(ret);
 }
 
+#ifdef CONFIG_EFI_CAPSULE_FIRMWARE_FIT
+/*
+ * This FIRMWARE_MANAGEMENT_PROTOCOL driver provides a firmware update
+ * method with existing FIT image format, and handles
+ *   - multiple regions of firmware via DFU
+ * but doesn't support
+ *   - versioning of firmware image
+ *   - package information
+ */
+
 /**
  * efi_firmware_fit_set_image - update the firmware image
  * @this:		Protocol instance
@@ -278,7 +278,7 @@  efi_status_t EFIAPI efi_firmware_fit_set_image(
 }
 
 const struct efi_firmware_management_protocol efi_fmp_fit = {
-	.get_image_info = efi_firmware_fit_get_image_info,
+	.get_image_info = efi_firmware_get_image_info,
 	.get_image = efi_firmware_get_image_unsupported,
 	.set_image = efi_firmware_fit_set_image,
 	.check_image = efi_firmware_check_image_unsupported,
@@ -293,58 +293,6 @@  const struct efi_firmware_management_protocol efi_fmp_fit = {
  * method with raw data.
  */
 
-/**
- * efi_firmware_raw_get_image_info - return information about the current
- *				     firmware image
- * @this:			Protocol instance
- * @image_info_size:		Size of @image_info
- * @image_info:			Image information
- * @descriptor_version:		Pointer to version number
- * @descriptor_count:		Pointer to number of descriptors
- * @descriptor_size:		Pointer to descriptor size
- * @package_version:		Package version
- * @package_version_name:	Package version's name
- *
- * Return information bout the current firmware image in @image_info.
- * @image_info will consist of a number of descriptors.
- * Each descriptor will be created based on "dfu_alt_info" variable.
- *
- * Return		status code
- */
-static
-efi_status_t EFIAPI efi_firmware_raw_get_image_info(
-	struct efi_firmware_management_protocol *this,
-	efi_uintn_t *image_info_size,
-	struct efi_firmware_image_descriptor *image_info,
-	u32 *descriptor_version,
-	u8 *descriptor_count,
-	efi_uintn_t *descriptor_size,
-	u32 *package_version,
-	u16 **package_version_name)
-{
-	efi_status_t ret = EFI_SUCCESS;
-
-	EFI_ENTRY("%p %p %p %p %p %p %p %p\n", this,
-		  image_info_size, image_info,
-		  descriptor_version, descriptor_count, descriptor_size,
-		  package_version, package_version_name);
-
-	if (!image_info_size)
-		return EFI_EXIT(EFI_INVALID_PARAMETER);
-
-	if (*image_info_size &&
-	    (!image_info || !descriptor_version || !descriptor_count ||
-	     !descriptor_size || !package_version || !package_version_name))
-		return EFI_EXIT(EFI_INVALID_PARAMETER);
-
-	ret = efi_fill_image_desc_array(image_info_size, image_info,
-					descriptor_version, descriptor_count,
-					descriptor_size, package_version,
-					package_version_name);
-
-	return EFI_EXIT(ret);
-}
-
 /**
  * efi_firmware_raw_set_image - update the firmware image
  * @this:		Protocol instance
@@ -430,7 +378,7 @@  efi_status_t EFIAPI efi_firmware_raw_set_image(
 }
 
 const struct efi_firmware_management_protocol efi_fmp_raw = {
-	.get_image_info = efi_firmware_raw_get_image_info,
+	.get_image_info = efi_firmware_get_image_info,
 	.get_image = efi_firmware_get_image_unsupported,
 	.set_image = efi_firmware_raw_set_image,
 	.check_image = efi_firmware_check_image_unsupported,