diff mbox series

[net-next,03/12] net: enetc: squash enetc_alloc_cbdr and enetc_setup_cbdr

Message ID 20210310120351.542292-4-vladimir.oltean@nxp.com (mailing list archive)
State Accepted
Commit 24be14e3260ad8f5b926da8ad0bc0067435e7340
Delegated to: Netdev Maintainers
Headers show
Series Refactoring/cleanup for NXP ENETC | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: From:/Signed-off-by: email address mismatch: 'From: Vladimir Oltean <olteanv@gmail.com>' != 'Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>'
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/header_inline success Link

Commit Message

Vladimir Oltean March 10, 2021, 12:03 p.m. UTC
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 <vladimir.oltean@nxp.com>
---
 drivers/net/ethernet/freescale/enetc/enetc.c  |  4 +--
 drivers/net/ethernet/freescale/enetc/enetc.h  |  4 +--
 .../net/ethernet/freescale/enetc/enetc_cbdr.c | 30 +++++++++----------
 .../net/ethernet/freescale/enetc/enetc_pf.c   |  4 +--
 4 files changed, 18 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index ceecee42f0f1..57073c3c679e 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -1064,12 +1064,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 b343d1002bb7..1f2e9bec1b30 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 7e84eb665ecd..4de31b283319 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 a7195ec736f3..31d229e0912a 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);