]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ARM: rmobile: Clean up rmobile_cpuinfo_idx()
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Sat, 19 Aug 2023 14:39:13 +0000 (16:39 +0200)
committerTom Rini <trini@konsulko.com>
Wed, 6 Sep 2023 17:47:44 +0000 (13:47 -0400)
Clean the function up a bit further. Return immediately on match
and return ARRAY_SIZE() - 1 on failure. Add proper comment in that
case.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Reviewed-by: Paul Barker <paul.barker.ct@bp.renesas.com>
arch/arm/mach-rmobile/cpu_info.c

index 7651e43bd0fcf040db1e528539bb3549a9666725..6804b1da2cda60f8d14e53750c7730ffd24c081b 100644 (file)
@@ -83,14 +83,15 @@ static const struct {
 
 static int rmobile_cpuinfo_idx(void)
 {
-       int i = 0;
        u32 cpu_type = rmobile_get_cpu_type();
+       int i;
 
-       for (; i < ARRAY_SIZE(rmobile_cpuinfo) - 1; i++)
+       for (i = 0; i < ARRAY_SIZE(rmobile_cpuinfo) - 1; i++)
                if (rmobile_cpuinfo[i].cpu_type == cpu_type)
-                       break;
+                       return i;
 
-       return i;
+       /* Unknown "CPU" entry */
+       return ARRAY_SIZE(rmobile_cpuinfo) - 1;
 }
 
 static const u8 *get_cpu_name(int idx)