aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic
diff options
context:
space:
mode:
authorThibaut VARÈNE <hacks@slashdirt.org>2020-05-15 18:00:08 +0200
committerKoen Vandeputte <koen.vandeputte@ncentric.com>2020-05-28 11:09:10 +0200
commit89226b86665b135fbf4c9eefecccde0c0d0e9f05 (patch)
tree5d1c4b7110067b1dc33516877b583155a1f48290 /target/linux/generic
parentf36e710e2d6da4c4a15a2af94204236d8fcae988 (diff)
downloadupstream-89226b86665b135fbf4c9eefecccde0c0d0e9f05.tar.gz
upstream-89226b86665b135fbf4c9eefecccde0c0d0e9f05.tar.bz2
upstream-89226b86665b135fbf4c9eefecccde0c0d0e9f05.zip
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>
Diffstat (limited to 'target/linux/generic')
-rw-r--r--target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c25
-rw-r--r--target/linux/generic/files/drivers/platform/mikrotik/routerboot.c19
-rw-r--r--target/linux/generic/files/drivers/platform/mikrotik/routerboot.h1
3 files changed, 23 insertions, 22 deletions
diff --git a/target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c b/target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c
index a03aa21b4d..992689605d 100644
--- a/target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c
+++ b/target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c
@@ -310,25 +310,6 @@ static struct hc_hwopt {
},
};
-static ssize_t hc_tag_show_u32(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;
-}
-
/*
* The MAC is stored network-endian on all devices, in 2 32-bit segments:
* <XX:XX:XX:XX> <XX:XX:00:00>. Kernel print has us covered.
@@ -389,7 +370,7 @@ static struct hc_attr {
} hc_attrs[] = {
{
.tag_id = RB_ID_FLASH_INFO,
- .tshow = hc_tag_show_u32,
+ .tshow = routerboot_tag_show_u32s,
.kattr = __ATTR(flash_info, S_IRUSR, hc_attr_show, NULL),
}, {
.tag_id = RB_ID_MAC_ADDRESS_PACK,
@@ -409,11 +390,11 @@ static struct hc_attr {
.kattr = __ATTR(board_serial, S_IRUSR, hc_attr_show, NULL),
}, {
.tag_id = RB_ID_MEMORY_SIZE,
- .tshow = hc_tag_show_u32,
+ .tshow = routerboot_tag_show_u32s,
.kattr = __ATTR(mem_size, S_IRUSR, hc_attr_show, NULL),
}, {
.tag_id = RB_ID_MAC_ADDRESS_COUNT,
- .tshow = hc_tag_show_u32,
+ .tshow = routerboot_tag_show_u32s,
.kattr = __ATTR(mac_count, S_IRUSR, hc_attr_show, NULL),
}, {
.tag_id = RB_ID_HW_OPTIONS,
diff --git a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c
index f496dd7e0c..47e4471f8e 100644
--- a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c
+++ b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c
@@ -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);
diff --git a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.h b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.h
index 5b644db4fe..67d89808d5 100644
--- a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.h
+++ b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.h
@@ -32,5 +32,6 @@ int __init rb_softconfig_init(struct kobject *rb_kobj);
void __exit rb_softconfig_exit(void);
ssize_t routerboot_tag_show_string(const u8 *pld, u16 pld_len, char *buf);
+ssize_t routerboot_tag_show_u32s(const u8 *pld, u16 pld_len, char *buf);
#endif /* _ROUTERBOOT_H_ */