Re: [PATCH] fixup! of: fdt: implement fdt_machine_is_compatible

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

 



On Mon, Mar 04, 2024 at 07:55:58PM +0100, Ahmad Fatoum wrote:
> of: fdt: have fdt_machine_is_compatible() return a score
> 
> fdt_machine_is_compatible() currently returns false on mismatch and
> true on match. of_machine_is_compatible(), that it's meant to partially
> replace, returns a positive score value, so multiple compatible machines
> can be compared. Do likewise for fdt_machine_is_compatible.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
> ---
>  drivers/of/fdt.c | 18 +++++++++---------
>  include/of.h     |  2 +-
>  2 files changed, 10 insertions(+), 10 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 23b7b90f8e54..2f3b0763999d 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -690,7 +690,7 @@ static int fdt_string_is_compatible(const char *haystack, int haystack_len,
>  	return 0;
>  }
>  
> -bool fdt_machine_is_compatible(const struct fdt_header *fdt, size_t fdt_size, const char *compat)
> +int fdt_machine_is_compatible(const struct fdt_header *fdt, size_t fdt_size, const char *compat)
>  {
>  	uint32_t tag;
>  	const struct fdt_property *fdt_prop;
> @@ -705,7 +705,7 @@ bool fdt_machine_is_compatible(const struct fdt_header *fdt, size_t fdt_size, co
>  
>  	ret = fdt_parse_header(fdt, fdt_size, &f);
>  	if (ret < 0)
> -		return false;
> +		return 0;
>  
>  	dt_struct = f.off_dt_struct;
>  	dt_strings = (const void *)fdt + f.off_dt_strings;
> @@ -713,11 +713,11 @@ bool fdt_machine_is_compatible(const struct fdt_header *fdt, size_t fdt_size, co
>  	while (1) {
>  		const __be32 *tagp = (const void *)fdt + dt_struct;
>  		if (!dt_ptr_ok(fdt, tagp))
> -			return false;
> +			return 0;
>  
>  		tag = be32_to_cpu(*tagp);
>  		if (tag != FDT_NOP && tag != expect)
> -			return false;
> +			return 0;
>  
>  		switch (tag) {
>  		case FDT_BEGIN_NODE:
> @@ -725,7 +725,7 @@ bool fdt_machine_is_compatible(const struct fdt_header *fdt, size_t fdt_size, co
>  
>  			/* The root node must have an empty name */
>  			if (fnh->name[0] != '\0')
> -				return false;
> +				return 0;
>  
>  			dt_struct = dt_struct_advance(&f, dt_struct,
>  					sizeof(struct fdt_node_header) + 1);
> @@ -739,7 +739,7 @@ bool fdt_machine_is_compatible(const struct fdt_header *fdt, size_t fdt_size, co
>  
>  			name = dt_string(&f, dt_strings, fdt32_to_cpu(fdt_prop->nameoff));
>  			if (!name)
> -				return false;
> +				return 0;
>  
>  			if (strcmp(name, "compatible")) {
>  				dt_struct = dt_struct_advance(&f, dt_struct,
> @@ -754,12 +754,12 @@ bool fdt_machine_is_compatible(const struct fdt_header *fdt, size_t fdt_size, co
>  			break;
>  
>  		default:
> -			return false;
> +			return 0;
>  		}
>  
>  		if (!dt_struct)
> -			return false;
> +			return 0;
>  	}
>  
> -	return false;
> +	return 0;
>  }
> diff --git a/include/of.h b/include/of.h
> index 7ee75728d0ad..9cd2c9aee2a4 100644
> --- a/include/of.h
> +++ b/include/of.h
> @@ -64,7 +64,7 @@ void of_clean_reserve_map(void);
>  void fdt_add_reserve_map(void *fdt);
>  void fdt_print_reserve_map(const void *fdt);
>  
> -bool fdt_machine_is_compatible(const struct fdt_header *fdt, size_t fdt_size, const char *compat);
> +int fdt_machine_is_compatible(const struct fdt_header *fdt, size_t fdt_size, const char *compat);
>  
>  
>  struct device;
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux