kernel: add platform_has() infrastructure
Add a simple infrastructure for setting, resetting and querying platform feature flags. Flags can be either global or architecture specific. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> Tested-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> # Arm64 only Reviewed-by: Christoph Hellwig <hch@lst.de> Acked-by: Borislav Petkov <bp@suse.de> Signed-off-by: Juergen Gross <jgross@suse.com>
This commit is contained in:
27
kernel/platform-feature.c
Normal file
27
kernel/platform-feature.c
Normal file
@@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/cache.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/platform-feature.h>
|
||||
|
||||
#define PLATFORM_FEAT_ARRAY_SZ BITS_TO_LONGS(PLATFORM_FEAT_N)
|
||||
static unsigned long __read_mostly platform_features[PLATFORM_FEAT_ARRAY_SZ];
|
||||
|
||||
void platform_set(unsigned int feature)
|
||||
{
|
||||
set_bit(feature, platform_features);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(platform_set);
|
||||
|
||||
void platform_clear(unsigned int feature)
|
||||
{
|
||||
clear_bit(feature, platform_features);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(platform_clear);
|
||||
|
||||
bool platform_has(unsigned int feature)
|
||||
{
|
||||
return test_bit(feature, platform_features);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(platform_has);
|
||||
Reference in New Issue
Block a user