ACK: [RFC,PATCH 1/7 v2] fwts: Add fwts_firmware_has_features

Alex Hung alex.hung at canonical.com
Mon May 5 08:28:01 UTC 2014


On 04/28/2014 09:35 AM, Jeremy Kerr wrote:
> Add a function to indicate whether a firmware has a particular feature
> mask. This can be used by tests to skip running on firmware without
> certain features.
>
> Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
>
> ---
>   src/lib/include/fwts_firmware.h |   12 ++++++++++++
>   src/lib/src/fwts_firmware.c     |   17 +++++++++++++++++
>   2 files changed, 29 insertions(+)
>
> diff --git a/src/lib/include/fwts_firmware.h b/src/lib/include/fwts_firmware.h
> index 7688d5e..ee3880d 100644
> --- a/src/lib/include/fwts_firmware.h
> +++ b/src/lib/include/fwts_firmware.h
> @@ -19,6 +19,8 @@
>   #ifndef __FWTS_FIRMWARE_H__
>   #define __FWTS_FIRMWARE_H__
>
> +#include <stdbool.h>
> +
>   enum {
>   	FWTS_FIRMWARE_UNKNOWN = 0,
>   	FWTS_FIRMWARE_BIOS = 1,
> @@ -26,6 +28,16 @@ enum {
>   	FWTS_FIRMWARE_OTHER = 100,
>   };
>
> +enum firmware_feature {
> +	FWTS_FW_FEATURE_ACPI = 1 << 0,
> +};
> +
>   int fwts_firmware_detect(void);
> +int fwts_firmware_features(void);
> +
> +static inline bool fwts_firmware_has_features(int features)
> +{
> +	return (fwts_firmware_features() & features) == features;
> +}
>
>   #endif
> diff --git a/src/lib/src/fwts_firmware.c b/src/lib/src/fwts_firmware.c
> index fcc2e80..bf080a7 100644
> --- a/src/lib/src/fwts_firmware.c
> +++ b/src/lib/src/fwts_firmware.c
> @@ -36,3 +36,20 @@ int fwts_firmware_detect(void)
>   	else
>   		return FWTS_FIRMWARE_UEFI;
>   }
> +
> +int fwts_firmware_features(void)
> +{
> +	int features = 0;
> +
> +	/* we just have static feature definitions for now */
> +	switch (fwts_firmware_detect()) {
> +	case FWTS_FIRMWARE_BIOS:
> +	case FWTS_FIRMWARE_UEFI:
> +		features = FWTS_FW_FEATURE_ACPI;
> +		break;
> +	default:
> +		break;
> +	}
> +
> +	return features;
> +}
>


Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list