aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThibaut VARÈNE <hacks@slashdirt.org>2020-05-13 18:43:30 +0200
committerKoen Vandeputte <koen.vandeputte@ncentric.com>2020-05-28 11:09:10 +0200
commitdac18f66fb18ebadf6f050d9c5c055a82855e8f6 (patch)
tree462bc4138809337e0692bf935eb160634554d96e
parent39ec3c5986e5109c3f1dd63b27d884606453191b (diff)
downloadupstream-dac18f66fb18ebadf6f050d9c5c055a82855e8f6.tar.gz
upstream-dac18f66fb18ebadf6f050d9c5c055a82855e8f6.tar.bz2
upstream-dac18f66fb18ebadf6f050d9c5c055a82855e8f6.zip
generic: routerboot sysfs: move tag_show_string()
This routine will be shared between hard and soft config drivers. Also use scnprintf() instead of snprintf(). 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>
-rw-r--r--target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c17
-rw-r--r--target/linux/generic/files/drivers/platform/mikrotik/routerboot.c7
-rw-r--r--target/linux/generic/files/drivers/platform/mikrotik/routerboot.h2
3 files changed, 15 insertions, 11 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 4bcbb75e6f..bef71a0b5f 100644
--- a/target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c
+++ b/target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c
@@ -310,11 +310,6 @@ static struct hc_hwopt {
},
};
-static ssize_t hc_tag_show_string(const u8 *pld, u16 pld_len, char *buf)
-{
- return snprintf(buf, pld_len+1, "%s\n", pld);
-}
-
static ssize_t hc_tag_show_u32(const u8 *pld, u16 pld_len, char *buf)
{
char *out = buf;
@@ -402,15 +397,15 @@ static struct hc_attr {
.kattr = __ATTR(mac_base, S_IRUSR, hc_attr_show, NULL),
}, {
.tag_id = RB_ID_BOARD_PRODUCT_CODE,
- .tshow = hc_tag_show_string,
+ .tshow = routerboot_tag_show_string,
.kattr = __ATTR(board_product_code, S_IRUSR, hc_attr_show, NULL),
}, {
.tag_id = RB_ID_BIOS_VERSION,
- .tshow = hc_tag_show_string,
+ .tshow = routerboot_tag_show_string,
.kattr = __ATTR(booter_version, S_IRUSR, hc_attr_show, NULL),
}, {
.tag_id = RB_ID_SERIAL_NUMBER,
- .tshow = hc_tag_show_string,
+ .tshow = routerboot_tag_show_string,
.kattr = __ATTR(board_serial, S_IRUSR, hc_attr_show, NULL),
}, {
.tag_id = RB_ID_MEMORY_SIZE,
@@ -429,15 +424,15 @@ static struct hc_attr {
.tshow = NULL,
}, {
.tag_id = RB_ID_BOARD_IDENTIFIER,
- .tshow = hc_tag_show_string,
+ .tshow = routerboot_tag_show_string,
.kattr = __ATTR(board_identifier, S_IRUSR, hc_attr_show, NULL),
}, {
.tag_id = RB_ID_PRODUCT_NAME,
- .tshow = hc_tag_show_string,
+ .tshow = routerboot_tag_show_string,
.kattr = __ATTR(product_name, S_IRUSR, hc_attr_show, NULL),
}, {
.tag_id = RB_ID_DEFCONF,
- .tshow = hc_tag_show_string,
+ .tshow = routerboot_tag_show_string,
.kattr = __ATTR(defconf, S_IRUSR, hc_attr_show, NULL),
}
};
diff --git a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c
index 36ca90c1ad..96a100a933 100644
--- a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c
+++ b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c
@@ -175,6 +175,13 @@ static void __exit routerboot_exit(void)
kobject_put(rb_kobj); // recursive afaict
}
+/* Common routines */
+
+ssize_t routerboot_tag_show_string(const u8 *pld, u16 pld_len, char *buf)
+{
+ return scnprintf(buf, pld_len+1, "%s\n", pld);
+}
+
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 c75f61ebbf..e1ae972183 100644
--- a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.h
+++ b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.h
@@ -28,4 +28,6 @@ int routerboot_rle_decode(const u8 *in, size_t inlen, u8 *out, size_t *outlen);
int __init rb_hardconfig_init(struct kobject *rb_kobj);
void __exit rb_hardconfig_exit(void);
+ssize_t routerboot_tag_show_string(const u8 *pld, u16 pld_len, char *buf);
+
#endif /* _ROUTERBOOT_H_ */