diff mbox series

[net-next] net: sxgbe: change conditional statement from if to switch

Message ID 20250116160314.23873-1-aha310510@gmail.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: sxgbe: change conditional statement from if to switch | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 61 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2025-01-16--18-01 (tests: 885)

Commit Message

Jeongjun Park Jan. 16, 2025, 4:03 p.m. UTC
Change the if conditional statement in sxgbe_rx_ctxt_wbstatus() to a switch
conditional statement to improve readability, and also add processing for
cases where all conditions are not satisfied.

Signed-off-by: Jeongjun Park <aha310510@gmail.com>
---
 .../net/ethernet/samsung/sxgbe/sxgbe_desc.c   | 43 +++++++++++++------
 1 file changed, 30 insertions(+), 13 deletions(-)

--
diff mbox series

Patch

diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.c
index b33ebf2dca47..5e69ab8a4b90 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.c
@@ -421,31 +421,48 @@  static void sxgbe_rx_ctxt_wbstatus(struct sxgbe_rx_ctxt_desc *p,
 	if (p->tstamp_dropped)
 		x->timestamp_dropped++;
 
-	/* ptp */
-	if (p->ptp_msgtype == RX_NO_PTP)
+	/* PTP Msg type */
+	switch (p->ptp_msgtype) {
+	case RX_NO_PTP:
 		x->rx_msg_type_no_ptp++;
-	else if (p->ptp_msgtype == RX_PTP_SYNC)
+		break;
+	case RX_PTP_SYNC:
 		x->rx_ptp_type_sync++;
-	else if (p->ptp_msgtype == RX_PTP_FOLLOW_UP)
+		break;
+	case RX_PTP_FOLLOW_UP:
 		x->rx_ptp_type_follow_up++;
-	else if (p->ptp_msgtype == RX_PTP_DELAY_REQ)
+		break;
+	case RX_PTP_DELAY_REQ:
 		x->rx_ptp_type_delay_req++;
-	else if (p->ptp_msgtype == RX_PTP_DELAY_RESP)
+		break;
+	case RX_PTP_DELAY_RESP:
 		x->rx_ptp_type_delay_resp++;
-	else if (p->ptp_msgtype == RX_PTP_PDELAY_REQ)
+		break;
+	case RX_PTP_PDELAY_REQ:
 		x->rx_ptp_type_pdelay_req++;
-	else if (p->ptp_msgtype == RX_PTP_PDELAY_RESP)
+		break;
+	case RX_PTP_PDELAY_RESP:
 		x->rx_ptp_type_pdelay_resp++;
-	else if (p->ptp_msgtype == RX_PTP_PDELAY_FOLLOW_UP)
+		break;
+	case RX_PTP_PDELAY_FOLLOW_UP:
 		x->rx_ptp_type_pdelay_follow_up++;
-	else if (p->ptp_msgtype == RX_PTP_ANNOUNCE)
+		break;
+	case RX_PTP_ANNOUNCE:
 		x->rx_ptp_announce++;
-	else if (p->ptp_msgtype == RX_PTP_MGMT)
+		break;
+	case RX_PTP_MGMT:
 		x->rx_ptp_mgmt++;
-	else if (p->ptp_msgtype == RX_PTP_SIGNAL)
+		break;
+	case RX_PTP_SIGNAL:
 		x->rx_ptp_signal++;
-	else if (p->ptp_msgtype == RX_PTP_RESV_MSG)
+		break;
+	case RX_PTP_RESV_MSG:
 		x->rx_ptp_resv_msg_type++;
+		break;
+	default:
+		pr_err("Invalid PTP Message type\n");
+		break;
+	}
 }
 
 /* Get rx timestamp status */