Skip to content

Commit e05fd62

Browse files
LorenzoBianconikuba-moo
authored andcommitted
net: ethernet: mtk_eth_soc: rely on MTK_MAX_DEVS and remove MTK_MAC_COUNT
Get rid of MTK_MAC_COUNT since it is a duplicated of MTK_MAX_DEVS. Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Daniel Golle <[email protected]> Link: https://lore.kernel.org/r/1856f4266f2fc80677807b1bad867659e7b00c65.1690246066.git.daniel@makrotopia.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6ca2655 commit e05fd62

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ static void mtk_stats_update(struct mtk_eth *eth)
896896
{
897897
int i;
898898

899-
for (i = 0; i < MTK_MAC_COUNT; i++) {
899+
for (i = 0; i < MTK_MAX_DEVS; i++) {
900900
if (!eth->mac[i] || !eth->mac[i]->hw_stats)
901901
continue;
902902
if (spin_trylock(&eth->mac[i]->hw_stats->stats_lock)) {
@@ -1401,7 +1401,7 @@ static int mtk_queue_stopped(struct mtk_eth *eth)
14011401
{
14021402
int i;
14031403

1404-
for (i = 0; i < MTK_MAC_COUNT; i++) {
1404+
for (i = 0; i < MTK_MAX_DEVS; i++) {
14051405
if (!eth->netdev[i])
14061406
continue;
14071407
if (netif_queue_stopped(eth->netdev[i]))
@@ -1415,7 +1415,7 @@ static void mtk_wake_queue(struct mtk_eth *eth)
14151415
{
14161416
int i;
14171417

1418-
for (i = 0; i < MTK_MAC_COUNT; i++) {
1418+
for (i = 0; i < MTK_MAX_DEVS; i++) {
14191419
if (!eth->netdev[i])
14201420
continue;
14211421
netif_tx_wake_all_queues(eth->netdev[i]);
@@ -1874,7 +1874,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
18741874
!(trxd.rxd4 & RX_DMA_SPECIAL_TAG))
18751875
mac = RX_DMA_GET_SPORT(trxd.rxd4) - 1;
18761876

1877-
if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
1877+
if (unlikely(mac < 0 || mac >= MTK_MAX_DEVS ||
18781878
!eth->netdev[mac]))
18791879
goto release_desc;
18801880

@@ -2911,7 +2911,7 @@ static void mtk_dma_free(struct mtk_eth *eth)
29112911
const struct mtk_soc_data *soc = eth->soc;
29122912
int i;
29132913

2914-
for (i = 0; i < MTK_MAC_COUNT; i++)
2914+
for (i = 0; i < MTK_MAX_DEVS; i++)
29152915
if (eth->netdev[i])
29162916
netdev_reset_queue(eth->netdev[i]);
29172917
if (eth->scratch_ring) {
@@ -3065,8 +3065,13 @@ static void mtk_gdm_config(struct mtk_eth *eth, u32 config)
30653065
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
30663066
return;
30673067

3068-
for (i = 0; i < MTK_MAC_COUNT; i++) {
3069-
u32 val = mtk_r32(eth, MTK_GDMA_FWD_CFG(i));
3068+
for (i = 0; i < MTK_MAX_DEVS; i++) {
3069+
u32 val;
3070+
3071+
if (!eth->netdev[i])
3072+
continue;
3073+
3074+
val = mtk_r32(eth, MTK_GDMA_FWD_CFG(i));
30703075

30713076
/* default setup the forward port to send frame to PDMA */
30723077
val &= ~0xffff;
@@ -3076,7 +3081,7 @@ static void mtk_gdm_config(struct mtk_eth *eth, u32 config)
30763081

30773082
val |= config;
30783083

3079-
if (eth->netdev[i] && netdev_uses_dsa(eth->netdev[i]))
3084+
if (netdev_uses_dsa(eth->netdev[i]))
30803085
val |= MTK_GDMA_SPECIAL_TAG;
30813086

30823087
mtk_w32(eth, val, MTK_GDMA_FWD_CFG(i));
@@ -3678,15 +3683,15 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset)
36783683
* up with the more appropriate value when mtk_mac_config call is being
36793684
* invoked.
36803685
*/
3681-
for (i = 0; i < MTK_MAC_COUNT; i++) {
3686+
for (i = 0; i < MTK_MAX_DEVS; i++) {
36823687
struct net_device *dev = eth->netdev[i];
36833688

3684-
mtk_w32(eth, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(i));
3685-
if (dev) {
3686-
struct mtk_mac *mac = netdev_priv(dev);
3689+
if (!dev)
3690+
continue;
36873691

3688-
mtk_set_mcr_max_rx(mac, dev->mtu + MTK_RX_ETH_HLEN);
3689-
}
3692+
mtk_w32(eth, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(i));
3693+
mtk_set_mcr_max_rx(netdev_priv(dev),
3694+
dev->mtu + MTK_RX_ETH_HLEN);
36903695
}
36913696

36923697
/* Indicates CDM to parse the MTK special tag from CPU
@@ -3866,7 +3871,7 @@ static void mtk_pending_work(struct work_struct *work)
38663871
mtk_prepare_for_reset(eth);
38673872

38683873
/* stop all devices to make sure that dma is properly shut down */
3869-
for (i = 0; i < MTK_MAC_COUNT; i++) {
3874+
for (i = 0; i < MTK_MAX_DEVS; i++) {
38703875
if (!eth->netdev[i] || !netif_running(eth->netdev[i]))
38713876
continue;
38723877

@@ -3882,8 +3887,8 @@ static void mtk_pending_work(struct work_struct *work)
38823887
mtk_hw_init(eth, true);
38833888

38843889
/* restart DMA and enable IRQs */
3885-
for (i = 0; i < MTK_MAC_COUNT; i++) {
3886-
if (!test_bit(i, &restart))
3890+
for (i = 0; i < MTK_MAX_DEVS; i++) {
3891+
if (!eth->netdev[i] || !test_bit(i, &restart))
38873892
continue;
38883893

38893894
if (mtk_open(eth->netdev[i])) {
@@ -3910,7 +3915,7 @@ static int mtk_free_dev(struct mtk_eth *eth)
39103915
{
39113916
int i;
39123917

3913-
for (i = 0; i < MTK_MAC_COUNT; i++) {
3918+
for (i = 0; i < MTK_MAX_DEVS; i++) {
39143919
if (!eth->netdev[i])
39153920
continue;
39163921
free_netdev(eth->netdev[i]);
@@ -3929,7 +3934,7 @@ static int mtk_unreg_dev(struct mtk_eth *eth)
39293934
{
39303935
int i;
39313936

3932-
for (i = 0; i < MTK_MAC_COUNT; i++) {
3937+
for (i = 0; i < MTK_MAX_DEVS; i++) {
39333938
struct mtk_mac *mac;
39343939
if (!eth->netdev[i])
39353940
continue;
@@ -4231,7 +4236,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
42314236
}
42324237

42334238
id = be32_to_cpup(_id);
4234-
if (id >= MTK_MAC_COUNT) {
4239+
if (id >= MTK_MAX_DEVS) {
42354240
dev_err(eth->dev, "%d is not a valid mac id\n", id);
42364241
return -EINVAL;
42374242
}
@@ -4391,7 +4396,7 @@ void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev)
43914396

43924397
rtnl_lock();
43934398

4394-
for (i = 0; i < MTK_MAC_COUNT; i++) {
4399+
for (i = 0; i < MTK_MAX_DEVS; i++) {
43954400
dev = eth->netdev[i];
43964401

43974402
if (!dev || !(dev->flags & IFF_UP))
@@ -4697,7 +4702,7 @@ static int mtk_remove(struct platform_device *pdev)
46974702
int i;
46984703

46994704
/* stop all devices to make sure that dma is properly shut down */
4700-
for (i = 0; i < MTK_MAC_COUNT; i++) {
4705+
for (i = 0; i < MTK_MAX_DEVS; i++) {
47014706
if (!eth->netdev[i])
47024707
continue;
47034708
mtk_stop(eth->netdev[i]);

drivers/net/ethernet/mediatek/mtk_eth_soc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#define MTK_TX_DMA_BUF_LEN_V2 0xffff
3434
#define MTK_QDMA_RING_SIZE 2048
3535
#define MTK_DMA_SIZE 512
36-
#define MTK_MAC_COUNT 2
3736
#define MTK_RX_ETH_HLEN (ETH_HLEN + ETH_FCS_LEN)
3837
#define MTK_RX_HLEN (NET_SKB_PAD + MTK_RX_ETH_HLEN + NET_IP_ALIGN)
3938
#define MTK_DMA_DUMMY_DESC 0xffffffff

0 commit comments

Comments
 (0)