Commit 0bfde022 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: enetc: squash clear_cbdr and free_cbdr into teardown_cbdr

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: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 27f9025d
...@@ -1074,8 +1074,7 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv) ...@@ -1074,8 +1074,7 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv)
return 0; return 0;
err_alloc_cls: err_alloc_cls:
enetc_clear_cbdr(&si->cbd_ring); enetc_teardown_cbdr(&si->cbd_ring);
enetc_free_cbdr(&si->cbd_ring);
return err; return err;
} }
...@@ -1084,8 +1083,7 @@ void enetc_free_si_resources(struct enetc_ndev_priv *priv) ...@@ -1084,8 +1083,7 @@ void enetc_free_si_resources(struct enetc_ndev_priv *priv)
{ {
struct enetc_si *si = priv->si; struct enetc_si *si = priv->si;
enetc_clear_cbdr(&si->cbd_ring); enetc_teardown_cbdr(&si->cbd_ring);
enetc_free_cbdr(&si->cbd_ring);
kfree(priv->cls_rules); kfree(priv->cls_rules);
} }
......
...@@ -314,8 +314,7 @@ void enetc_set_ethtool_ops(struct net_device *ndev); ...@@ -314,8 +314,7 @@ void enetc_set_ethtool_ops(struct net_device *ndev);
/* control buffer descriptor ring (CBDR) */ /* control buffer descriptor ring (CBDR) */
int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw,
struct enetc_cbdr *cbdr); struct enetc_cbdr *cbdr);
void enetc_free_cbdr(struct enetc_cbdr *cbdr); void enetc_teardown_cbdr(struct enetc_cbdr *cbdr);
void enetc_clear_cbdr(struct enetc_cbdr *cbdr);
int enetc_set_mac_flt_entry(struct enetc_si *si, int index, int enetc_set_mac_flt_entry(struct enetc_si *si, int index,
char *mac_addr, int si_map); char *mac_addr, int si_map);
int enetc_clear_mac_flt_entry(struct enetc_si *si, int index); 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, ...@@ -44,22 +44,19 @@ int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw,
return 0; 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); 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, dma_free_coherent(cbdr->dma_dev, size, cbdr->bd_base,
cbdr->bd_dma_base); cbdr->bd_dma_base);
cbdr->bd_base = NULL; cbdr->bd_base = NULL;
cbdr->dma_dev = 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) static void enetc_clean_cbdr(struct enetc_cbdr *ring)
{ {
struct enetc_cbd *dest_cbd; struct enetc_cbd *dest_cbd;
......
...@@ -1095,8 +1095,7 @@ static void enetc_init_unused_port(struct enetc_si *si) ...@@ -1095,8 +1095,7 @@ static void enetc_init_unused_port(struct enetc_si *si)
enetc_init_port_rfs_memory(si); enetc_init_port_rfs_memory(si);
enetc_init_port_rss_memory(si); enetc_init_port_rss_memory(si);
enetc_clear_cbdr(&si->cbd_ring); enetc_teardown_cbdr(&si->cbd_ring);
enetc_free_cbdr(&si->cbd_ring);
} }
static int enetc_pf_probe(struct pci_dev *pdev, static int enetc_pf_probe(struct pci_dev *pdev,
......
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