From c902a6887eaadf56e6da79f68f8843cbe45cc808 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 3 Jun 2026 17:10:14 +0200 Subject: [PATCH] ARM: shmobile: rcar-gen2: Use of_machine_compatible_match() helper Replace sequences of of_machine_is_compatible() calls by single calls to the of_machine_compatible_match() helper, to simplify the code, and to reduce code size. Note that this does have a slight performance impact on matching platforms: while the C sequences terminated evaluation after a match, (internal) of_device_compatible_match() calculates a matching score, and thus always checks against all passed compatible values. Signed-off-by: Geert Uytterhoeven Link: https://patch.msgid.link/2230eb28da9b8d8bdee4e4fd7e19dc8f074531bc.1780499233.git.geert+renesas@glider.be --- arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c | 10 +++++----- arch/arm/mach-shmobile/setup-rcar-gen2.c | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c index 747a96c58df1..647e5f9f6aa8 100644 --- a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c +++ b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c @@ -140,6 +140,10 @@ static struct notifier_block regulator_quirk_nb = { static int __init rcar_gen2_regulator_quirk(void) { + static const char *const boards[] __initconst = { + "renesas,koelsch", "renesas,lager", "renesas,porter", + "renesas,stout", "renesas,gose", NULL + }; struct regulator_quirk *quirk, *pos, *tmp; struct of_phandle_args *args; const struct of_device_id *id; @@ -147,11 +151,7 @@ static int __init rcar_gen2_regulator_quirk(void) u32 mon, addr; int ret; - if (!of_machine_is_compatible("renesas,koelsch") && - !of_machine_is_compatible("renesas,lager") && - !of_machine_is_compatible("renesas,porter") && - !of_machine_is_compatible("renesas,stout") && - !of_machine_is_compatible("renesas,gose")) + if (!of_machine_compatible_match(boards)) return -ENODEV; for_each_matching_node_and_match(np, rcar_gen2_quirk_match, &id) { diff --git a/arch/arm/mach-shmobile/setup-rcar-gen2.c b/arch/arm/mach-shmobile/setup-rcar-gen2.c index 3cd34a42e39b..514558905919 100644 --- a/arch/arm/mach-shmobile/setup-rcar-gen2.c +++ b/arch/arm/mach-shmobile/setup-rcar-gen2.c @@ -56,6 +56,10 @@ static unsigned int __init get_extal_freq(void) static void __init rcar_gen2_timer_init(void) { + static const char *const fixed_freq_socs[] __initconst = { + "renesas,r8a7745", "renesas,r8a77470", "renesas,r8a7792", + "renesas,r8a7794", NULL + }; bool need_update = true; void __iomem *base; u32 freq; @@ -76,10 +80,7 @@ static void __init rcar_gen2_timer_init(void) secure_cntvoff_init(); - if (of_machine_is_compatible("renesas,r8a7745") || - of_machine_is_compatible("renesas,r8a77470") || - of_machine_is_compatible("renesas,r8a7792") || - of_machine_is_compatible("renesas,r8a7794")) { + if (of_machine_compatible_match(fixed_freq_socs)) { freq = 260000000 / 8; /* ZS / 8 */ } else { /* At Linux boot time the r8a7790 arch timer comes up