mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] of: add a function to remove an of_fixup
Date: Sat, 16 May 2015 12:12:29 +0200	[thread overview]
Message-ID: <1431771149-27265-1-git-send-email-u.kleine-koenig@pengutronix.de> (raw)

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>
---
 common/oftree.c | 19 +++++++++++++++++++
 include/of.h    |  1 +
 2 files changed, 20 insertions(+)

diff --git a/common/oftree.c b/common/oftree.c
index 50fc95b58820..f75d7b4bfe5d 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.
  */
diff --git a/include/of.h b/include/of.h
index e73cd7a446b7..c02f5f49aba4 100644
--- a/include/of.h
+++ b/include/of.h
@@ -243,6 +243,7 @@ struct device_d *of_find_device_by_node_path(const char *path);
 #define OF_FIND_PATH_FLAGS_BB 1		/* return .bb device if available */
 int of_find_path(struct device_node *node, const char *propname, char **outpath, unsigned flags);
 int of_register_fixup(int (*fixup)(struct device_node *, void *), void *context);
+int of_unregister_fixup(int (*fixup)(struct device_node *, void *), void *context);
 struct device_node *of_find_node_by_alias(struct device_node *root,
 		const char *alias);
 struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2015-05-16 10:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431771149-27265-1-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox