[PATCH] fwts_acpu_tables: move array gas_space_id_names into get_space_id_name

Alex Hung alex.hung at canonical.com
Sun Apr 11 20:45:06 UTC 2021


There is a typo in subject - it should be "fwts_acpi_tables" instead of
"fwts_acpu_tables"

On 2021-04-11 7:09 a.m., Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
> 
> The scope of gas_space_id_names is limited to function get_space_id_name
> so move it into the function. Also add array bounds checking based
> on the array size and don't rely on index position 0x0b to cater for
> id 0x7f as we may add more GAS types in the future and this last index
> position will change, just use a literal string instead.
> 
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/lib/src/fwts_acpi_tables.c | 46 ++++++++++++++++++----------------
>  1 file changed, 25 insertions(+), 21 deletions(-)
> 
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index ac3b9890..b870bffd 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -1604,30 +1604,34 @@ void fwts_acpi_reserved_type_check(
>  }
>  
>  /*
> - *  Space Id defined for Generic Address Structure (GAS)
> - *  See Table 5.1: Generic Address Structure (GAS) in ACPI spec
> - *  Also see fwts_acpi.h
> + *  get_space_id_name()
> + *  convert Generic Address Structure to a string, NULL if undefined
>   */
> -static const char *gas_space_id_names[] = {
> -	"System Memory (0x0)",
> -	"System I/O (0x1)",
> -	"PCI Configuration (0x2)",
> -	"Embedded Controller (0x3)",
> -	"SMBus (0x4)",
> -	"SystemCMOS (0x5)",
> -	"PciBarTarget (0x6)",
> -	"IPMI (0x7)",
> -	"General PurposeIO (0x8)",
> -	"GenericSerialBus (0x9)",
> -	"Platform Communications Channel (0xa)",
> -	"Functional Fixed Hardware (0x7f)",
> -};
> -
> -static const char *get_space_id_name(uint8_t id) {
> -	if (id <= 0x0a)
> +static const char *get_space_id_name(const uint8_t id)
> +{
> +	/*
> +	 *  Space Id defined for Generic Address Structure (GAS)
> +	 *  See Table 5.1: Generic Address Structure (GAS) in ACPI spec
> +	 *  Also see fwts_acpi.h
> +	 */
> +	static const char *gas_space_id_names[] = {
> +		"System Memory (0x0)",
> +		"System I/O (0x1)",
> +		"PCI Configuration (0x2)",
> +		"Embedded Controller (0x3)",
> +		"SMBus (0x4)",
> +		"SystemCMOS (0x5)",
> +		"PciBarTarget (0x6)",
> +		"IPMI (0x7)",
> +		"General PurposeIO (0x8)",
> +		"GenericSerialBus (0x9)",
> +		"Platform Communications Channel (0xa)"
> +	};
> +
> +	if (id < FWTS_ARRAY_SIZE(gas_space_id_names))
>  		return gas_space_id_names[id];
>  	else if (id == 0x7f)
> -		return gas_space_id_names[0x0b];
> +		return "Functional Fixed Hardware (0x7f)";
>  	else
>  		return NULL;
>  }
> 


-- 
Cheers,
Alex Hung



More information about the fwts-devel mailing list