From 4f213285d78974c4b8915b311aff88449279f554 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sat, 15 Jun 2019 17:33:49 +0200 Subject: layout: Move generic layout functions into `layout.c` Change-Id: If1edde70fc51e88e6e1c560d79a0d51941b9627c Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/flashrom/+/33514 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans --- layout.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'layout.c') diff --git a/layout.c b/layout.c index 6e348144b..6963e61a1 100644 --- a/layout.c +++ b/layout.c @@ -244,3 +244,44 @@ const struct romentry *layout_next_included_region( return lowest; } + +/** + * @addtogroup flashrom-layout + * @{ + */ + +/** + * @brief Mark given region as included. + * + * @param layout The layout to alter. + * @param name The name of the region to include. + * + * @return 0 on success, + * 1 if the given name can't be found. + */ +int flashrom_layout_include_region(struct flashrom_layout *const layout, const char *name) +{ + size_t i; + for (i = 0; i < layout->num_entries; ++i) { + if (!strcmp(layout->entries[i].name, name)) { + layout->entries[i].included = true; + return 0; + } + } + return 1; +} + +/** + * @brief Free a layout. + * + * @param layout Layout to free. + */ +void flashrom_layout_release(struct flashrom_layout *const layout) +{ + if (layout == get_global_layout()) + return; + + free(layout); +} + +/** @} */ /* end flashrom-layout */ -- cgit v1.2.3