Re: [PATCH v2 2/3] Make next_type_marker and type_marker_length helpers public

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



On Mon, Jul 30, 2018 at 09:57:36PM -0600, Rob Herring wrote:
> Make next_type_marker and type_marker_length available to other users of
> TYPE_* markers.
> 
> Signed-off-by: Rob Herring <robh@xxxxxxxxxx>

So, I'm find with exposing these, but I'd like some details changed:

> ---
>  dtc.h        | 16 ++++++++++++++++
>  treesource.c | 16 ----------------

I don't see a good case for making these inlines.  I think it would be
better to move them to data.c (since they're helpers pertaining to
data objects) and expose them as externs.

>  2 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/dtc.h b/dtc.h
> index 303c2a6a73b7..e0d4fefd294f 100644
> --- a/dtc.h
> +++ b/dtc.h
> @@ -109,6 +109,22 @@ struct data {
>  	for_each_marker(m) \
>  		if ((m)->type == (t))
>  
> +static inline struct marker *next_type_marker(struct marker *m)
> +{
> +        while (m && (m->type == LABEL || m->type == REF_PHANDLE || m->type == REF_PATH))
> +                m = m->next;
> +        return m;
> +}
> +
> +static inline size_t type_marker_length(struct marker *m)
> +{
> +        struct marker *next = next_type_marker(m->next);
> +
> +        if (next)
> +                return next->offset - m->offset;
> +        return 0;
> +}
> +
>  void data_free(struct data d);
>  
>  struct data data_grow_for(struct data d, int xlen);
> diff --git a/treesource.c b/treesource.c
> index f99544d72344..6ab2b1048197 100644
> --- a/treesource.c
> +++ b/treesource.c
> @@ -133,22 +133,6 @@ static void write_propval_int(FILE *f, const char *p, size_t len, size_t width)
>  	}
>  }
>  
> -static struct marker *next_type_marker(struct marker *m)
> -{
> -	while (m && (m->type == LABEL || m->type == REF_PHANDLE || m->type == REF_PATH))
> -		m = m->next;
> -	return m;
> -}
> -
> -static size_t type_marker_length(struct marker *m)
> -{
> -	struct marker *next = next_type_marker(m->next);
> -
> -	if (next)
> -		return next->offset - m->offset;
> -	return 0;
> -}
> -
>  static const char *delim_start[] = {
>  	[TYPE_UINT8] = "[",
>  	[TYPE_UINT16] = "/bits/ 16 <",

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux