diff options
author | Tom Rini <trini@konsulko.com> | 2022-10-18 07:36:52 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-10-18 07:36:52 -0400 |
commit | 700b4fe782f9fc46b7be1b1a93a49356baeccc3f (patch) | |
tree | 7c4f01a95ceb7288ac9f95ffb59c2ea11b0a33cf /drivers/core/regmap.c | |
parent | d3031d442b941f059eb83bb67ca10a28a0539f9a (diff) | |
parent | ae0bf2214b81b56a5670819958234947443680be (diff) |
Merge tag 'dm-pull-18oct22' of https://source.denx.de/u-boot/custodians/u-boot-dm
Update uclass iterators to work better when devices fail to probe
Support VBE OS requests / fixups
Minor error-handling tweaks to bootm command
Diffstat (limited to 'drivers/core/regmap.c')
-rw-r--r-- | drivers/core/regmap.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index 5ccbf9abb8a..e33bb9d798d 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -4,6 +4,8 @@ * Written by Simon Glass <sjg@chromium.org> */ +#define LOG_CATEGORY LOGC_DM + #include <common.h> #include <dm.h> #include <errno.h> @@ -37,6 +39,22 @@ struct regmap_field { DECLARE_GLOBAL_DATA_PTR; /** + * do_range_check() - Control whether range checks are done + * + * Returns: true to do range checks, false to skip + * + * This is used to reduce code size on SPL where range checks are known not to + * be needed + * + * Add this to the top of the file to enable them: #define LOG_DEBUG + */ +static inline bool do_range_check(void) +{ + return _LOG_DEBUG || !IS_ENABLED(CONFIG_SPL); + +} + +/** * regmap_alloc() - Allocate a regmap with a given number of ranges. * * @count: Number of ranges to be allocated for the regmap. @@ -391,7 +409,7 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset, struct regmap_range *range; void *ptr; - if (range_num >= map->range_count) { + if (do_range_check() && range_num >= map->range_count) { debug("%s: range index %d larger than range count\n", __func__, range_num); return -ERANGE; @@ -399,7 +417,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset, range = &map->ranges[range_num]; offset <<= map->reg_offset_shift; - if (offset + val_len > range->size || offset + val_len < offset) { + if (do_range_check() && + (offset + val_len > range->size || offset + val_len < offset)) { debug("%s: offset/size combination invalid\n", __func__); return -ERANGE; } |