Commit 240f1ae4 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by David S. Miller

net: ethernet: mtk-star-emac: use regmap bitops

Shrink the code visually by replacing regmap_update_bits() with
appropriate regmap bit operations where applicable.
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bfad9781
...@@ -413,8 +413,8 @@ static void mtk_star_dma_unmap_tx(struct mtk_star_priv *priv, ...@@ -413,8 +413,8 @@ static void mtk_star_dma_unmap_tx(struct mtk_star_priv *priv,
static void mtk_star_nic_disable_pd(struct mtk_star_priv *priv) static void mtk_star_nic_disable_pd(struct mtk_star_priv *priv)
{ {
regmap_update_bits(priv->regs, MTK_STAR_REG_MAC_CFG, regmap_clear_bits(priv->regs, MTK_STAR_REG_MAC_CFG,
MTK_STAR_BIT_MAC_CFG_NIC_PD, 0); MTK_STAR_BIT_MAC_CFG_NIC_PD);
} }
/* Unmask the three interrupts we care about, mask all others. */ /* Unmask the three interrupts we care about, mask all others. */
...@@ -434,40 +434,37 @@ static void mtk_star_intr_disable(struct mtk_star_priv *priv) ...@@ -434,40 +434,37 @@ static void mtk_star_intr_disable(struct mtk_star_priv *priv)
static void mtk_star_intr_enable_tx(struct mtk_star_priv *priv) static void mtk_star_intr_enable_tx(struct mtk_star_priv *priv)
{ {
regmap_update_bits(priv->regs, MTK_STAR_REG_INT_MASK, regmap_clear_bits(priv->regs, MTK_STAR_REG_INT_MASK,
MTK_STAR_BIT_INT_STS_TNTC, 0); MTK_STAR_BIT_INT_STS_TNTC);
} }
static void mtk_star_intr_enable_rx(struct mtk_star_priv *priv) static void mtk_star_intr_enable_rx(struct mtk_star_priv *priv)
{ {
regmap_update_bits(priv->regs, MTK_STAR_REG_INT_MASK, regmap_clear_bits(priv->regs, MTK_STAR_REG_INT_MASK,
MTK_STAR_BIT_INT_STS_FNRC, 0); MTK_STAR_BIT_INT_STS_FNRC);
} }
static void mtk_star_intr_enable_stats(struct mtk_star_priv *priv) static void mtk_star_intr_enable_stats(struct mtk_star_priv *priv)
{ {
regmap_update_bits(priv->regs, MTK_STAR_REG_INT_MASK, regmap_clear_bits(priv->regs, MTK_STAR_REG_INT_MASK,
MTK_STAR_REG_INT_STS_MIB_CNT_TH, 0); MTK_STAR_REG_INT_STS_MIB_CNT_TH);
} }
static void mtk_star_intr_disable_tx(struct mtk_star_priv *priv) static void mtk_star_intr_disable_tx(struct mtk_star_priv *priv)
{ {
regmap_update_bits(priv->regs, MTK_STAR_REG_INT_MASK, regmap_set_bits(priv->regs, MTK_STAR_REG_INT_MASK,
MTK_STAR_BIT_INT_STS_TNTC,
MTK_STAR_BIT_INT_STS_TNTC); MTK_STAR_BIT_INT_STS_TNTC);
} }
static void mtk_star_intr_disable_rx(struct mtk_star_priv *priv) static void mtk_star_intr_disable_rx(struct mtk_star_priv *priv)
{ {
regmap_update_bits(priv->regs, MTK_STAR_REG_INT_MASK, regmap_set_bits(priv->regs, MTK_STAR_REG_INT_MASK,
MTK_STAR_BIT_INT_STS_FNRC,
MTK_STAR_BIT_INT_STS_FNRC); MTK_STAR_BIT_INT_STS_FNRC);
} }
static void mtk_star_intr_disable_stats(struct mtk_star_priv *priv) static void mtk_star_intr_disable_stats(struct mtk_star_priv *priv)
{ {
regmap_update_bits(priv->regs, MTK_STAR_REG_INT_MASK, regmap_set_bits(priv->regs, MTK_STAR_REG_INT_MASK,
MTK_STAR_REG_INT_STS_MIB_CNT_TH,
MTK_STAR_REG_INT_STS_MIB_CNT_TH); MTK_STAR_REG_INT_STS_MIB_CNT_TH);
} }
...@@ -524,11 +521,9 @@ static void mtk_star_dma_init(struct mtk_star_priv *priv) ...@@ -524,11 +521,9 @@ static void mtk_star_dma_init(struct mtk_star_priv *priv)
static void mtk_star_dma_start(struct mtk_star_priv *priv) static void mtk_star_dma_start(struct mtk_star_priv *priv)
{ {
regmap_update_bits(priv->regs, MTK_STAR_REG_TX_DMA_CTRL, regmap_set_bits(priv->regs, MTK_STAR_REG_TX_DMA_CTRL,
MTK_STAR_BIT_TX_DMA_CTRL_START,
MTK_STAR_BIT_TX_DMA_CTRL_START); MTK_STAR_BIT_TX_DMA_CTRL_START);
regmap_update_bits(priv->regs, MTK_STAR_REG_RX_DMA_CTRL, regmap_set_bits(priv->regs, MTK_STAR_REG_RX_DMA_CTRL,
MTK_STAR_BIT_RX_DMA_CTRL_START,
MTK_STAR_BIT_RX_DMA_CTRL_START); MTK_STAR_BIT_RX_DMA_CTRL_START);
} }
...@@ -553,15 +548,13 @@ static void mtk_star_dma_disable(struct mtk_star_priv *priv) ...@@ -553,15 +548,13 @@ static void mtk_star_dma_disable(struct mtk_star_priv *priv)
static void mtk_star_dma_resume_rx(struct mtk_star_priv *priv) static void mtk_star_dma_resume_rx(struct mtk_star_priv *priv)
{ {
regmap_update_bits(priv->regs, MTK_STAR_REG_RX_DMA_CTRL, regmap_set_bits(priv->regs, MTK_STAR_REG_RX_DMA_CTRL,
MTK_STAR_BIT_RX_DMA_CTRL_RESUME,
MTK_STAR_BIT_RX_DMA_CTRL_RESUME); MTK_STAR_BIT_RX_DMA_CTRL_RESUME);
} }
static void mtk_star_dma_resume_tx(struct mtk_star_priv *priv) static void mtk_star_dma_resume_tx(struct mtk_star_priv *priv)
{ {
regmap_update_bits(priv->regs, MTK_STAR_REG_TX_DMA_CTRL, regmap_set_bits(priv->regs, MTK_STAR_REG_TX_DMA_CTRL,
MTK_STAR_BIT_TX_DMA_CTRL_RESUME,
MTK_STAR_BIT_TX_DMA_CTRL_RESUME); MTK_STAR_BIT_TX_DMA_CTRL_RESUME);
} }
...@@ -842,8 +835,8 @@ static int mtk_star_hash_wait_ok(struct mtk_star_priv *priv) ...@@ -842,8 +835,8 @@ static int mtk_star_hash_wait_ok(struct mtk_star_priv *priv)
return ret; return ret;
/* Check the BIST_OK bit. */ /* Check the BIST_OK bit. */
regmap_read(priv->regs, MTK_STAR_REG_HASH_CTRL, &val); if (!regmap_test_bits(priv->regs, MTK_STAR_REG_HASH_CTRL,
if (!(val & MTK_STAR_BIT_HASH_CTRL_BIST_OK)) MTK_STAR_BIT_HASH_CTRL_BIST_OK))
return -EIO; return -EIO;
return 0; return 0;
...@@ -877,11 +870,9 @@ static int mtk_star_reset_hash_table(struct mtk_star_priv *priv) ...@@ -877,11 +870,9 @@ static int mtk_star_reset_hash_table(struct mtk_star_priv *priv)
if (ret) if (ret)
return ret; return ret;
regmap_update_bits(priv->regs, MTK_STAR_REG_HASH_CTRL, regmap_set_bits(priv->regs, MTK_STAR_REG_HASH_CTRL,
MTK_STAR_BIT_HASH_CTRL_BIST_EN,
MTK_STAR_BIT_HASH_CTRL_BIST_EN); MTK_STAR_BIT_HASH_CTRL_BIST_EN);
regmap_update_bits(priv->regs, MTK_STAR_REG_TEST1, regmap_set_bits(priv->regs, MTK_STAR_REG_TEST1,
MTK_STAR_BIT_TEST1_RST_HASH_MBIST,
MTK_STAR_BIT_TEST1_RST_HASH_MBIST); MTK_STAR_BIT_TEST1_RST_HASH_MBIST);
return mtk_star_hash_wait_ok(priv); return mtk_star_hash_wait_ok(priv);
...@@ -1013,13 +1004,13 @@ static int mtk_star_enable(struct net_device *ndev) ...@@ -1013,13 +1004,13 @@ static int mtk_star_enable(struct net_device *ndev)
return ret; return ret;
/* Setup the hashing algorithm */ /* Setup the hashing algorithm */
regmap_update_bits(priv->regs, MTK_STAR_REG_ARL_CFG, regmap_clear_bits(priv->regs, MTK_STAR_REG_ARL_CFG,
MTK_STAR_BIT_ARL_CFG_HASH_ALG | MTK_STAR_BIT_ARL_CFG_HASH_ALG |
MTK_STAR_BIT_ARL_CFG_MISC_MODE, 0); MTK_STAR_BIT_ARL_CFG_MISC_MODE);
/* Don't strip VLAN tags */ /* Don't strip VLAN tags */
regmap_update_bits(priv->regs, MTK_STAR_REG_MAC_CFG, regmap_clear_bits(priv->regs, MTK_STAR_REG_MAC_CFG,
MTK_STAR_BIT_MAC_CFG_VLAN_STRIP, 0); MTK_STAR_BIT_MAC_CFG_VLAN_STRIP);
/* Setup DMA */ /* Setup DMA */
mtk_star_dma_init(priv); mtk_star_dma_init(priv);
...@@ -1201,8 +1192,7 @@ static void mtk_star_set_rx_mode(struct net_device *ndev) ...@@ -1201,8 +1192,7 @@ static void mtk_star_set_rx_mode(struct net_device *ndev)
int ret; int ret;
if (ndev->flags & IFF_PROMISC) { if (ndev->flags & IFF_PROMISC) {
regmap_update_bits(priv->regs, MTK_STAR_REG_ARL_CFG, regmap_set_bits(priv->regs, MTK_STAR_REG_ARL_CFG,
MTK_STAR_BIT_ARL_CFG_MISC_MODE,
MTK_STAR_BIT_ARL_CFG_MISC_MODE); MTK_STAR_BIT_ARL_CFG_MISC_MODE);
} else if (netdev_mc_count(ndev) > MTK_STAR_HASHTABLE_MC_LIMIT || } else if (netdev_mc_count(ndev) > MTK_STAR_HASHTABLE_MC_LIMIT ||
ndev->flags & IFF_ALLMULTI) { ndev->flags & IFF_ALLMULTI) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment