BAREBOX_CLASSES is the only member of RO_DATA_SECTION that's indeed not read-only. This will lead to issues when we start making to mark that section read-only on sandbox. Replace the linker list thus with an initcall. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- drivers/base/class.c | 20 +------------------- include/asm-generic/barebox.lds.h | 7 ------- include/device.h | 20 ++++++++++++++------ 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/drivers/base/class.c b/drivers/base/class.c index fd7d6b2d7a29..5fbbae0ff025 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -5,11 +5,9 @@ LIST_HEAD(class_list); -static int class_register(struct class *class) +void class_register(struct class *class) { list_add_tail(&class->list, &class_list); - - return 0; } int class_add_device(struct class *class, struct device *dev) @@ -23,19 +21,3 @@ void class_remove_device(struct class *class, struct device *dev) { list_del(&dev->class_list); } - -extern struct class __barebox_class_start[]; -extern struct class __barebox_class_end[]; - -static int register_classes(void) -{ - struct class *c; - - for (c = __barebox_class_start; - c != __barebox_class_end; - c++) - class_register(c); - - return 0; -} -device_initcall(register_classes); diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h index 8bbf5907cdfd..d3736ebaed59 100644 --- a/include/asm-generic/barebox.lds.h +++ b/include/asm-generic/barebox.lds.h @@ -70,12 +70,6 @@ KEEP(*(SORT_BY_NAME(.barebox_magicvar*))) \ __barebox_magicvar_end = .; -#define BAREBOX_CLASSES \ - STRUCT_ALIGN(); \ - __barebox_class_start = .; \ - KEEP(*(SORT_BY_NAME(.barebox_class*))) \ - __barebox_class_end = .; - #define BAREBOX_CLK_TABLE \ STRUCT_ALIGN(); \ __clk_of_table_start = .; \ @@ -144,7 +138,6 @@ BAREBOX_SYMS \ KERNEL_CTORS() \ BAREBOX_MAGICVARS \ - BAREBOX_CLASSES \ BAREBOX_CLK_TABLE \ BAREBOX_DTB \ BAREBOX_RSA_KEYS \ diff --git a/include/device.h b/include/device.h index 8550544ca807..4c76da2f82dd 100644 --- a/include/device.h +++ b/include/device.h @@ -7,6 +7,8 @@ #define DEVICE_H #include <linux/types.h> +#include <linux/list.h> +#include <init.h> enum dev_dma_coherence { DEV_DMA_COHERENCE_DEFAULT = 0, @@ -110,12 +112,18 @@ struct class { struct list_head list; }; -#define DEFINE_DEV_CLASS(_name, _classname) \ - struct class _name __ll_elem(.barebox_class_##_name) \ - __aligned(__alignof__(struct class)) = { \ - .name = _classname, \ - .devices = LIST_HEAD_INIT(_name.devices), \ - } +void class_register(struct class *class); + +#define DEFINE_DEV_CLASS(_name, _classname) \ + struct class _name = { \ + .name = _classname, \ + .devices = LIST_HEAD_INIT(_name.devices), \ + }; \ + static int register_##_name(void) { \ + class_register(&_name); \ + return 0; \ + } \ + pure_initcall(register_##_name); int class_add_device(struct class *class, struct device *dev); void class_remove_device(struct class *class, struct device *dev); -- 2.39.2