mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 18:34:57 +02:00
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>
This commit is contained in:
+2
-12
@@ -43,7 +43,6 @@ static void cmd_swap(void);
|
|||||||
static int good_checksum(int);
|
static int good_checksum(int);
|
||||||
static uint16_t word(size_t, int);
|
static uint16_t word(size_t, int);
|
||||||
static void set_word(size_t, int, uint16_t);
|
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 check_bound(size_t, int);
|
||||||
static void write_gbe(void);
|
static void write_gbe(void);
|
||||||
static void write_gbe_part(int);
|
static void write_gbe_part(int);
|
||||||
@@ -620,7 +619,7 @@ word(size_t pos16, int p)
|
|||||||
size_t pos;
|
size_t pos;
|
||||||
|
|
||||||
check_bound(pos16, p);
|
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);
|
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;
|
size_t pos;
|
||||||
|
|
||||||
check_bound(pos16, p);
|
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] = (uint8_t)(val16 & 0xff);
|
||||||
buf[pos + 1] = (uint8_t)(val16 >> 8);
|
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;
|
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
|
static void
|
||||||
check_bound(size_t c, int p)
|
check_bound(size_t c, int p)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user