svn commit: r322289 - head/sys/dev/ofw
Marcin Wojtas
mw at FreeBSD.org
Wed Aug 9 01:06:41 UTC 2017
Author: mw
Date: Wed Aug 9 01:06:40 2017
New Revision: 322289
URL: https://svnweb.freebsd.org/changeset/base/322289
Log:
Enable using ofw_bus_find_compatible in early platform code
Before this patch function ofw_bus_find_compatible was using
memory allocations in order to find compatible node and the property's
length. This way there was always a suited buffer for property,
however this approach had also disadvantages - ofw_bus_find_compatible
couldn't be used when malloc is not available, e.g. during fdt fixup stage.
In order to remove the usage limitation of ofw_bus_find_compatible(),
this patch modifies the function to use ofw_bus_node_is_compatible()
(instead of the one without _int suffix), which uses a fixed
buffer on stack instead of dynamic allocations.
Submitted by: Patryk Duda <pdk at semihalf.com>
Reviewed by: nwhitehorn, cognet (mentor)
Approved by: cognet (mentor)
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D11880
Modified:
head/sys/dev/ofw/ofw_bus_subr.c
Modified: head/sys/dev/ofw/ofw_bus_subr.c
==============================================================================
--- head/sys/dev/ofw/ofw_bus_subr.c Wed Aug 9 01:04:36 2017 (r322288)
+++ head/sys/dev/ofw/ofw_bus_subr.c Wed Aug 9 01:06:40 2017 (r322289)
@@ -720,22 +720,14 @@ phandle_t
ofw_bus_find_compatible(phandle_t node, const char *onecompat)
{
phandle_t child, ret;
- void *compat;
- int len;
/*
* Traverse all children of 'start' node, and find first with
* matching 'compatible' property.
*/
for (child = OF_child(node); child != 0; child = OF_peer(child)) {
- len = OF_getprop_alloc(child, "compatible", 1, &compat);
- if (len >= 0) {
- ret = ofw_bus_node_is_compatible_int(compat, len,
- onecompat);
- free(compat, M_OFWPROP);
- if (ret != 0)
- return (child);
- }
+ if (ofw_bus_node_is_compatible(child, onecompat) != 0)
+ return (child);
ret = ofw_bus_find_compatible(child, onecompat);
if (ret != 0)
More information about the svn-src-all
mailing list