summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-02-23 13:45:28 +0000
committerLeah Rowe <leah@libreboot.org>2026-02-23 13:45:28 +0000
commit678b9d859b788bb0c4aa6353d650ae616add86d7 (patch)
tree91fdabd7e3a92f652d4a103b7d5c2d8cd4987db8 /util
parente1d8773c5453084bd7016c070a0bbf3b9d043f6d (diff)
nvmutil: split pread from readGbe
split it into readGbe_part, for code clarity. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index ee86de14..25a372c7 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -18,7 +18,8 @@ void cmd_setchecksum(void), cmd_brick(void), swap(int partnum), writeGbe(void),
cmd_dump(void), cmd_setmac(void), nvmalloc(void), readGbe(void),
checkdir(const char *path), macf(int partnum), hexdump(int partnum),
parseMacString(const char *strMac, uint16_t *mac), cmd_swap(void),
- openFiles(const char *path), cmd_copy(void), writeGbe_part(int);
+ openFiles(const char *path), cmd_copy(void), writeGbe_part(int),
+ readGbe_part(int);
int goodChecksum(int partnum);
uint8_t hextonum(char chs), rhex(void);
@@ -221,16 +222,20 @@ void
readGbe(void)
{
for (int p = 0; p < 2; p++) {
- if (!do_read[p])
- continue;
- if (pread(fd, (uint8_t *) gbe[p], nf, p * partsize) != nf)
- err(ERR(), "Couldn't read %ld bytes from '%s' part %d",
- nf, filename, p);
- swap(p); /* handle big-endian host CPU */
+ if (do_read[p])
+ readGbe_part(p);
}
}
void
+readGbe_part(int p)
+{
+ if (pread(fd, (uint8_t *) gbe[p], nf, p * partsize) != nf)
+ err(ERR(), "Can't read %ld b from '%s' p%d", nf, filename, p);
+ swap(p); /* handle big-endian host CPU */
+}
+
+void
cmd_setmac(void)
{
int mac_updated = 0;