Skip to content

Commit

Permalink
arm64: vdso: simplify arch_vdso_type ifdeffery
Browse files Browse the repository at this point in the history
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 <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20200428164921.41641-3-mark.rutland@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
  • Loading branch information
Mark Rutland authored and willdeacon committed Apr 29, 2020
1 parent 74fc72e commit 3ee16ff
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions arch/arm64/kernel/vdso.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,11 @@ extern char vdso32_start[], vdso32_end[];

/* vdso_lookup arch_index */
enum arch_vdso_type {
ARM64_VDSO = 0,
ARM64_VDSO,
#ifdef CONFIG_COMPAT_VDSO
ARM64_VDSO32 = 1,
ARM64_VDSO32,
#endif /* CONFIG_COMPAT_VDSO */
};
#ifdef CONFIG_COMPAT_VDSO
#define VDSO_TYPES (ARM64_VDSO32 + 1)
#else
#define VDSO_TYPES (ARM64_VDSO + 1)
#endif /* CONFIG_COMPAT_VDSO */

struct __vdso_abi {
const char *name;
Expand All @@ -57,14 +52,14 @@ struct __vdso_abi {
struct vm_special_mapping *cm;
};

static struct __vdso_abi vdso_lookup[VDSO_TYPES] __ro_after_init = {
{
static struct __vdso_abi vdso_lookup[] __ro_after_init = {
[ARM64_VDSO] = {
.name = "vdso",
.vdso_code_start = vdso_start,
.vdso_code_end = vdso_end,
},
#ifdef CONFIG_COMPAT_VDSO
{
[ARM64_VDSO32] = {
.name = "vdso32",
.vdso_code_start = vdso32_start,
.vdso_code_end = vdso32_end,
Expand Down

0 comments on commit 3ee16ff

Please sign in to comment.