public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeongjun Park <aha310510@gmail.com>
To: bh74.an@samsung.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jeongjun Park <aha310510@gmail.com>
Subject: [PATCH net-next] net: sxgbe: change conditional statement from if to switch
Date: Fri, 17 Jan 2025 01:03:14 +0900	[thread overview]
Message-ID: <20250116160314.23873-1-aha310510@gmail.com> (raw)

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 --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 */
--

             reply	other threads:[~2025-01-16 16:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16 16:03 Jeongjun Park [this message]
2025-01-17 10:29 ` [PATCH net-next] net: sxgbe: change conditional statement from if to switch Simon Horman
2025-02-19 14:47   ` Jeongjun Park

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=20250116160314.23873-1-aha310510@gmail.com \
    --to=aha310510@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bh74.an@samsung.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    /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