@@ -1078,8 +1078,7 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv)
return 0;
err_alloc_cls:
- enetc_clear_cbdr(&si->cbd_ring);
- enetc_free_cbdr(&si->cbd_ring);
+ enetc_teardown_cbdr(&si->cbd_ring);
return err;
}
@@ -1088,8 +1087,7 @@ void enetc_free_si_resources(struct enetc_ndev_priv *priv)
{
struct enetc_si *si = priv->si;
- enetc_clear_cbdr(&si->cbd_ring);
- enetc_free_cbdr(&si->cbd_ring);
+ enetc_teardown_cbdr(&si->cbd_ring);
kfree(priv->cls_rules);
}
@@ -314,8 +314,7 @@ void enetc_set_ethtool_ops(struct net_device *ndev);
/* control buffer descriptor ring (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_clear_cbdr(struct enetc_cbdr *cbdr);
+void enetc_teardown_cbdr(struct enetc_cbdr *cbdr);
int enetc_set_mac_flt_entry(struct enetc_si *si, int index,
char *mac_addr, int si_map);
int enetc_clear_mac_flt_entry(struct enetc_si *si, int index);
@@ -44,22 +44,19 @@ int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw,
return 0;
}
-void enetc_free_cbdr(struct enetc_cbdr *cbdr)
+void enetc_teardown_cbdr(struct enetc_cbdr *cbdr)
{
int size = cbdr->bd_count * sizeof(struct enetc_cbd);
+ /* disable ring */
+ enetc_wr_reg(cbdr->mr, 0);
+
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_cbdr *cbdr)
-{
- /* disable ring */
- enetc_wr_reg(cbdr->mr, 0);
-}
-
static void enetc_clean_cbdr(struct enetc_cbdr *ring)
{
struct enetc_cbd *dest_cbd;
@@ -1095,8 +1095,7 @@ static void enetc_init_unused_port(struct enetc_si *si)
enetc_init_port_rfs_memory(si);
enetc_init_port_rss_memory(si);
- enetc_clear_cbdr(&si->cbd_ring);
- enetc_free_cbdr(&si->cbd_ring);
+ enetc_teardown_cbdr(&si->cbd_ring);
}
static int enetc_pf_probe(struct pci_dev *pdev,
All call sites call enetc_clear_cbdr and enetc_free_cbdr one after another, so let's combine the two functions into a single method named enetc_teardown_cbdr which does both, and in the same order. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> --- drivers/net/ethernet/freescale/enetc/enetc.c | 6 ++---- drivers/net/ethernet/freescale/enetc/enetc.h | 3 +-- drivers/net/ethernet/freescale/enetc/enetc_cbdr.c | 11 ++++------- drivers/net/ethernet/freescale/enetc/enetc_pf.c | 3 +-- 4 files changed, 8 insertions(+), 15 deletions(-)