Skip to content

Commit 7173eca

Browse files
LorenzoBianconidavem330
authored andcommitted
net: ethernet: mtk_eth_soc: convert ring dma pointer to void
Simplify the code converting {tx,rx} ring dma pointer to void Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 160d3a9 commit 7173eca

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -917,32 +917,28 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
917917
return 0;
918918
}
919919

920-
static inline void *mtk_qdma_phys_to_virt(struct mtk_tx_ring *ring, u32 desc)
920+
static void *mtk_qdma_phys_to_virt(struct mtk_tx_ring *ring, u32 desc)
921921
{
922-
void *ret = ring->dma;
923-
924-
return ret + (desc - ring->phys);
922+
return ring->dma + (desc - ring->phys);
925923
}
926924

927925
static struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring,
928-
struct mtk_tx_dma *txd,
929-
u32 txd_size)
926+
void *txd, u32 txd_size)
930927
{
931-
int idx = ((void *)txd - (void *)ring->dma) / txd_size;
928+
int idx = (txd - ring->dma) / txd_size;
932929

933930
return &ring->buf[idx];
934931
}
935932

936933
static struct mtk_tx_dma *qdma_to_pdma(struct mtk_tx_ring *ring,
937934
struct mtk_tx_dma *dma)
938935
{
939-
return ring->dma_pdma - ring->dma + dma;
936+
return ring->dma_pdma - (struct mtk_tx_dma *)ring->dma + dma;
940937
}
941938

942-
static int txd_to_idx(struct mtk_tx_ring *ring, struct mtk_tx_dma *dma,
943-
u32 txd_size)
939+
static int txd_to_idx(struct mtk_tx_ring *ring, void *dma, u32 txd_size)
944940
{
945-
return ((void *)dma - (void *)ring->dma) / txd_size;
941+
return (dma - ring->dma) / txd_size;
946942
}
947943

948944
static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf,
@@ -1359,7 +1355,7 @@ static struct mtk_rx_ring *mtk_get_rx_ring(struct mtk_eth *eth)
13591355

13601356
ring = &eth->rx_ring[i];
13611357
idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size);
1362-
rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size;
1358+
rxd = ring->dma + idx * eth->soc->txrx.rxd_size;
13631359
if (rxd->rxd2 & RX_DMA_DONE) {
13641360
ring->calc_idx_update = true;
13651361
return ring;
@@ -1411,7 +1407,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
14111407
goto rx_done;
14121408

14131409
idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size);
1414-
rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size;
1410+
rxd = ring->dma + idx * eth->soc->txrx.rxd_size;
14151411
data = ring->data[idx];
14161412

14171413
if (!mtk_rx_get_desc(eth, &trxd, rxd))
@@ -1615,7 +1611,7 @@ static int mtk_poll_tx_pdma(struct mtk_eth *eth, int budget,
16151611

16161612
mtk_tx_unmap(eth, tx_buf, true);
16171613

1618-
desc = (void *)ring->dma + cpu * eth->soc->txrx.txd_size;
1614+
desc = ring->dma + cpu * eth->soc->txrx.txd_size;
16191615
ring->last_free = desc;
16201616
atomic_inc(&ring->free_count);
16211617

@@ -1760,7 +1756,7 @@ static int mtk_tx_alloc(struct mtk_eth *eth)
17601756
int next = (i + 1) % MTK_DMA_SIZE;
17611757
u32 next_ptr = ring->phys + next * sz;
17621758

1763-
txd = (void *)ring->dma + i * sz;
1759+
txd = ring->dma + i * sz;
17641760
txd->txd2 = next_ptr;
17651761
txd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU;
17661762
txd->txd4 = 0;
@@ -1790,7 +1786,7 @@ static int mtk_tx_alloc(struct mtk_eth *eth)
17901786

17911787
ring->dma_size = MTK_DMA_SIZE;
17921788
atomic_set(&ring->free_count, MTK_DMA_SIZE - 2);
1793-
ring->next_free = &ring->dma[0];
1789+
ring->next_free = ring->dma;
17941790
ring->last_free = (void *)txd;
17951791
ring->last_free_ptr = (u32)(ring->phys + ((MTK_DMA_SIZE - 1) * sz));
17961792
ring->thresh = MAX_SKB_FRAGS;
@@ -1902,7 +1898,7 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag)
19021898
if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr)))
19031899
return -ENOMEM;
19041900

1905-
rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size;
1901+
rxd = ring->dma + i * eth->soc->txrx.rxd_size;
19061902
rxd->rxd1 = (unsigned int)dma_addr;
19071903

19081904
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
@@ -1964,7 +1960,7 @@ static void mtk_rx_clean(struct mtk_eth *eth, struct mtk_rx_ring *ring)
19641960
if (!ring->data[i])
19651961
continue;
19661962

1967-
rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size;
1963+
rxd = ring->dma + i * eth->soc->txrx.rxd_size;
19681964
if (!rxd->rxd1)
19691965
continue;
19701966

drivers/net/ethernet/mediatek/mtk_eth_soc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ struct mtk_tx_buf {
692692
* are present
693693
*/
694694
struct mtk_tx_ring {
695-
struct mtk_tx_dma *dma;
695+
void *dma;
696696
struct mtk_tx_buf *buf;
697697
dma_addr_t phys;
698698
struct mtk_tx_dma *next_free;
@@ -722,7 +722,7 @@ enum mtk_rx_flags {
722722
* @calc_idx: The current head of ring
723723
*/
724724
struct mtk_rx_ring {
725-
struct mtk_rx_dma *dma;
725+
void *dma;
726726
u8 **data;
727727
dma_addr_t phys;
728728
u16 frag_size;

0 commit comments

Comments
 (0)