Attention is currently required from: Jakub Czapiga, Tim Wawrzynczak, Felix Held. Hello Jakub Czapiga, Tim Wawrzynczak, Felix Held,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/62600
to review the following change.
Change subject: commonlib/bsd: Remove cb_err_t ......................................................................
commonlib/bsd: Remove cb_err_t
cb_err_t was meant to be used in place of `enum cb_err` in all situations, but the choice to use a typedef here seems to be controversial. We should not be arbitrarily using two different identifiers for the same thing across the codebase, so since there are no use cases for serializing enum cb_err at the moment (which would be the primary reason to typedef a fixed-width integer instead), remove cb_err_t again for now.
Signed-off-by: Julius Werner jwerner@chromium.org Change-Id: Iaec36210d129db26d51f0a105d3de070c03b686b --- M payloads/libpayload/include/fmap.h M payloads/libpayload/libc/fmap.c M payloads/libpayload/libcbfs/cbfs.c M payloads/libpayload/tests/libcbfs/cbfs-lookup-test.c M payloads/libpayload/tests/libcbfs/cbfs-verification-test.c M src/commonlib/bsd/cbfs_mcache.c M src/commonlib/bsd/cbfs_private.c M src/commonlib/bsd/include/commonlib/bsd/cb_err.h M src/commonlib/bsd/include/commonlib/bsd/cbfs_private.h M src/drivers/mipi/panel.c M src/drivers/parade/ps8640/ps8640.c M src/drivers/ti/sn65dsi86bridge/sn65dsi86bridge.c M src/include/cbfs.h M src/include/mipi/panel.h M src/lib/cbfs.c M src/security/vboot/vboot_loader.c M src/soc/mediatek/common/dsi.c M src/soc/qualcomm/sc7180/display/dsi.c M src/soc/qualcomm/sc7180/include/soc/display/mipi_dsi.h M tests/lib/cbfs-lookup-test.c M tests/lib/cbfs-verification-test.c M util/cbfstool/cbfstool.c 22 files changed, 110 insertions(+), 113 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/00/62600/1
diff --git a/payloads/libpayload/include/fmap.h b/payloads/libpayload/include/fmap.h index 53ebe23..02705c2 100644 --- a/payloads/libpayload/include/fmap.h +++ b/payloads/libpayload/include/fmap.h @@ -7,6 +7,6 @@ #include <stddef.h>
/* Looks for area with |name| in FlashMap. Requires lib_sysinfo.fmap_cache. */ -cb_err_t fmap_locate_area(const char *name, size_t *offset, size_t *size); +enum cb_err fmap_locate_area(const char *name, size_t *offset, size_t *size);
#endif /* _FMAP_H */ diff --git a/payloads/libpayload/libc/fmap.c b/payloads/libpayload/libc/fmap.c index 2d185a7..52fd31d 100644 --- a/payloads/libpayload/libc/fmap.c +++ b/payloads/libpayload/libc/fmap.c @@ -38,7 +38,7 @@ /* Private fmap cache. */ static struct fmap *_fmap_cache;
-static cb_err_t fmap_find_area(struct fmap *fmap, const char *name, size_t *offset, +static enum cb_err fmap_find_area(struct fmap *fmap, const char *name, size_t *offset, size_t *size) { for (size_t i = 0; i < le32toh(fmap->nareas); ++i) { @@ -71,7 +71,7 @@ return false; }
-cb_err_t fmap_locate_area(const char *name, size_t *offset, size_t *size) +enum cb_err fmap_locate_area(const char *name, size_t *offset, size_t *size) { if (!_fmap_cache && !fmap_setup_cache()) return CB_ERR; diff --git a/payloads/libpayload/libcbfs/cbfs.c b/payloads/libpayload/libcbfs/cbfs.c index 44173c8..9e88364 100644 --- a/payloads/libpayload/libcbfs/cbfs.c +++ b/payloads/libpayload/libcbfs/cbfs.c @@ -48,7 +48,7 @@ return CB_ERR;
size_t data_offset; - cb_err_t err = CB_CBFS_CACHE_FULL; + enum cb_err err = CB_CBFS_CACHE_FULL; if (cbd->mcache_size) err = cbfs_mcache_lookup(cbd->mcache, cbd->mcache_size, name, mdata, &data_offset); diff --git a/payloads/libpayload/tests/libcbfs/cbfs-lookup-test.c b/payloads/libpayload/tests/libcbfs/cbfs-lookup-test.c index 0f84076..85690bf 100644 --- a/payloads/libpayload/tests/libcbfs/cbfs-lookup-test.c +++ b/payloads/libpayload/tests/libcbfs/cbfs-lookup-test.c @@ -40,7 +40,7 @@
static size_t test_fmap_offset = 0; static size_t test_fmap_size = 0; -static cb_err_t test_fmap_result = CB_SUCCESS; +static enum cb_err test_fmap_result = CB_SUCCESS;
static void set_fmap_locate_area_results(size_t offset, size_t size, size_t result) { @@ -49,14 +49,14 @@ test_fmap_result = result; }
-cb_err_t fmap_locate_area(const char *name, size_t *offset, size_t *size) +enum cb_err fmap_locate_area(const char *name, size_t *offset, size_t *size) { *offset = test_fmap_offset; *size = test_fmap_size; return test_fmap_result; }
-cb_err_t cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char *name, +enum cb_err cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char *name, union cbfs_mdata *mdata_out, size_t *data_offset_out) { assert_non_null(mcache); @@ -66,7 +66,7 @@
check_expected(name);
- cb_err_t ret = mock_type(cb_err_t); + enum cb_err ret = mock_type(enum cb_err); if (ret != CB_SUCCESS) return ret;
@@ -75,7 +75,7 @@ return CB_SUCCESS; }
-static void expect_cbfs_mcache_lookup(const char *name, cb_err_t err, +static void expect_cbfs_mcache_lookup(const char *name, enum cb_err err, const union cbfs_mdata *mdata, size_t data_offset_out) { expect_string(cbfs_mcache_lookup, name, name); @@ -87,13 +87,13 @@ } }
-cb_err_t cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, +enum cb_err cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, size_t *data_offset_out, struct vb2_hash *metadata_hash) { assert_non_null(dev); check_expected(name);
- cb_err_t ret = mock_type(cb_err_t); + enum cb_err ret = mock_type(enum cb_err); if (ret != CB_SUCCESS) return ret;
@@ -102,7 +102,7 @@ return CB_SUCCESS; }
-static void expect_cbfs_lookup(const char *name, cb_err_t err, const union cbfs_mdata *mdata, +static void expect_cbfs_lookup(const char *name, enum cb_err err, const union cbfs_mdata *mdata, size_t data_offset_out) { expect_string(cbfs_lookup, name, name); diff --git a/payloads/libpayload/tests/libcbfs/cbfs-verification-test.c b/payloads/libpayload/tests/libcbfs/cbfs-verification-test.c index 2ab3d53..4af2b39 100644 --- a/payloads/libpayload/tests/libcbfs/cbfs-verification-test.c +++ b/payloads/libpayload/tests/libcbfs/cbfs-verification-test.c @@ -53,19 +53,19 @@ return 0; }
-cb_err_t cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char *name, +enum cb_err cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char *name, union cbfs_mdata *mdata_out, size_t *data_offset_out) { return CB_CBFS_CACHE_FULL; }
-cb_err_t cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, +enum cb_err cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, size_t *data_offset_out, struct vb2_hash *metadata_hash) { assert_non_null(dev); check_expected(name);
- cb_err_t ret = mock_type(cb_err_t); + enum cb_err ret = mock_type(enum cb_err); if (ret != CB_SUCCESS) return ret;
@@ -74,7 +74,7 @@ return CB_SUCCESS; }
-static void expect_cbfs_lookup(const char *name, cb_err_t err, const union cbfs_mdata *mdata, +static void expect_cbfs_lookup(const char *name, enum cb_err err, const union cbfs_mdata *mdata, size_t data_offset_out) { expect_string(cbfs_lookup, name, name); @@ -91,7 +91,7 @@ return mock_ptr_type(void *); }
-cb_err_t fmap_locate_area(const char *name, size_t *offset, size_t *size) +enum cb_err fmap_locate_area(const char *name, size_t *offset, size_t *size) { *offset = 0; *size = 0; diff --git a/src/commonlib/bsd/cbfs_mcache.c b/src/commonlib/bsd/cbfs_mcache.c index 965f9fa..0e84f0f 100644 --- a/src/commonlib/bsd/cbfs_mcache.c +++ b/src/commonlib/bsd/cbfs_mcache.c @@ -40,7 +40,7 @@ int count; };
-static cb_err_t build_walker(cbfs_dev_t dev, size_t offset, const union cbfs_mdata *mdata, +static enum cb_err build_walker(cbfs_dev_t dev, size_t offset, const union cbfs_mdata *mdata, size_t already_read, void *arg) { struct cbfs_mcache_build_args *args = arg; @@ -62,8 +62,8 @@ return CB_CBFS_NOT_FOUND; }
-cb_err_t cbfs_mcache_build(cbfs_dev_t dev, void *mcache, size_t size, - struct vb2_hash *metadata_hash) +enum cb_err cbfs_mcache_build(cbfs_dev_t dev, void *mcache, size_t size, + struct vb2_hash *metadata_hash) { struct cbfs_mcache_build_args args = { .mcache = mcache, @@ -73,7 +73,7 @@ };
assert(size > sizeof(uint32_t) && IS_ALIGNED((uintptr_t)mcache, CBFS_MCACHE_ALIGNMENT)); - cb_err_t ret = cbfs_walk(dev, build_walker, &args, metadata_hash, 0); + enum cb_err ret = cbfs_walk(dev, build_walker, &args, metadata_hash, 0); union mcache_entry *entry = args.mcache; if (ret == CB_CBFS_NOT_FOUND) { ret = CB_SUCCESS; @@ -88,8 +88,8 @@ return ret; }
-cb_err_t cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char *name, - union cbfs_mdata *mdata_out, size_t *data_offset_out) +enum cb_err cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char *name, + union cbfs_mdata *mdata_out, size_t *data_offset_out) { const size_t namesize = strlen(name) + 1; /* Count trailing \0 so we can memcmp() it. */ const void *end = mcache + mcache_size; diff --git a/src/commonlib/bsd/cbfs_private.c b/src/commonlib/bsd/cbfs_private.c index a8c2a3a..586710d 100644 --- a/src/commonlib/bsd/cbfs_private.c +++ b/src/commonlib/bsd/cbfs_private.c @@ -3,7 +3,7 @@ #include <commonlib/bsd/cbfs_private.h> #include <assert.h>
-static cb_err_t read_next_header(cbfs_dev_t dev, size_t *offset, struct cbfs_file *buffer, +static enum cb_err read_next_header(cbfs_dev_t dev, size_t *offset, struct cbfs_file *buffer, const size_t devsize) { DEBUG("Looking for next file @%#zx...\n", *offset); @@ -22,10 +22,10 @@ return CB_CBFS_NOT_FOUND; }
-cb_err_t cbfs_walk(cbfs_dev_t dev, cb_err_t (*walker)(cbfs_dev_t dev, size_t offset, - const union cbfs_mdata *mdata, - size_t already_read, void *arg), - void *arg, struct vb2_hash *metadata_hash, enum cbfs_walk_flags flags) +enum cb_err cbfs_walk(cbfs_dev_t dev, enum cb_err (*walker)(cbfs_dev_t dev, size_t offset, + const union cbfs_mdata *mdata, + size_t already_read, void *arg), + void *arg, struct vb2_hash *metadata_hash, enum cbfs_walk_flags flags) { const bool do_hash = CBFS_ENABLE_HASHING && metadata_hash; const size_t devsize = cbfs_dev_size(dev); @@ -39,8 +39,8 @@ }
size_t offset = 0; - cb_err_t ret_header; - cb_err_t ret_walker = CB_CBFS_NOT_FOUND; + enum cb_err ret_header; + enum cb_err ret_walker = CB_CBFS_NOT_FOUND; union cbfs_mdata mdata; while ((ret_header = read_next_header(dev, &offset, &mdata.h, devsize)) == CB_SUCCESS) { const uint32_t attr_offset = be32toh(mdata.h.attributes_offset); @@ -113,8 +113,8 @@ return ret_walker; }
-cb_err_t cbfs_copy_fill_metadata(union cbfs_mdata *dst, const union cbfs_mdata *src, - size_t already_read, cbfs_dev_t dev, size_t offset) +enum cb_err cbfs_copy_fill_metadata(union cbfs_mdata *dst, const union cbfs_mdata *src, + size_t already_read, cbfs_dev_t dev, size_t offset) { /* First, copy the stuff that cbfs_walk() already read for us. */ memcpy(dst, src, already_read); @@ -135,8 +135,8 @@ size_t *data_offset_out; };
-static cb_err_t lookup_walker(cbfs_dev_t dev, size_t offset, const union cbfs_mdata *mdata, - size_t already_read, void *arg) +static enum cb_err lookup_walker(cbfs_dev_t dev, size_t offset, const union cbfs_mdata *mdata, + size_t already_read, void *arg) { struct cbfs_lookup_args *args = arg; /* Check if the name we're looking for could fit, then we can safely memcmp() it. */ @@ -152,8 +152,8 @@ return CB_SUCCESS; }
-cb_err_t cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, - size_t *data_offset_out, struct vb2_hash *metadata_hash) +enum cb_err cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, + size_t *data_offset_out, struct vb2_hash *metadata_hash) { struct cbfs_lookup_args args = { .mdata_out = mdata_out, diff --git a/src/commonlib/bsd/include/commonlib/bsd/cb_err.h b/src/commonlib/bsd/include/commonlib/bsd/cb_err.h index b61b956..eec44f2f 100644 --- a/src/commonlib/bsd/include/commonlib/bsd/cb_err.h +++ b/src/commonlib/bsd/include/commonlib/bsd/cb_err.h @@ -42,7 +42,4 @@ CB_CBFS_CACHE_FULL = -403, /**< Metadata cache overflowed */ };
-/* Don't typedef the enum directly, so the size is unambiguous for serialization. */ -typedef int32_t cb_err_t; - #endif /* _COMMONLIB_BSD_CB_ERR_H_ */ diff --git a/src/commonlib/bsd/include/commonlib/bsd/cbfs_private.h b/src/commonlib/bsd/include/commonlib/bsd/cbfs_private.h index fc2d0d0..410bfd6 100644 --- a/src/commonlib/bsd/include/commonlib/bsd/cbfs_private.h +++ b/src/commonlib/bsd/include/commonlib/bsd/cbfs_private.h @@ -78,24 +78,24 @@ * CB_SUCCESS/<other> - First non-CB_CBFS_NOT_FOUND code returned by walker() * CB_CBFS_NOT_FOUND - walker() returned CB_CBFS_NOT_FOUND for every file in the CBFS */ -cb_err_t cbfs_walk(cbfs_dev_t dev, cb_err_t (*walker)(cbfs_dev_t dev, size_t offset, - const union cbfs_mdata *mdata, - size_t already_read, void *arg), - void *arg, struct vb2_hash *metadata_hash, enum cbfs_walk_flags); +enum cb_err cbfs_walk(cbfs_dev_t dev, enum cb_err (*walker)(cbfs_dev_t dev, size_t offset, + const union cbfs_mdata *mdata, + size_t already_read, void *arg), + void *arg, struct vb2_hash *metadata_hash, enum cbfs_walk_flags);
/* * Helper function that can be used by a |walker| callback to cbfs_walk() to copy the metadata * of a file into a permanent buffer. Will copy the |already_read| metadata from |src| into * |dst| and load remaining metadata from |dev| as required. */ -cb_err_t cbfs_copy_fill_metadata(union cbfs_mdata *dst, const union cbfs_mdata *src, - size_t already_read, cbfs_dev_t dev, size_t offset); +enum cb_err cbfs_copy_fill_metadata(union cbfs_mdata *dst, const union cbfs_mdata *src, + size_t already_read, cbfs_dev_t dev, size_t offset);
/* Find a file named |name| in the CBFS on |dev|. Copy its metadata (including attributes) * into |mdata_out| and pass out the offset to the file data on the CBFS device. * Verify the metadata with |metadata_hash| if provided. */ -cb_err_t cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, - size_t *data_offset_out, struct vb2_hash *metadata_hash); +enum cb_err cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, + size_t *data_offset_out, struct vb2_hash *metadata_hash);
/* Both base address and size of CBFS mcaches must be aligned to this value! */ #define CBFS_MCACHE_ALIGNMENT sizeof(uint32_t) /* Largest data type used in CBFS */ @@ -105,15 +105,15 @@ * CB_CBFS_CACHE_FULL, the mcache is still valid and can be used, but lookups may return * CB_CBFS_CACHE_FULL for files that didn't fit to indicate that the caller needs to fall back * to cbfs_lookup(). */ -cb_err_t cbfs_mcache_build(cbfs_dev_t dev, void *mcache, size_t mcache_size, - struct vb2_hash *metadata_hash); +enum cb_err cbfs_mcache_build(cbfs_dev_t dev, void *mcache, size_t mcache_size, + struct vb2_hash *metadata_hash);
/* * Find a file named |name| in a CBFS metadata cache and copy its metadata into |mdata_out|. * Pass out offset to the file data (on the original CBFS device used for cbfs_mcache_build()). */ -cb_err_t cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char *name, - union cbfs_mdata *mdata_out, size_t *data_offset_out); +enum cb_err cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char *name, + union cbfs_mdata *mdata_out, size_t *data_offset_out);
/* Returns the amount of bytes actually used by the CBFS metadata cache in |mcache|. */ size_t cbfs_mcache_real_size(const void *mcache, size_t mcache_size); diff --git a/src/drivers/mipi/panel.c b/src/drivers/mipi/panel.c index f1d87c3..9646eca 100644 --- a/src/drivers/mipi/panel.c +++ b/src/drivers/mipi/panel.c @@ -4,7 +4,7 @@ #include <delay.h> #include <mipi/panel.h>
-cb_err_t mipi_panel_parse_init_commands(const void *buf, mipi_cmd_func_t cmd_func) +enum cb_err mipi_panel_parse_init_commands(const void *buf, mipi_cmd_func_t cmd_func) { const struct panel_init_command *init = buf; enum mipi_dsi_transaction type; @@ -68,7 +68,7 @@ return CB_ERR; }
- cb_err_t ret = cmd_func(type, init->data, len); + enum cb_err ret = cmd_func(type, init->data, len); if (ret != CB_SUCCESS) return ret; buf += len; diff --git a/src/drivers/parade/ps8640/ps8640.c b/src/drivers/parade/ps8640/ps8640.c index 587eae1..ebb2f48 100644 --- a/src/drivers/parade/ps8640/ps8640.c +++ b/src/drivers/parade/ps8640/ps8640.c @@ -81,12 +81,12 @@ return 0; }
-static cb_err_t ps8640_bridge_aux_request(uint8_t bus, - uint8_t chip, - unsigned int target_reg, - unsigned int total_size, - enum aux_request request, - uint8_t *data) +static enum cb_err ps8640_bridge_aux_request(uint8_t bus, + uint8_t chip, + unsigned int target_reg, + unsigned int total_size, + enum aux_request request, + uint8_t *data) { int i; uint32_t length; diff --git a/src/drivers/ti/sn65dsi86bridge/sn65dsi86bridge.c b/src/drivers/ti/sn65dsi86bridge/sn65dsi86bridge.c index 806e9b2..9683b17 100644 --- a/src/drivers/ti/sn65dsi86bridge/sn65dsi86bridge.c +++ b/src/drivers/ti/sn65dsi86bridge/sn65dsi86bridge.c @@ -155,12 +155,12 @@ 0, 1620, 2160, 2430, 2700, 3240, 4320, 5400 };
-static cb_err_t sn65dsi86_bridge_aux_request(uint8_t bus, - uint8_t chip, - unsigned int target_reg, - unsigned int total_size, - enum aux_request request, - uint8_t *data) +static enum cb_err sn65dsi86_bridge_aux_request(uint8_t bus, + uint8_t chip, + unsigned int target_reg, + unsigned int total_size, + enum aux_request request, + uint8_t *data) { int i; uint32_t length; @@ -217,9 +217,9 @@ return CB_SUCCESS; }
-cb_err_t sn65dsi86_bridge_read_edid(uint8_t bus, uint8_t chip, struct edid *out) +enum cb_err sn65dsi86_bridge_read_edid(uint8_t bus, uint8_t chip, struct edid *out) { - cb_err_t err; + enum cb_err err; u8 edid[EDID_LENGTH * 2]; int edid_size = EDID_LENGTH;
diff --git a/src/include/cbfs.h b/src/include/cbfs.h index 5731d6e..476920a 100644 --- a/src/include/cbfs.h +++ b/src/include/cbfs.h @@ -185,15 +185,15 @@ * hash was still verified. Should be called once per *boot* (not once per stage) before the * first CBFS access. */ -cb_err_t cbfs_init_boot_device(const struct cbfs_boot_device *cbd, - struct vb2_hash *metadata_hash); +enum cb_err cbfs_init_boot_device(const struct cbfs_boot_device *cbd, + struct vb2_hash *metadata_hash);
/********************************************************************************************** * INTERNAL HELPERS FOR INLINES, DO NOT USE. * **********************************************************************************************/ -cb_err_t _cbfs_boot_lookup(const char *name, bool force_ro, - union cbfs_mdata *mdata, struct region_device *rdev); +enum cb_err _cbfs_boot_lookup(const char *name, bool force_ro, + union cbfs_mdata *mdata, struct region_device *rdev);
void *_cbfs_alloc(const char *name, cbfs_allocator_t allocator, void *arg, size_t *size_out, bool force_ro, enum cbfs_type *type); diff --git a/src/include/mipi/panel.h b/src/include/mipi/panel.h index 527af7e..ca06897 100644 --- a/src/include/mipi/panel.h +++ b/src/include/mipi/panel.h @@ -31,10 +31,10 @@ u8 init[]; /* A packed array of panel_init_command */ };
-typedef cb_err_t (*mipi_cmd_func_t)(enum mipi_dsi_transaction type, const u8 *data, u8 len); +typedef enum cb_err (*mipi_cmd_func_t)(enum mipi_dsi_transaction type, const u8 *data, u8 len);
/* Parse a command array and call cmd_func() for each entry. Delays get handled internally. */ -cb_err_t mipi_panel_parse_init_commands(const void *buf, mipi_cmd_func_t cmd_func); +enum cb_err mipi_panel_parse_init_commands(const void *buf, mipi_cmd_func_t cmd_func);
#define PANEL_DCS(...) \ PANEL_CMD_DCS, \ diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index 2d98c44..fc8ca74 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -34,15 +34,15 @@ } ROMSTAGE_CBMEM_INIT_HOOK(switch_to_postram_cache);
-cb_err_t _cbfs_boot_lookup(const char *name, bool force_ro, - union cbfs_mdata *mdata, struct region_device *rdev) +enum cb_err _cbfs_boot_lookup(const char *name, bool force_ro, + union cbfs_mdata *mdata, struct region_device *rdev) { const struct cbfs_boot_device *cbd = cbfs_get_boot_device(force_ro); if (!cbd) return CB_ERR;
size_t data_offset; - cb_err_t err = CB_CBFS_CACHE_FULL; + enum cb_err err = CB_CBFS_CACHE_FULL; if (!CONFIG(NO_CBFS_MCACHE) && !ENV_SMM && cbd->mcache_size) err = cbfs_mcache_lookup(cbd->mcache, cbd->mcache_size, name, mdata, &data_offset); @@ -520,11 +520,11 @@ return cbmem_add((uintptr_t)arg, size); }
-cb_err_t cbfs_prog_stage_load(struct prog *pstage) +enum cb_err cbfs_prog_stage_load(struct prog *pstage) { union cbfs_mdata mdata; struct region_device rdev; - cb_err_t err; + enum cb_err err;
prog_locate_hook(pstage);
@@ -612,8 +612,8 @@ } }
-cb_err_t cbfs_init_boot_device(const struct cbfs_boot_device *cbd, - struct vb2_hash *mdata_hash) +enum cb_err cbfs_init_boot_device(const struct cbfs_boot_device *cbd, + struct vb2_hash *mdata_hash) { /* If we have an mcache, mcache_build() will also check mdata hash. */ if (!CONFIG(NO_CBFS_MCACHE) && !ENV_SMM && cbd->mcache_size > 0) @@ -625,7 +625,7 @@
/* Verification only: use cbfs_walk() without a walker() function to just run through the CBFS once, will return NOT_FOUND by default. */ - cb_err_t err = cbfs_walk(&cbd->rdev, NULL, NULL, mdata_hash, 0); + enum cb_err err = cbfs_walk(&cbd->rdev, NULL, NULL, mdata_hash, 0); if (err == CB_CBFS_NOT_FOUND) err = CB_SUCCESS; return err; @@ -660,7 +660,7 @@ die("Cannot locate primary CBFS");
if (ENV_INITIAL_STAGE) { - cb_err_t err = cbfs_init_boot_device(&ro, metadata_hash_get()); + enum cb_err err = cbfs_init_boot_device(&ro, metadata_hash_get()); if (err == CB_CBFS_HASH_MISMATCH) die("RO CBFS metadata hash verification failure"); else if (CONFIG(TOCTOU_SAFETY) && err == CB_CBFS_CACHE_FULL) diff --git a/src/security/vboot/vboot_loader.c b/src/security/vboot/vboot_loader.c index 482c6fb..5bd81f0 100644 --- a/src/security/vboot/vboot_loader.c +++ b/src/security/vboot/vboot_loader.c @@ -34,7 +34,7 @@ if (!cbd) /* Can't initialize RW CBFS in recovery mode. */ return;
- cb_err_t err = cbfs_init_boot_device(cbd, NULL); /* TODO: RW hash */ + enum cb_err err = cbfs_init_boot_device(cbd, NULL); /* TODO: RW hash */ if (err && err != CB_CBFS_CACHE_FULL) /* TODO: -> recovery? */ die("RW CBFS initialization failure: %d", err); } diff --git a/src/soc/mediatek/common/dsi.c b/src/soc/mediatek/common/dsi.c index f16d8f2..396d979 100644 --- a/src/soc/mediatek/common/dsi.c +++ b/src/soc/mediatek/common/dsi.c @@ -303,7 +303,7 @@ } }
-static cb_err_t mtk_dsi_cmdq(enum mipi_dsi_transaction type, const u8 *data, u8 len) +static enum cb_err mtk_dsi_cmdq(enum mipi_dsi_transaction type, const u8 *data, u8 len) { const u8 *tx_buf = data; u32 config; diff --git a/src/soc/qualcomm/sc7180/display/dsi.c b/src/soc/qualcomm/sc7180/display/dsi.c index 48dc2b3..1f227a1 100644 --- a/src/soc/qualcomm/sc7180/display/dsi.c +++ b/src/soc/qualcomm/sc7180/display/dsi.c @@ -204,11 +204,11 @@ return status; }
-static cb_err_t mdss_dsi_send_init_cmd(enum mipi_dsi_transaction type, const u8 *body, u8 len) +static enum cb_err mdss_dsi_send_init_cmd(enum mipi_dsi_transaction type, const u8 *body, u8 len) { uint8_t *pload = _dma_coherent; uint32_t size; - cb_err_t ret = CB_SUCCESS; + enum cb_err ret = CB_SUCCESS; int data = 0; uint32_t *bp = NULL;
@@ -276,7 +276,7 @@ write32(&dsi0->err_int_mask0, 0x13FF3BFF); }
-cb_err_t mdss_dsi_panel_initialize(const u8 *init_cmds) +enum cb_err mdss_dsi_panel_initialize(const u8 *init_cmds) { uint32_t ctrl_mode = 0;
@@ -286,7 +286,7 @@ /* Enable command mode before sending the commands */ write32(&dsi0->ctrl, ctrl_mode | 0x04);
- cb_err_t ret = mipi_panel_parse_init_commands(init_cmds, mdss_dsi_send_init_cmd); + enum cb_err ret = mipi_panel_parse_init_commands(init_cmds, mdss_dsi_send_init_cmd); write32(&dsi0->ctrl, ctrl_mode); mdss_dsi_clear_intr();
diff --git a/src/soc/qualcomm/sc7180/include/soc/display/mipi_dsi.h b/src/soc/qualcomm/sc7180/include/soc/display/mipi_dsi.h index a7c9b6e..12e5149 100644 --- a/src/soc/qualcomm/sc7180/include/soc/display/mipi_dsi.h +++ b/src/soc/qualcomm/sc7180/include/soc/display/mipi_dsi.h @@ -22,6 +22,6 @@ enum cb_err mdss_dsi_config(struct edid *edid, uint32_t num_of_lanes, uint32_t bpp); void mdss_dsi_clock_config(void); void mdss_dsi_video_mode_config(struct edid *edid, uint32_t bpp); -cb_err_t mdss_dsi_panel_initialize(const u8 *init_cmds); +enum cb_err mdss_dsi_panel_initialize(const u8 *init_cmds);
#endif diff --git a/tests/lib/cbfs-lookup-test.c b/tests/lib/cbfs-lookup-test.c index 63a8298..7562868 100644 --- a/tests/lib/cbfs-lookup-test.c +++ b/tests/lib/cbfs-lookup-test.c @@ -70,29 +70,29 @@ return dstn; }
-extern cb_err_t __real_cbfs_lookup(cbfs_dev_t dev, const char *name, - union cbfs_mdata *mdata_out, size_t *data_offset_out, - struct vb2_hash *metadata_hash); +extern enum cb_err __real_cbfs_lookup(cbfs_dev_t dev, const char *name, + union cbfs_mdata *mdata_out, size_t *data_offset_out, + struct vb2_hash *metadata_hash);
-cb_err_t cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, - size_t *data_offset_out, struct vb2_hash *metadata_hash) +enum cb_err cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, + size_t *data_offset_out, struct vb2_hash *metadata_hash) { - const cb_err_t err = + const enum cb_err err = __real_cbfs_lookup(dev, name, mdata_out, data_offset_out, metadata_hash); - assert_int_equal(err, mock_type(cb_err_t)); + assert_int_equal(err, mock_type(enum cb_err)); return err; }
-extern cb_err_t __real_cbfs_mcache_lookup(const void *mcache, size_t mcache_size, +extern enum cb_err __real_cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char *name, union cbfs_mdata *mdata_out, size_t *data_offset_out);
-cb_err_t cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char *name, - union cbfs_mdata *mdata_out, size_t *data_offset_out) +enum cb_err cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char *name, + union cbfs_mdata *mdata_out, size_t *data_offset_out) { - const cb_err_t err = __real_cbfs_mcache_lookup(mcache, mcache_size, name, mdata_out, + const enum cb_err err = __real_cbfs_mcache_lookup(mcache, mcache_size, name, mdata_out, data_offset_out); - assert_int_equal(err, mock_type(cb_err_t)); + assert_int_equal(err, mock_type(enum cb_err)); return err; }
@@ -128,7 +128,7 @@ struct cbfs_test_state_ex { u32 file_type; u32 file_length; - cb_err_t lookup_result; + enum cb_err lookup_result; };
struct cbfs_test_state { @@ -198,7 +198,7 @@
/* Utils */
-static void expect_lookup_result(cb_err_t res) +static void expect_lookup_result(enum cb_err res) { if (CONFIG(NO_CBFS_MCACHE)) will_return(cbfs_lookup, (res)); diff --git a/tests/lib/cbfs-verification-test.c b/tests/lib/cbfs-verification-test.c index 1f46c7d..263fbec 100644 --- a/tests/lib/cbfs-verification-test.c +++ b/tests/lib/cbfs-verification-test.c @@ -80,15 +80,15 @@ }
/* Original function alias created by test framework. Used for call wrapping in mock below. */ -cb_err_t __real_cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, - size_t *data_offset_out, struct vb2_hash *metadata_hash); +enum cb_err __real_cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, + size_t *data_offset_out, struct vb2_hash *metadata_hash);
-cb_err_t cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, - size_t *data_offset_out, struct vb2_hash *metadata_hash) +enum cb_err cbfs_lookup(cbfs_dev_t dev, const char *name, union cbfs_mdata *mdata_out, + size_t *data_offset_out, struct vb2_hash *metadata_hash) { - const cb_err_t err = + const enum cb_err err = __real_cbfs_lookup(dev, name, mdata_out, data_offset_out, metadata_hash); - assert_int_equal(mock_type(cb_err_t), err); + assert_int_equal(mock_type(enum cb_err), err); return err; }
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index b765340..cebfef6 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -247,8 +247,8 @@ if (mhc->cbfs_hash.algo == VB2_HASH_INVALID) return 0;
- cb_err_t err = cbfs_walk(cbfs, NULL, NULL, &mhc->cbfs_hash, - CBFS_WALK_WRITEBACK_HASH); + enum cb_err err = cbfs_walk(cbfs, NULL, NULL, &mhc->cbfs_hash, + CBFS_WALK_WRITEBACK_HASH); if (err != CB_CBFS_NOT_FOUND) { ERROR("Unexpected cbfs_walk() error %d\n", err); return -1; @@ -1508,8 +1508,8 @@ return 0;
struct vb2_hash real_hash = { .algo = mhc->cbfs_hash.algo }; - cb_err_t err = cbfs_walk(&image, NULL, NULL, &real_hash, - CBFS_WALK_WRITEBACK_HASH); + enum cb_err err = cbfs_walk(&image, NULL, NULL, &real_hash, + CBFS_WALK_WRITEBACK_HASH); if (err != CB_CBFS_NOT_FOUND) { ERROR("Unexpected cbfs_walk() error %d\n", err); return 1;