mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: barebox@lists.infradead.org
Cc: Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH] ARM: at91: setup: refactor SoC subtype detection with switch statements
Date: Wed, 18 Jun 2025 09:35:51 +0300	[thread overview]
Message-ID: <20250618063552.23777-4-eagle.alexander923@gmail.com> (raw)
In-Reply-To: <20250618063552.23777-1-eagle.alexander923@gmail.com>

This patch replaces the series of independent if-statements in
dbgu_soc_detect() with a structured switch-case approach for
better code organization and readability.

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 arch/arm/mach-at91/setup.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 708c946192..e8d45c30dd 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -102,7 +102,8 @@ static void __init dbgu_soc_detect(u32 dbgu_base)
 
 	at91_soc_initdata.cidr = cidr;
 
-	if (at91_soc_initdata.type == AT91_SOC_SAM9G45) {
+	switch (at91_soc_initdata.type) {
+	case AT91_SOC_SAM9G45:
 		switch (at91_soc_initdata.exid) {
 		case ARCH_EXID_AT91SAM9M10:
 			at91_soc_initdata.subtype = AT91_SOC_SAM9M10;
@@ -114,9 +115,8 @@ static void __init dbgu_soc_detect(u32 dbgu_base)
 			at91_soc_initdata.subtype = AT91_SOC_SAM9M11;
 			break;
 		}
-	}
-
-	if (at91_soc_initdata.type == AT91_SOC_SAM9X5) {
+		break;
+	case AT91_SOC_SAM9X5:
 		switch (at91_soc_initdata.exid) {
 		case ARCH_EXID_AT91SAM9G15:
 			at91_soc_initdata.subtype = AT91_SOC_SAM9G15;
@@ -134,9 +134,8 @@ static void __init dbgu_soc_detect(u32 dbgu_base)
 			at91_soc_initdata.subtype = AT91_SOC_SAM9X25;
 			break;
 		}
-	}
-
-	if (at91_soc_initdata.type == AT91_SOC_SAM9N12) {
+		break;
+	case AT91_SOC_SAM9N12:
 		switch (at91_soc_initdata.exid) {
 		case ARCH_EXID_AT91SAM9N12:
 			at91_soc_initdata.subtype = AT91_SOC_SAM9N12;
@@ -148,9 +147,8 @@ static void __init dbgu_soc_detect(u32 dbgu_base)
 			at91_soc_initdata.subtype = AT91_SOC_SAM9CN12;
 			break;
 		}
-	}
-
-	if (at91_soc_initdata.type == AT91_SOC_SAMA5D3) {
+		break;
+	case AT91_SOC_SAMA5D3:
 		switch (at91_soc_initdata.exid) {
 		case ARCH_EXID_SAMA5D31:
 			at91_soc_initdata.subtype = AT91_SOC_SAMA5D31;
@@ -168,9 +166,8 @@ static void __init dbgu_soc_detect(u32 dbgu_base)
 			at91_soc_initdata.subtype = AT91_SOC_SAMA5D36;
 			break;
 		}
-	}
-
-	if (at91_soc_initdata.type == AT91_SOC_SAMA5D4) {
+		break;
+	case AT91_SOC_SAMA5D4:
 		switch (at91_soc_initdata.exid) {
 		case ARCH_EXID_SAMA5D41:
 			at91_soc_initdata.subtype = AT91_SOC_SAMA5D41;
@@ -185,6 +182,7 @@ static void __init dbgu_soc_detect(u32 dbgu_base)
 			at91_soc_initdata.subtype = AT91_SOC_SAMA5D44;
 			break;
 		}
+		break;
 	}
 }
 
-- 
2.39.1




  parent reply	other threads:[~2025-06-18  6:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18  6:35 [PATCH] ARM: at91: clock: remove unused SAMA5D2/SAMA5D3 support from legacy clock driver Alexander Shiyan
2025-06-18  6:35 ` [PATCH] ARM: at91: sam9x5ek: enable missing DT and clock options for devicetree boot Alexander Shiyan
2025-06-18 10:13   ` Sascha Hauer
2025-06-18  6:35 ` [PATCH] ARM: at91: setup: improve address handling for DBGU and CHIPID detection Alexander Shiyan
2025-06-18 10:13   ` Sascha Hauer
2025-06-18  6:35 ` Alexander Shiyan [this message]
2025-06-18 10:13   ` [PATCH] ARM: at91: setup: refactor SoC subtype detection with switch statements Sascha Hauer
2025-06-18  6:35 ` [PATCH] ARM: at91: xload: use pin_to_mask for peripheral pin configuration Alexander Shiyan
2025-06-18 10:13   ` (subset) " Sascha Hauer
2025-06-18 10:13   ` Sascha Hauer
2025-06-18 10:13 ` (subset) [PATCH] ARM: at91: clock: remove unused SAMA5D2/SAMA5D3 support from legacy clock driver Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250618063552.23777-4-eagle.alexander923@gmail.com \
    --to=eagle.alexander923@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox