[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v3 6/8] xen/device_tree: introduce find_compatible_node



On Tue, 2012-12-18 at 18:46 +0000, Stefano Stabellini wrote:
> Introduce a find_compatible_node function that can be used by device

> +static int _find_compatible_node(const void *fdt,
> +                             int node, const char *name, int depth,
> +                             u32 address_cells, u32 size_cells,
> +                             void *data)
> +{
> +    struct find_compat *c = (struct find_compat *) data;
> +
> +    if (  c->found  )
> +        return 0;

It'd be nice if returning e.g. 1 would cause device_tree_for_each_node
to stop walking the DTB and return immediately. Would make this function
cleaner and avoid pointlessly parsing the rest of the DTB.

> +
> +    if ( device_tree_node_compatible(fdt, node, c->compatible) )
> +    {
> +        c->found = 1;
> +        c->node = node;
> +        c->depth = depth;
> +        c->address_cells = address_cells;
> +        c->size_cells = size_cells;
> +    }
> +    return 0;
> +}
> + 
> +int find_compatible_node(const char *compatible, int *node, int *depth,
> +                u32 *address_cells, u32 *size_cells)
> +{
> +    int ret;
> +    struct find_compat c;
> +    c.compatible = compatible;
> +    c.found = 0;
> +
> +    ret = device_tree_for_each_node(device_tree_flattened, 
> _find_compatible_node, &c);
> +    if ( !c.found )
> +        return ret;



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.