9
0
Fork 0

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>
Forwarded: id:1431771149-27265-1-git-send-email-u.kleine-koenig@pengutronix.de
This commit is contained in:
Uwe Kleine-König 2015-05-16 12:06:29 +02:00
parent d9ada004ea
commit 25d8af0f01
2 changed files with 20 additions and 0 deletions

View File

@ -159,6 +159,25 @@ int of_register_fixup(int (*fixup)(struct device_node *, void *), void *context)
return 0;
}
/*
* 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.

View File

@ -242,6 +242,7 @@ void of_add_memory_bank(struct device_node *node, bool dump, int r,
struct device_d *of_find_device_by_node_path(const char *path);
int of_find_path(struct device_node *node, const char *propname, char **outpath);
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,