From: Stanislav Kinsburskii <stanislav.kinsburskii@xxxxxxxxx> Introduce primitives to: - Register and unregister callbacks for flattened device tree (fdt) modifications. - Invoke all registered callbacks. - Check for any registered callbacks. These enhancements enable the use of a device tree to store kernel bits. Signed-off-by: Stanislav Kinsburskii <skinsburskii@xxxxxxxxxxxxxxxxxxx> --- include/linux/kexec.h | 7 +++++++ kernel/kexec_file.c | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 22b5cd24f581..c9c70551796d 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -282,6 +282,13 @@ arch_kexec_apply_relocations(struct purgatory_info *pi, Elf_Shdr *section, return -ENOEXEC; } #endif + +struct notifier_block; +extern int register_kexec_fdt_notifier(struct notifier_block *nb); +extern int unregister_kexec_fdt_notifier(struct notifier_block *nb); +extern bool kexec_fdt_notify_list_empty(void); +extern int kexec_fdt_notify(void *fdt); + #endif /* CONFIG_KEXEC_FILE */ #ifdef CONFIG_KEXEC_ELF diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 881ba0d1714c..f9245d5e4459 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -43,6 +43,30 @@ static int kexec_calculate_store_digests(struct kimage *image); /* Maximum size in bytes for kernel/initrd files. */ #define KEXEC_FILE_SIZE_MAX min_t(s64, 4LL << 30, SSIZE_MAX) +static BLOCKING_NOTIFIER_HEAD(kexec_fdt_notify_list); + +bool kexec_fdt_notify_list_empty(void) +{ + return kexec_fdt_notify_list.head == NULL; +} + +int kexec_fdt_notify(void *fdt) +{ + return blocking_notifier_call_chain(&kexec_fdt_notify_list, 0, fdt); +} + +int register_kexec_fdt_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&kexec_fdt_notify_list, nb); +} +EXPORT_SYMBOL(register_kexec_fdt_notifier); + +int unregister_kexec_fdt_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&kexec_fdt_notify_list, nb); +} +EXPORT_SYMBOL(unregister_kexec_fdt_notifier); + /* * Currently this is the only default function that is exported as some * architectures need it to do additional handlings. _______________________________________________ kexec mailing list kexec@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/kexec