summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/cadence/macb_main.c
diff options
context:
space:
mode:
authorThéo Lebrun <theo.lebrun@bootlin.com>2025-10-14 17:25:08 +0200
committerJakub Kicinski <kuba@kernel.org>2025-10-16 16:59:26 -0700
commit62e6c17463a7b361457193b4bf4e87de78534130 (patch)
tree08c97af246518e35f6fed4090f04bbb03c601166 /drivers/net/ethernet/cadence/macb_main.c
parent94a164598d833aaee98a81b2910ac7bfea09e60f (diff)
net: macb: simplify macb_adj_dma_desc_idx()
The function body uses a switch statement on bp->hw_dma_cap and handles its four possible values: 0, is_64b, is_ptp, is_64b && is_ptp. Instead, refactor by noticing that the return value is: desc_size * MULT with MULT = 3 if is_64b && is_ptp, 2 if is_64b || is_ptp, 1 otherwise. MULT can be expressed as: 1 + is_64b + is_ptp Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com> Link: https://patch.msgid.link/20251014-macb-cleanup-v1-7-31cd266e22cd@bootlin.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/ethernet/cadence/macb_main.c')
-rw-r--r--drivers/net/ethernet/cadence/macb_main.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 7f74e280a335..44a411662786 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -136,19 +136,13 @@ static unsigned int macb_dma_desc_get_size(struct macb *bp)
static unsigned int macb_adj_dma_desc_idx(struct macb *bp, unsigned int desc_idx)
{
#ifdef MACB_EXT_DESC
- switch (bp->hw_dma_cap) {
- case HW_DMA_CAP_64B:
- case HW_DMA_CAP_PTP:
- desc_idx <<= 1;
- break;
- case HW_DMA_CAP_64B_PTP:
- desc_idx *= 3;
- break;
- default:
- break;
- }
-#endif
+ bool is_ptp = bp->hw_dma_cap & HW_DMA_CAP_PTP;
+ bool is_64b = bp->hw_dma_cap & HW_DMA_CAP_64B;
+
+ return desc_idx * (1 + is_64b + is_ptp);
+#else
return desc_idx;
+#endif
}
#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT