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 <jwerner@chromium.org>
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: Ie442217eba2e8f99de1407d61f965428b5c6f3bf
Reviewed-on: https://review.coreboot.org/c/coreboot/+/58761
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
This commit is contained in:
Raul E Rangel 2021-10-29 15:18:40 -06:00 committed by Raul Rangel
parent 67258983e6
commit 0f4b8a24db
1 changed files with 11 additions and 0 deletions

View File

@ -157,6 +157,17 @@ static inline int rdev_chain_full(struct region_device *child,
return rdev_chain(child, parent, 0, region_device_sz(parent)); 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 * Compute relative offset of the child (c) w.r.t. the parent (p). Returns < 0
* when child is not within the parent's region. * when child is not within the parent's region.