From: Vladimir Oltean Date: Wed, 10 Mar 2021 12:03:42 +0000 (+0200) Subject: net: enetc: squash enetc_alloc_cbdr and enetc_setup_cbdr X-Git-Tag: v5.15~1236^2~591^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24be14e3260ad8f5b926da8ad0bc0067435e7340;p=platform%2Fkernel%2Flinux-starfive.git net: enetc: squash enetc_alloc_cbdr and enetc_setup_cbdr enetc_alloc_cbdr and enetc_setup_cbdr are always called one after another, so we can simplify the callers and make enetc_setup_cbdr do everything that's needed. Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 2d60af5..718ce01 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1060,12 +1060,10 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv) struct enetc_si *si = priv->si; int err; - err = enetc_alloc_cbdr(priv->dev, &si->cbd_ring); + err = enetc_setup_cbdr(priv->dev, &si->hw, &si->cbd_ring); if (err) return err; - enetc_setup_cbdr(&si->hw, &si->cbd_ring); - priv->cls_rules = kcalloc(si->num_fs_entries, sizeof(*priv->cls_rules), GFP_KERNEL); if (!priv->cls_rules) { diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index b343d10..1f2e9be 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -311,9 +311,9 @@ int enetc_setup_tc(struct net_device *ndev, enum tc_setup_type type, void enetc_set_ethtool_ops(struct net_device *ndev); /* control buffer descriptor ring (CBDR) */ -int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr); +int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, + struct enetc_cbdr *cbdr); void enetc_free_cbdr(struct enetc_cbdr *cbdr); -void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr); void enetc_clear_cbdr(struct enetc_hw *hw); int enetc_set_mac_flt_entry(struct enetc_si *si, int index, char *mac_addr, int si_map); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c index 7e84eb6..4de31b2 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c @@ -3,7 +3,8 @@ #include "enetc.h" -int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr) +int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, + struct enetc_cbdr *cbdr) { int size = cbdr->bd_count * sizeof(struct enetc_cbd); @@ -23,21 +24,6 @@ int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr) cbdr->next_to_use = 0; cbdr->dma_dev = dev; - return 0; -} - -void enetc_free_cbdr(struct enetc_cbdr *cbdr) -{ - int size = cbdr->bd_count * sizeof(struct enetc_cbd); - - dma_free_coherent(cbdr->dma_dev, size, cbdr->bd_base, - cbdr->bd_dma_base); - cbdr->bd_base = NULL; - cbdr->dma_dev = NULL; -} - -void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr) -{ /* set CBDR cache attributes */ enetc_wr(hw, ENETC_SICAR2, ENETC_SICAR_RD_COHERENT | ENETC_SICAR_WR_COHERENT); @@ -54,6 +40,18 @@ void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr) cbdr->pir = hw->reg + ENETC_SICBDRPIR; cbdr->cir = hw->reg + ENETC_SICBDRCIR; + + return 0; +} + +void enetc_free_cbdr(struct enetc_cbdr *cbdr) +{ + int size = cbdr->bd_count * sizeof(struct enetc_cbd); + + dma_free_coherent(cbdr->dma_dev, size, cbdr->bd_base, + cbdr->bd_dma_base); + cbdr->bd_base = NULL; + cbdr->dma_dev = NULL; } void enetc_clear_cbdr(struct enetc_hw *hw) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index a7195ec..31d229e 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -1088,12 +1088,10 @@ static void enetc_init_unused_port(struct enetc_si *si) int err; si->cbd_ring.bd_count = ENETC_CBDR_DEFAULT_SIZE; - err = enetc_alloc_cbdr(dev, &si->cbd_ring); + err = enetc_setup_cbdr(dev, hw, &si->cbd_ring); if (err) return; - enetc_setup_cbdr(hw, &si->cbd_ring); - enetc_init_port_rfs_memory(si); enetc_init_port_rss_memory(si);