From: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
To: Pantelis Antoniou
<pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>,
Grant Likely
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Geert Uytterhoeven
<geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
Subject: [PATCH/RFC 3/3] of/dynamic: Update list of aliases on aliases changes
Date: Tue, 30 Jun 2015 16:51:16 +0200 [thread overview]
Message-ID: <1435675876-2159-4-git-send-email-geert+renesas@glider.be> (raw)
In-Reply-To: <1435675876-2159-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
Currently the list of aliases is not updated when an overlay that
modifies /aliases is added or removed. This breaks drivers (e.g. serial)
that rely on of_alias_get_id().
Update the list of aliases when a property of the /aliases node is
added, removed, or updated.
Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
---
- Should the OF core handle this itself, by registering a notifier
using of_reconfig_notifier_register()?
- Adding or destroying the /aliases node itself should be handled,
too.
- Is it safe to deallocate struct alias_prop using kfree()? It may
have been allocated using early_init_dt_alloc_memory_arch() /
memblock_alloc(). What's the alternative? Leaking memory?
---
drivers/of/dynamic.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 1901f8870591fe30..65dfb26f879c3a9a 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -502,6 +502,16 @@ static void __of_changeset_entry_invert(struct of_changeset_entry *ce,
}
}
+static void *alias_alloc(u64 size, u64 align)
+{
+ return kzalloc(size, GFP_KERNEL);
+}
+
+static void alias_free(void *p)
+{
+ kfree(p);
+}
+
static void __of_changeset_entry_notify(struct of_changeset_entry *ce, bool revert)
{
struct of_reconfig_data rd;
@@ -513,6 +523,20 @@ static void __of_changeset_entry_notify(struct of_changeset_entry *ce, bool reve
ce = &ce_inverted;
}
+ if (ce->np == of_aliases) {
+ switch (ce->action) {
+ case OF_RECONFIG_ADD_PROPERTY:
+ of_alias_create(ce->prop, alias_alloc);
+ break;
+ case OF_RECONFIG_REMOVE_PROPERTY:
+ of_alias_destroy(ce->prop->name, alias_free);
+ break;
+ case OF_RECONFIG_UPDATE_PROPERTY:
+ of_alias_destroy(ce->old_prop->name, alias_free);
+ of_alias_create(ce->prop, alias_alloc);
+ break;
+ }
+ }
switch (ce->action) {
case OF_RECONFIG_ATTACH_NODE:
case OF_RECONFIG_DETACH_NODE:
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-06-30 14:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-30 14:51 [PATCH/RFC 0/3] of/overlay: Update aliases when added or removed Geert Uytterhoeven
[not found] ` <1435675876-2159-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2015-06-30 14:51 ` [PATCH/RFC 1/3] of: Extract of_alias_create() Geert Uytterhoeven
2015-06-30 14:51 ` [PATCH/RFC 2/3] of: Add of_alias_destroy() Geert Uytterhoeven
2015-06-30 14:51 ` Geert Uytterhoeven [this message]
2015-06-30 17:21 ` [PATCH/RFC 3/3] of/dynamic: Update list of aliases on aliases changes Grant Likely
[not found] ` <20150630172131.D4E6CC4041A-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2015-07-01 6:53 ` Geert Uytterhoeven
2015-06-30 17:24 ` [PATCH/RFC 0/3] of/overlay: Update aliases when added or removed Grant Likely
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=1435675876-2159-4-git-send-email-geert+renesas@glider.be \
--to=geert+renesas-gxvu3+zwzmszqb+pc5nmwq@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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;
as well as URLs for NNTP newsgroup(s).