[OpenBIOS] [PATCH 2/3] fw_cfg: add fw_cfg_find_file() and fw_cfg_read_file() functions
Segher Boessenkool
segher at kernel.crashing.org
Sun Mar 19 20:04:21 CET 2017
Hi Mark,
On Sun, Mar 19, 2017 at 11:46:53AM +0000, Mark Cave-Ayland wrote:
> + uint32_t buf, count;
> +
> + fw_cfg_read(FW_CFG_FILE_DIR, (char *)&buf, sizeof(uint32_t));
> + count = __be32_to_cpu(buf);
It's a lot cleaner to use e.g.
count = fw_cfg_read32(FW_CFG_FILE_DIR);
and ideally you wouldn't use byte-swapping things at all:
uint32_t fw_cfg_read32(unsigned char *p)
{
uint32_t x = 0;
for (int i = 0; i < 4; i++_
x = (x << 8) | p[i];
return x;
}
Segher
More information about the OpenBIOS
mailing list