Skip to content

Commit 3ee16ff

Browse files
mrutland-armwilldeacon
authored andcommitted
arm64: vdso: simplify arch_vdso_type ifdeffery
Currently we have some ifdeffery to determine the number of elements in enum arch_vdso_type as VDSO_TYPES, rather that the usual pattern of having the enum define this: | enum foo_type { | FOO_TYPE_A, | FOO_TYPE_B, | #ifdef CONFIG_C | FOO_TYPE_C, | #endif | NR_FOO_TYPES | } ... however, given we only use this number to size the vdso_lookup[] array, this is redundant anyway as the compiler can automatically size the array to fit all defined elements. So let's remove the VDSO_TYPES to simplify the code. At the same time, let's use designated initializers for the array elements so that these are guarnateed to be at the expected indices, regardless of how we modify the structure. For clariy the redundant explicit initialization of the enum elements is dropped. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Vincenzo Frascino <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 74fc72e commit 3ee16ff

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

arch/arm64/kernel/vdso.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,11 @@ extern char vdso32_start[], vdso32_end[];
3535

3636
/* vdso_lookup arch_index */
3737
enum arch_vdso_type {
38-
ARM64_VDSO = 0,
38+
ARM64_VDSO,
3939
#ifdef CONFIG_COMPAT_VDSO
40-
ARM64_VDSO32 = 1,
40+
ARM64_VDSO32,
4141
#endif /* CONFIG_COMPAT_VDSO */
4242
};
43-
#ifdef CONFIG_COMPAT_VDSO
44-
#define VDSO_TYPES (ARM64_VDSO32 + 1)
45-
#else
46-
#define VDSO_TYPES (ARM64_VDSO + 1)
47-
#endif /* CONFIG_COMPAT_VDSO */
4843

4944
struct __vdso_abi {
5045
const char *name;
@@ -57,14 +52,14 @@ struct __vdso_abi {
5752
struct vm_special_mapping *cm;
5853
};
5954

60-
static struct __vdso_abi vdso_lookup[VDSO_TYPES] __ro_after_init = {
61-
{
55+
static struct __vdso_abi vdso_lookup[] __ro_after_init = {
56+
[ARM64_VDSO] = {
6257
.name = "vdso",
6358
.vdso_code_start = vdso_start,
6459
.vdso_code_end = vdso_end,
6560
},
6661
#ifdef CONFIG_COMPAT_VDSO
67-
{
62+
[ARM64_VDSO32] = {
6863
.name = "vdso32",
6964
.vdso_code_start = vdso32_start,
7065
.vdso_code_end = vdso32_end,

0 commit comments

Comments
 (0)