diff options
author | Denis Kalashnikov <denis281089@gmail.com> | 2021-11-16 19:06:44 +0300 |
---|---|---|
committer | Koen Vandeputte <koen.vandeputte@ncentric.com> | 2022-01-13 09:33:29 +0100 |
commit | 2d19e6c6a42cbbd6ab53c4c673ba71303ef6a70b (patch) | |
tree | dad3725f0d025a2909aaa51956e00a5f3f55bd93 /target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c | |
parent | 9571d9d4b127622d8dd07b838d22b64e800dd23f (diff) | |
download | upstream-2d19e6c6a42cbbd6ab53c4c673ba71303ef6a70b.tar.gz upstream-2d19e6c6a42cbbd6ab53c4c673ba71303ef6a70b.tar.bz2 upstream-2d19e6c6a42cbbd6ab53c4c673ba71303ef6a70b.zip |
generic: platform/mikrotik: use MTD notifier
If the SPI probe is sufficiently delayed, the routerboot driver may fail
to init as the routerboot partitions are not yet available.
Register an MTD user notifier instead of doing straight init so that the
init subroutines are only executed when the target MTD partitions are
present.
Because the init/exit routines can now be called outside of the kernel
normal init/exit calls, they cannot be jettisoned and must always be
available: the __init and __exit qualifiers are thus removed.
Reported-by: Denis Kalashnikov <denis281089@gmail.com>
Signed-off-by: Denis Kalashnikov <denis281089@gmail.com>
Signed-off-by: Thibaut VARĂˆNE <hacks@slashdirt.org>
Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
[bump hardconfig/softconfig versions]
Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Diffstat (limited to 'target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c')
-rw-r--r-- | target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c b/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c index 453e1347b2..5acff6aa91 100644 --- a/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c +++ b/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c @@ -56,7 +56,7 @@ #include "routerboot.h" -#define RB_SOFTCONFIG_VER "0.04" +#define RB_SOFTCONFIG_VER "0.05" #define RB_SC_PR_PFX "[rb_softconfig] " #define RB_SC_HAS_WRITE_SUPPORT true @@ -694,9 +694,8 @@ mtdfail: static struct kobj_attribute sc_kattrcommit = __ATTR(commit, RB_SC_RMODE|RB_SC_WMODE, sc_commit_show, sc_commit_store); -int __init rb_softconfig_init(struct kobject *rb_kobj) +int rb_softconfig_init(struct kobject *rb_kobj, struct mtd_info *mtd) { - struct mtd_info *mtd; size_t bytes_read, buflen; const u8 *buf; int i, ret; @@ -705,20 +704,19 @@ int __init rb_softconfig_init(struct kobject *rb_kobj) sc_buf = NULL; sc_kobj = NULL; - // TODO allow override - mtd = get_mtd_device_nm(RB_MTD_SOFT_CONFIG); - if (IS_ERR(mtd)) + ret = __get_mtd_device(mtd); + if (ret) return -ENODEV; sc_buflen = mtd->size; sc_buf = kmalloc(sc_buflen, GFP_KERNEL); if (!sc_buf) { - put_mtd_device(mtd); + __put_mtd_device(mtd); return -ENOMEM; } ret = mtd_read(mtd, 0, sc_buflen, &bytes_read, sc_buf); - put_mtd_device(mtd); + __put_mtd_device(mtd); if (ret) goto fail; @@ -788,8 +786,10 @@ fail: return ret; } -void __exit rb_softconfig_exit(void) +void rb_softconfig_exit(void) { kobject_put(sc_kobj); + sc_kobj = NULL; kfree(sc_buf); + sc_buf = NULL; } |