summaryrefslogtreecommitdiffstats
path: root/common/oftree.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2015-05-16 12:12:29 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-05-18 08:06:35 +0200
commit145e65ab12e7a8d7a895b8a8a4631ae303ec734f (patch)
tree9612f457584f15eae8714c0181fbb0174db5246d /common/oftree.c
parent65a8f2f8f1066b589560b1f09f3ae1da485335eb (diff)
downloadbarebox-145e65ab12e7a8d7a895b8a8a4631ae303ec734f.tar.gz
barebox-145e65ab12e7a8d7a895b8a8a4631ae303ec734f.tar.xz
of: add a function to remove an of_fixup
This function is needed when a device that already registered a fixup in the probe routine fails later to probe completely. Without unregistering the fixup the function might later be called with invalid data. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/oftree.c')
-rw-r--r--common/oftree.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/oftree.c b/common/oftree.c
index 50fc95b588..f75d7b4bfe 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -160,6 +160,25 @@ int of_register_fixup(int (*fixup)(struct device_node *, void *), void *context)
}
/*
+ * Remove a previously registered fixup. Only the first (if any) is removed.
+ * Returns 0 if a match was found (and removed), -ENOENT otherwise.
+ */
+int of_unregister_fixup(int (*fixup)(struct device_node *, void *),
+ void *context)
+{
+ struct of_fixup *of_fixup;
+
+ list_for_each_entry(of_fixup, &of_fixup_list, list) {
+ if (of_fixup->fixup == fixup && of_fixup->context == context) {
+ list_del(&of_fixup->list);
+ return 0;
+ }
+ }
+
+ return -ENOENT;
+}
+
+/*
* Apply registered fixups for the given fdt. The fdt must have
* enough free space to apply the fixups.
*/