[RFC,09/12] libpdbg: Initialise target class from device-tree
diff mbox series

Message ID 20190806013723.4047-10-alistair@popple.id.au
State New
Headers show
Series
  • Split backends from system description
Related show

Checks

Context Check Description
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (d0a0d919cccbd69631aaef0d37f1dba8d53e86e0)

Commit Message

Alistair Popple Aug. 6, 2019, 1:37 a.m. UTC
The target class is usually initialised from the hardware unit
description. However if no hardware unit is found no class is
assigned. This patch makes it possible to assign one in cases when no
hardware unit is available.

This is primarily useful for busses and other targets that have
drivers assigned via the backend selection logic.

Signed-off-by: Alistair Popple <alistair@popple.id.au>
---
 libpdbg/device.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Amitay Isaacs Aug. 20, 2019, 4:06 a.m. UTC | #1
I guess we can keep this for time being till we add drivers for all the
hardware units.

Reviewed-by: Amitay Isaacs <amitay@ozlabs.org>

On Tue, 2019-08-06 at 11:37 +1000, Alistair Popple wrote:
> The target class is usually initialised from the hardware unit
> description. However if no hardware unit is found no class is
> assigned. This patch makes it possible to assign one in cases when no
> hardware unit is available.
> 
> This is primarily useful for busses and other targets that have
> drivers assigned via the backend selection logic.
> 
> Signed-off-by: Alistair Popple <alistair@popple.id.au>
> ---
>  libpdbg/device.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/libpdbg/device.c b/libpdbg/device.c
> index f6d27db..428d946 100644
> --- a/libpdbg/device.c
> +++ b/libpdbg/device.c
> @@ -118,6 +118,8 @@ static struct pdbg_target *pdbg_target_new(const
> void *fdt, int node_offset)
>  
>  static struct pdbg_target *dt_new_node(const char *name, const void
> *fdt, int node_offset)
>  {
> +	struct pdbg_target_class *target_class;
> +	const struct fdt_property *prop;
>  	struct pdbg_target *node = NULL;
>  	size_t size = sizeof(*node);
>  
> @@ -132,6 +134,15 @@ static struct pdbg_target *dt_new_node(const
> char *name, const void *fdt, int no
>  		abort();
>  	}
>  
> +	if (fdt && !node->class) {
> +		prop = fdt_get_property(fdt, node_offset, "class",
> NULL);
> +		if (prop) {
> +			node->class = (char *) &prop->data[0];
> +			target_class = get_target_class(node);
> +			list_add_tail(&target_class->targets, &node-
> >class_link);
> +		}
> +	}
> +
>  	node->dn_name = take_name(name);
>  	node->parent = NULL;
>  	list_head_init(&node->properties);
> -- 
> 2.20.1
> 

Amitay.
Alistair Popple Aug. 20, 2019, 4:58 a.m. UTC | #2
This was only required for the subsequent patches so I will drop this from the 
series for now. We can always add it back if it turns out we need it later on.

- Alistair

On Tuesday, 20 August 2019 2:06:52 PM AEST Amitay Isaacs wrote:
> I guess we can keep this for time being till we add drivers for all the
> hardware units.
> 
> Reviewed-by: Amitay Isaacs <amitay@ozlabs.org>
> 
> On Tue, 2019-08-06 at 11:37 +1000, Alistair Popple wrote:
> > The target class is usually initialised from the hardware unit
> > description. However if no hardware unit is found no class is
> > assigned. This patch makes it possible to assign one in cases when no
> > hardware unit is available.
> > 
> > This is primarily useful for busses and other targets that have
> > drivers assigned via the backend selection logic.
> > 
> > Signed-off-by: Alistair Popple <alistair@popple.id.au>
> > ---
> >  libpdbg/device.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/libpdbg/device.c b/libpdbg/device.c
> > index f6d27db..428d946 100644
> > --- a/libpdbg/device.c
> > +++ b/libpdbg/device.c
> > @@ -118,6 +118,8 @@ static struct pdbg_target *pdbg_target_new(const
> > void *fdt, int node_offset)
> >  
> >  static struct pdbg_target *dt_new_node(const char *name, const void
> > *fdt, int node_offset)
> >  {
> > +	struct pdbg_target_class *target_class;
> > +	const struct fdt_property *prop;
> >  	struct pdbg_target *node = NULL;
> >  	size_t size = sizeof(*node);
> >  
> > @@ -132,6 +134,15 @@ static struct pdbg_target *dt_new_node(const
> > char *name, const void *fdt, int no
> >  		abort();
> >  	}
> >  
> > +	if (fdt && !node->class) {
> > +		prop = fdt_get_property(fdt, node_offset, "class",
> > NULL);
> > +		if (prop) {
> > +			node->class = (char *) &prop->data[0];
> > +			target_class = get_target_class(node);
> > +			list_add_tail(&target_class->targets, &node-
> > >class_link);
> > +		}
> > +	}
> > +
> >  	node->dn_name = take_name(name);
> >  	node->parent = NULL;
> >  	list_head_init(&node->properties);
> 
> Amitay.
>

Patch
diff mbox series

diff --git a/libpdbg/device.c b/libpdbg/device.c
index f6d27db..428d946 100644
--- a/libpdbg/device.c
+++ b/libpdbg/device.c
@@ -118,6 +118,8 @@  static struct pdbg_target *pdbg_target_new(const void *fdt, int node_offset)
 
 static struct pdbg_target *dt_new_node(const char *name, const void *fdt, int node_offset)
 {
+	struct pdbg_target_class *target_class;
+	const struct fdt_property *prop;
 	struct pdbg_target *node = NULL;
 	size_t size = sizeof(*node);
 
@@ -132,6 +134,15 @@  static struct pdbg_target *dt_new_node(const char *name, const void *fdt, int no
 		abort();
 	}
 
+	if (fdt && !node->class) {
+		prop = fdt_get_property(fdt, node_offset, "class", NULL);
+		if (prop) {
+			node->class = (char *) &prop->data[0];
+			target_class = get_target_class(node);
+			list_add_tail(&target_class->targets, &node->class_link);
+		}
+	}
+
 	node->dn_name = take_name(name);
 	node->parent = NULL;
 	list_head_init(&node->properties);