From f36e710e2d6da4c4a15a2af94204236d8fcae988 Mon Sep 17 00:00:00 2001 From: Thibaut VARÈNE Date: Wed, 13 May 2020 22:12:41 +0200 Subject: generic: routerboot sysfs: add support for soft_config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This driver exposes the data encoded in the "soft_config" flash segment of MikroTik RouterBOARDs devices. It presents the data in a sysfs folder named "soft_config" through a set of human-and-machine-parseable attributes. Changes can be discarded by writing 0 to the 'commit' attribute, or they can be committed to flash storage by writing 1. This driver does not reuse any of the existing code previously found in the "rbcfg" utility and makes this utility obsolete by providing a clean sysfs interface. Like "rbcfg", this driver requires 4K_SECTORS support since the flash partition in which these parameters are stored is typically 4KB in size. Tested-by: Koen Vandeputte Tested-by: Roger Pueyo Centelles Signed-off-by: Thibaut VARÈNE --- .../generic/files/drivers/platform/mikrotik/routerboot.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'target/linux/generic/files/drivers/platform/mikrotik/routerboot.c') diff --git a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c index 96a100a933..f496dd7e0c 100644 --- a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c +++ b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c @@ -166,11 +166,20 @@ static int __init routerboot_init(void) if (!rb_kobj) return -ENOMEM; - return rb_hardconfig_init(rb_kobj); + /* + * We ignore the following return values and always register. + * These init() routines are designed so that their failed state is + * always manageable by the corresponding exit() calls. + */ + rb_hardconfig_init(rb_kobj); + rb_softconfig_init(rb_kobj); + + return 0; } static void __exit routerboot_exit(void) { + rb_softconfig_exit(); rb_hardconfig_exit(); kobject_put(rb_kobj); // recursive afaict } -- cgit v1.2.3