diff options
author | Luis R. Rodriguez <mcgrof@kernel.org> | 2015-10-23 19:23:44 -0700 |
---|---|---|
committer | Luis R. Rodriguez <mcgrof@kernel.org> | 2016-02-11 08:42:16 -0800 |
commit | 527a05f14c4520626b814f65851acc727cd8a6bc (patch) | |
tree | ebe2c25900965e63edc59c185d664f3ed56c4880 | |
parent | 0f9830d41512fc40509526e5ac25baffd241376c (diff) | |
download | linker-tables-527a05f14c4520626b814f65851acc727cd8a6bc.tar.gz |
init: add detection support to init structure
This lets a component have a detection routine.
This mimics the struct iommu_table_entry from the
kernel. For now we just add a detect routine to
the x thing.
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
-rw-r--r-- | init.c | 13 | ||||
-rw-r--r-- | init.h | 1 |
2 files changed, 11 insertions, 3 deletions
@@ -6,7 +6,12 @@ static void init_x(void) { sleep(1); } +static int detect_x(void) { + return 1; +} + struct init_fn x_init_fn __init_fn(INIT_EARLY) = { + .detect = detect_x, .initialise = init_x, .name = "X thing", }; @@ -20,9 +25,11 @@ int init(void) printf("Number of init entries: %d\n", num_inits); for_each_table_entry (init_fn, INIT_FNS) { - printf("Initializing %s ...\n", init_fn->name); - init_fn->initialise(); - printf("Completed initializing %s !\n", init_fn->name); + if (init_fn->detect && init_fn->detect() > 0) { + printf("Initializing %s ...\n", init_fn->name); + init_fn->initialise(); + printf("Completed initializing %s !\n", init_fn->name); + } } return 0; @@ -7,6 +7,7 @@ * call to init(). */ struct init_fn { + int (* detect)(void); void (* initialise) (void); const char *name; }; |