forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
6 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _ASM_GENERIC_PLATFORM_FEATURE_H | ||
#define _ASM_GENERIC_PLATFORM_FEATURE_H | ||
|
||
/* Number of arch specific feature flags. */ | ||
#define PLATFORM_ARCH_FEAT_N 0 | ||
|
||
#endif /* _ASM_GENERIC_PLATFORM_FEATURE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _PLATFORM_FEATURE_H | ||
#define _PLATFORM_FEATURE_H | ||
|
||
#include <linux/bitops.h> | ||
#include <asm/platform-feature.h> | ||
|
||
/* The platform features are starting with the architecture specific ones. */ | ||
#define PLATFORM_FEAT_N (0 + PLATFORM_ARCH_FEAT_N) | ||
|
||
void platform_set(unsigned int feature); | ||
void platform_clear(unsigned int feature); | ||
bool platform_has(unsigned int feature); | ||
|
||
#endif /* _PLATFORM_FEATURE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |