mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
net: macb: simplify macb_dma_desc_get_size()
macb_dma_desc_get_size() does a switch on bp->hw_dma_cap and covers all four cases: 0, 64B, PTP, 64B+PTP. It also covers the #ifndef MACB_EXT_DESC separately, making it four codepaths. Instead, notice the descriptor size grows with enabled features and use plain if-statements on 64B and PTP flags. Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com> Link: https://patch.msgid.link/20251014-macb-cleanup-v1-6-31cd266e22cd@bootlin.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
d7a4a20abe
commit
94a164598d
@@ -121,29 +121,16 @@ struct sifive_fu540_macb_mgmt {
|
||||
*/
|
||||
static unsigned int macb_dma_desc_get_size(struct macb *bp)
|
||||
{
|
||||
#ifdef MACB_EXT_DESC
|
||||
unsigned int desc_size;
|
||||
unsigned int desc_size = sizeof(struct macb_dma_desc);
|
||||
|
||||
switch (bp->hw_dma_cap) {
|
||||
case HW_DMA_CAP_64B:
|
||||
desc_size = sizeof(struct macb_dma_desc)
|
||||
+ sizeof(struct macb_dma_desc_64);
|
||||
break;
|
||||
case HW_DMA_CAP_PTP:
|
||||
desc_size = sizeof(struct macb_dma_desc)
|
||||
+ sizeof(struct macb_dma_desc_ptp);
|
||||
break;
|
||||
case HW_DMA_CAP_64B_PTP:
|
||||
desc_size = sizeof(struct macb_dma_desc)
|
||||
+ sizeof(struct macb_dma_desc_64)
|
||||
+ sizeof(struct macb_dma_desc_ptp);
|
||||
break;
|
||||
default:
|
||||
desc_size = sizeof(struct macb_dma_desc);
|
||||
}
|
||||
return desc_size;
|
||||
#ifdef MACB_EXT_DESC
|
||||
if (bp->hw_dma_cap & HW_DMA_CAP_64B)
|
||||
desc_size += sizeof(struct macb_dma_desc_64);
|
||||
if (bp->hw_dma_cap & HW_DMA_CAP_PTP)
|
||||
desc_size += sizeof(struct macb_dma_desc_ptp);
|
||||
#endif
|
||||
return sizeof(struct macb_dma_desc);
|
||||
|
||||
return desc_size;
|
||||
}
|
||||
|
||||
static unsigned int macb_adj_dma_desc_idx(struct macb *bp, unsigned int desc_idx)
|
||||
|
||||
Reference in New Issue
Block a user