diff options
author | Rasmus Villemoes <rasmus.villemoes@prevas.dk> | 2022-07-07 15:12:17 +0200 |
---|---|---|
committer | Heiko Schocher <hs@denx.de> | 2022-07-19 13:46:28 +0200 |
commit | 49f3a42edf097fbaca76aef9bfcd98d871b442cb (patch) | |
tree | 37f05b6c74fb005a43875691626076d817c71a29 /drivers/fpga/fpga.c | |
parent | 2b77eea7f309d969310f5d4c2d9639ffca2b5abf (diff) |
i2c: avoid dynamic stack use in dm_i2c_write
The size of the dynamic stack allocation here is bounded by the if()
statement. However, just allocating the maximum size up-front and
doing malloc() if necessary avoids code duplication (the
i2c_setup_offset() until the invocation of ->xfer), and generates much
better (smaller) code:
bloat-o-meter drivers/i2c/i2c-uclass.o.{0,1}
add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-144 (-144)
Function old new delta
dm_i2c_write 552 408 -144
Total: Before=3828, After=3684, chg -3.76%
It also makes static analysis of maximum stack usage (using the .su
files that are automatically generated during build) easier if there
are no lines saying "dynamic".
[This is not entirely equivalent to the existing code; this now uses
the stack for len <= 64 rather than len <= 63, but that seems like a
more natural limit.]
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/fpga/fpga.c')
0 files changed, 0 insertions, 0 deletions