Skip to content
Snippets Groups Projects
Commit f36e710e authored by Thibaut VARÈNE's avatar Thibaut VARÈNE Committed by Koen Vandeputte
Browse files

generic: routerboot sysfs: add support for soft_config


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: default avatarKoen Vandeputte <koen.vandeputte@ncentric.com>
Tested-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
Signed-off-by: default avatarThibaut VARÈNE <hacks@slashdirt.org>
parent dac18f66
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ config MIKROTIK_RB_SYSFS
tristate "RouterBoot sysfs support"
depends on MTD
select LZO_DECOMPRESS
select CRC32
help
This driver exposes RouterBoot configuration in sysfs.
......
#
# Makefile for MikroTik RouterBoard platform specific drivers
#
obj-$(CONFIG_MIKROTIK_RB_SYSFS) += routerboot.o rb_hardconfig.o
obj-$(CONFIG_MIKROTIK_RB_SYSFS) += routerboot.o rb_hardconfig.o rb_softconfig.o
......@@ -675,6 +675,9 @@ int __init rb_hardconfig_init(struct kobject *rb_kobj)
int i, ret;
u32 magic;
hc_buf = NULL;
hc_kobj = NULL;
// TODO allow override
mtd = get_mtd_device_nm(RB_MTD_HARD_CONFIG);
if (IS_ERR(mtd))
......@@ -749,6 +752,7 @@ int __init rb_hardconfig_init(struct kobject *rb_kobj)
fail:
kfree(hc_buf);
hc_buf = NULL;
return ret;
}
......
This diff is collapsed.
......@@ -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
}
......
......@@ -28,6 +28,9 @@ 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);
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);
#endif /* _ROUTERBOOT_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment