[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 5/6] xen/device_tree: introduce find_compatible_node
On Wed, 2012-12-05 at 18:19 +0000, Stefano Stabellini wrote: > Introduce a find_compatible_node function that can be used by device > drivers to find the node corresponding to their device in the device > tree. > > Also add device_tree_node_compatible to device_tree.h, that is currently > missing. > > Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> > --- > xen/arch/arm/setup.c | 2 +- > xen/common/device_tree.c | 47 > +++++++++++++++++++++++++++++++++++++++++ > xen/include/xen/device_tree.h | 3 ++ > 3 files changed, 51 insertions(+), 1 deletions(-) > > diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c > index 5f4e318..d978938 100644 > --- a/xen/arch/arm/setup.c > +++ b/xen/arch/arm/setup.c > @@ -187,7 +187,7 @@ void __init start_xen(unsigned long boot_phys_offset, > > smp_clear_cpu_maps(); > > - fdt = (void *)BOOT_MISC_VIRT_START > + device_tree_flattened = fdt = (void *)BOOT_MISC_VIRT_START This seems unrelated to the commit log? Is this to avoid declaring an early variant? It seems like this could mean we can drop the fdt variable from a bunch of the existing early_* functions. > + (atag_paddr & ((1 << SECOND_SHIFT) - 1)); > fdt_size = device_tree_early_init(fdt); > > diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c > index 8d5b6b0..ca0aba7 100644 > --- a/xen/common/device_tree.c > +++ b/xen/common/device_tree.c > @@ -173,6 +173,53 @@ int device_tree_for_each_node(const void *fdt, > return 0; > } > > +struct find_compat { > + const char *compatible; > + int found; > + int node; > + int depth; > + u32 address_cells; > + u32 size_cells; > +}; > + > +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; Do you want if ( c->found ) return ? > + 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; > + else > + { > + *node = c.node; > + *depth = c.depth; > + *address_cells = c.address_cells; > + *size_cells = c.size_cells; > + return 1; > + } > +} > + > /** > * device_tree_bootargs - return the bootargs (the Xen command line) > * @fdt flat device tree. > diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h > index a0e3a97..5a75f0e 100644 > --- a/xen/include/xen/device_tree.h > +++ b/xen/include/xen/device_tree.h > @@ -54,6 +54,9 @@ void device_tree_set_reg(u32 **cell, u32 address_cells, u32 > size_cells, > u64 start, u64 size); > u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name); > bool_t device_tree_node_matches(const void *fdt, int node, const char > *match); > +bool_t device_tree_node_compatible(const void *fdt, int node, const char > *match); > +int find_compatible_node(const char *compatible, int *node, int *depth, > + u32 *address_cells, u32 *size_cells); > int device_tree_for_each_node(const void *fdt, > device_tree_node_func func, void *data); > const char *device_tree_bootargs(const void *fdt); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |