|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 7/7] xen/arm: get the number of cpus from device tree
> diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
> index 3d1f0f4..3ae0f4d 100644
> --- a/xen/common/device_tree.c
> +++ b/xen/common/device_tree.c
> @@ -153,6 +153,26 @@ const char *device_tree_bootargs(const void *fdt)
> return prop->data;
> }
>
> +int device_tree_cpus(const void *fdt)
> +{
> + int node, depth;
> + int cpus = 0;
> +
> + node = fdt_path_offset(fdt, "/cpus");
> + if ( node < 0 )
> + return -1;
With this we will stumble on with cpus == -1 (~4 billion, which would
make a nice system ;-) ). Perhaps we should either assume UP (with a big
printk) or BUG on failure here?
> + do {
> + node = fdt_next_node(fdt, node, &depth);
> + if ( node < 0 )
> + break;
> + if ( strncmp(fdt_get_name(fdt, node, NULL), "cpu", 3) )
> + break;
If we find /cpus/foo (for any foo != "cpu*") then we stop counting,
rather than just ignoring that node?
> + cpus++;
> + } while ( depth > 0 );
> +
> + return cpus;
> +}
> +
> static int dump_node(const void *fdt, int node, const char *name, int depth,
> u32 address_cells, u32 size_cells, void *data)
> {
> diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
> index 4d010c0..46bc0f8 100644
> --- a/xen/include/xen/device_tree.h
> +++ b/xen/include/xen/device_tree.h
> @@ -49,6 +49,7 @@ bool_t device_tree_node_matches(const void *fdt, int node,
> const char *match);
> int device_tree_for_each_node(const void *fdt,
> device_tree_node_func func, void *data);
> const char *device_tree_bootargs(const void *fdt);
> +int device_tree_cpus(const void *fdt);
> void device_tree_dump(const void *fdt);
>
> #endif
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |