[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 Thu, 6 Dec 2012, Ian Campbell wrote:
> 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.

Yes, it is needed to make device_tree_flattened available earlier than
setup_mm.
I'll get rid of fdt.


> >          + (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 ?

Good idea


_______________________________________________
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®.