aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@kernel.org>2015-10-23 19:23:44 -0700
committerLuis R. Rodriguez <mcgrof@kernel.org>2016-02-11 08:42:16 -0800
commit527a05f14c4520626b814f65851acc727cd8a6bc (patch)
treeebe2c25900965e63edc59c185d664f3ed56c4880
parent0f9830d41512fc40509526e5ac25baffd241376c (diff)
downloadlinker-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.c13
-rw-r--r--init.h1
2 files changed, 11 insertions, 3 deletions
diff --git a/init.c b/init.c
index 5cebb87..5991252 100644
--- a/init.c
+++ b/init.c
@@ -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;
diff --git a/init.h b/init.h
index ccfd9d0..1ff5a11 100644
--- a/init.h
+++ b/init.h
@@ -7,6 +7,7 @@
* call to init().
*/
struct init_fn {
+ int (* detect)(void);
void (* initialise) (void);
const char *name;
};