forked from Ivasoft/openwrt
generic: routerboot sysfs: move tag_show_u32()
This routine will be shared between hard and soft config drivers. Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com> Tested-by: Roger Pueyo Centelles <roger.pueyo@guifi.net> Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
This commit is contained in:
committed by
Koen Vandeputte
parent
f36e710e2d
commit
89226b8666
@@ -191,6 +191,25 @@ ssize_t routerboot_tag_show_string(const u8 *pld, u16 pld_len, char *buf)
|
||||
return scnprintf(buf, pld_len+1, "%s\n", pld);
|
||||
}
|
||||
|
||||
ssize_t routerboot_tag_show_u32s(const u8 *pld, u16 pld_len, char *buf)
|
||||
{
|
||||
char *out = buf;
|
||||
u32 data; // cpu-endian
|
||||
|
||||
/* Caller ensures pld_len > 0 */
|
||||
if (pld_len % sizeof(data))
|
||||
return -EINVAL;
|
||||
|
||||
data = *(u32 *)pld;
|
||||
|
||||
do {
|
||||
out += sprintf(out, "0x%08x\n", data);
|
||||
data++;
|
||||
} while ((pld_len -= sizeof(data)));
|
||||
|
||||
return out - buf;
|
||||
}
|
||||
|
||||
module_init(routerboot_init);
|
||||
module_exit(routerboot_exit);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user