summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-06 13:47:16 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-06 13:49:33 +0000
commit95b294db05cd92a3a915484532a4dda230c8ae56 (patch)
tree3657cc7fb962f1f084ea9039f9cec1296cb8f911 /util/nvmutil/nvmutil.c
parentd89d14e911a8bfc1a4562e8d799370448e793990 (diff)
util/nvmutil: inline pos calculation on word()
we don't need a whole function. i previously did it for clarity, but simply setting a variable all in one line is totally fine. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r--util/nvmutil/nvmutil.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 9b0ac3f0..300217e8 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -43,7 +43,6 @@ static void cmd_swap(void);
static int good_checksum(int);
static uint16_t word(size_t, int);
static void set_word(size_t, int, uint16_t);
-static size_t get_word_pos(size_t, int);
static void check_bound(size_t, int);
static void write_gbe(void);
static void write_gbe_part(int);
@@ -620,7 +619,7 @@ word(size_t pos16, int p)
size_t pos;
check_bound(pos16, p);
- pos = get_word_pos(pos16, p);
+ pos = (pos16 << 1) + ((size_t)p * SIZE_4KB);
return (uint16_t)buf[pos] | ((uint16_t)buf[pos + 1] << 8);
}
@@ -631,7 +630,7 @@ set_word(size_t pos16, int p, uint16_t val16)
size_t pos;
check_bound(pos16, p);
- pos = get_word_pos(pos16, p);
+ pos = (pos16 << 1) + ((size_t)p * SIZE_4KB);
buf[pos] = (uint8_t)(val16 & 0xff);
buf[pos + 1] = (uint8_t)(val16 >> 8);
@@ -639,15 +638,6 @@ set_word(size_t pos16, int p, uint16_t val16)
part_modified[p] = 1;
}
-static size_t
-get_word_pos(size_t pos16, int p)
-{
- size_t off = SIZE_4KB * p;
- size_t pos = (pos16 << 1) + off;
-
- return pos;
-}
-
static void
check_bound(size_t c, int p)
{