lkml.org 
[lkml]   [2015]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH/RFC 3/3] of/dynamic: Update list of aliases on aliases changes
Date
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@glider.be>
---
- 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


\
 
 \ /
  Last update: 2015-06-30 17:01    [W:0.051 / U:2.596 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site