From 0f4b8a24db92fa8b1abd79308ff69c4e48808878 Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Fri, 29 Oct 2021 15:18:40 -0600 Subject: [PATCH] commonlib/region: Add rdev_readat_full helper method This helper method makes the code a bit cleaner. BUG=b:179699789 TEST=none Suggested-by: Julius Werner Signed-off-by: Raul E Rangel Change-Id: Ie442217eba2e8f99de1407d61f965428b5c6f3bf Reviewed-on: https://review.coreboot.org/c/coreboot/+/58761 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner Reviewed-by: Karthik Ramasubramanian --- src/commonlib/include/commonlib/region.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/commonlib/include/commonlib/region.h b/src/commonlib/include/commonlib/region.h index 764870f46c..5d73d9e199 100644 --- a/src/commonlib/include/commonlib/region.h +++ b/src/commonlib/include/commonlib/region.h @@ -157,6 +157,17 @@ static inline int rdev_chain_full(struct region_device *child, return rdev_chain(child, parent, 0, region_device_sz(parent)); } +/* + * Returns < 0 on error otherwise returns size of data read at provided + * offset filling in the buffer passed. + * + * You must ensure the buffer is large enough to hold the full region_device. + */ +static inline ssize_t rdev_readat_full(const struct region_device *rd, void *b) +{ + return rdev_readat(rd, b, 0, region_device_sz(rd)); +} + /* * Compute relative offset of the child (c) w.r.t. the parent (p). Returns < 0 * when child is not within the parent's region.