Skip to contentSkip to conversation

staging: vt6655: Convert four macros to one function

PATCH New Philipp Hortmann 1 participant 6 messages Jul 29, 2022 Staging

lore
Share & tools
lore
#0 lore raw

v2 cover staging: vt6655: Convert four macros to one function

Convert four multiline macros to one function with parameter. Multiline macros are not liked by kernel community.

Tested with vt6655 on mini PCI Module Transferred this patch over wlan connection of vt6655

V1 -> V2: Combined patch "Rename dwData to reg_value in four ..." with
patch "Convert macro MACvReceive0 to function" Combined patch "Add parameter to function vt6655_m ..." with patch "Rename function MACvReceive0 and add parameter" Changed order of renaming function and conversion to function Improved to early line breaks in patch descriptions Removed function declaration of vt6655_mac_dma_ctl Changed variable declaration in vt6655_mac_dma_ctl Improved patch descriptions

Philipp Hortmann (5):
staging: vt6655: Convert macro MACvReceive0 to function
staging: vt6655: Rename function MACvReceive0 and add parameter
staging: vt6655: Replace MACvReceive1 with function vt6655_mac_dma_ctl
staging: vt6655: Replace MACvTransmit0 with function

    vt6655_mac_dma_ctl
  staging: vt6655: Replace MACvTransmitAC0 with function
    vt6655_mac_dma_ctl
 drivers/staging/vt6655/device_main.c | 23 +++++++++++-----
 drivers/staging/vt6655/mac.h         | 40 ----------------------------
 2 files changed, 17 insertions(+), 46 deletions(-)
Signature · 1 line
2.37.1
#1 lore raw

PATCH v2 1/5 staging: vt6655: Convert macro MACvReceive0 to function

Convert macro to static function. Multiline macros are not liked by kernel community. Rename variable dwData to reg_value to avoid CamelCase which is not accepted by checkpatch.pl. Change variable declaration to u32 as this improves readability.

---
V1 -> V2: Combind patch "Rename dwData to reg_value ..." with this one
Changed order of renaming function and conversion to function Removed function declaration
Changed variable declaration
Improved patch description

---
 drivers/staging/vt6655/device_main.c | 11 +++++++++++
 drivers/staging/vt6655/mac.h         | 10 ----------
 2 files changed, 11 insertions(+), 10 deletions(-)
drivers/staging/vt6655/device_main.c +11 -0
index 92583ee8bffd..39bfbb1ab742 100644
@@ -205,6 +205,17 @@ static void vt6655_mac_read_ether_addr(void __iomem *iobase, u8 *mac_addr)
 	iowrite8(0, iobase + MAC_REG_PAGE1SEL);
 }
 
+static void MACvReceive0(void __iomem *iobase)
+{
+	u32 reg_value;
+
+	reg_value = ioread32(iobase + MAC_REG_RXDMACTL0);
+	if (reg_value & DMACTL_RUN)
+		iowrite32(DMACTL_WAKE, iobase + MAC_REG_RXDMACTL0);
+	else
+		iowrite32(DMACTL_RUN, iobase + MAC_REG_RXDMACTL0);
+}
+
 /*
  * Initialisation of MAC & BBP registers
  */
drivers/staging/vt6655/mac.h +0 -10
index 0122c4603c66..d21313f3067e 100644
@@ -537,16 +537,6 @@
 
 /*---------------------  Export Macros ------------------------------*/
 
-#define MACvReceive0(iobase)						\
-do {									\
-	unsigned long dwData;						\
-	dwData = ioread32(iobase + MAC_REG_RXDMACTL0);			\
-	if (dwData & DMACTL_RUN)					\
-		iowrite32(DMACTL_WAKE, iobase + MAC_REG_RXDMACTL0);	\
-	else								\
-		iowrite32(DMACTL_RUN, iobase + MAC_REG_RXDMACTL0);	\
-} while (0)
-
 #define MACvReceive1(iobase)						\
 do {									\
 	unsigned long dwData;						\
Signature · 1 line
2.37.1
#2 lore raw

PATCH v2 2/5 staging: vt6655: Rename function MACvReceive0 and add parameter

In reply to Philipp Hortmann

Rename MACvReceive0 function to vt6655_mac_dma_ctl to avoid CamelCase which is not accepted by checkpatch.pl and to clean up namespace. Add one parameter to avoid multiple repetitions of the same function.

---
V1 -> V2: Combind patch "Add parameter to function vt..." with this one
Changed order of renaming function and conversion to function Improved patch description

---
 drivers/staging/vt6655/device_main.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/vt6655/device_main.c +6 -6
index 39bfbb1ab742..fb40d71d9e8e 100644
@@ -205,15 +205,15 @@ static void vt6655_mac_read_ether_addr(void __iomem *iobase, u8 *mac_addr)
 	iowrite8(0, iobase + MAC_REG_PAGE1SEL);
 }
 
-static void MACvReceive0(void __iomem *iobase)
+static void vt6655_mac_dma_ctl(void __iomem *iobase, u8 reg_index)
 {
 	u32 reg_value;
 
-	reg_value = ioread32(iobase + MAC_REG_RXDMACTL0);
+	reg_value = ioread32(iobase + reg_index);
 	if (reg_value & DMACTL_RUN)
-		iowrite32(DMACTL_WAKE, iobase + MAC_REG_RXDMACTL0);
+		iowrite32(DMACTL_WAKE, iobase + reg_index);
 	else
-		iowrite32(DMACTL_RUN, iobase + MAC_REG_RXDMACTL0);
+		iowrite32(DMACTL_RUN, iobase + reg_index);
 }
 
 /*
@@ -431,7 +431,7 @@ static void device_init_registers(struct vnt_private *priv)
 		vt6655_mac_reg_bits_on(priv->port_offset, MAC_REG_RCR, RCR_WPAERR);
 
 	/* Turn On Rx DMA */
-	MACvReceive0(priv->port_offset);
+	vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_RXDMACTL0);
 	MACvReceive1(priv->port_offset);
 
 	/* start the adapter */
@@ -1146,7 +1146,7 @@ static void vnt_interrupt_process(struct vnt_private *priv)
 
 		isr = ioread32(priv->port_offset + MAC_REG_ISR);
 
-		MACvReceive0(priv->port_offset);
+		vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_RXDMACTL0);
 		MACvReceive1(priv->port_offset);
 
 		if (max_count > priv->opts.int_works)
Signature · 1 line
2.37.1
#3 lore raw

PATCH v2 3/5 staging: vt6655: Replace MACvReceive1 with function vt6655_mac_dma_ctl

In reply to Philipp Hortmann

Convert macro MACvReceive1 to existing static function. This saves codelines and multiline macros are not liked by kernel community.

---
V1 -> V2: Improved description

---
 drivers/staging/vt6655/device_main.c |  4 ++--
 drivers/staging/vt6655/mac.h         | 10 ----------
 2 files changed, 2 insertions(+), 12 deletions(-)
drivers/staging/vt6655/device_main.c +2 -2
index fb40d71d9e8e..554531411dad 100644
@@ -432,7 +432,7 @@ static void device_init_registers(struct vnt_private *priv)
 
 	/* Turn On Rx DMA */
 	vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_RXDMACTL0);
-	MACvReceive1(priv->port_offset);
+	vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_RXDMACTL1);
 
 	/* start the adapter */
 	iowrite8(HOSTCR_MACEN | HOSTCR_RXON | HOSTCR_TXON, priv->port_offset + MAC_REG_HOSTCR);
@@ -1147,7 +1147,7 @@ static void vnt_interrupt_process(struct vnt_private *priv)
 		isr = ioread32(priv->port_offset + MAC_REG_ISR);
 
 		vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_RXDMACTL0);
-		MACvReceive1(priv->port_offset);
+		vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_RXDMACTL1);
 
 		if (max_count > priv->opts.int_works)
 			break;
drivers/staging/vt6655/mac.h +0 -10
index d21313f3067e..5a473ca393f2 100644
@@ -537,16 +537,6 @@
 
 /*---------------------  Export Macros ------------------------------*/
 
-#define MACvReceive1(iobase)						\
-do {									\
-	unsigned long dwData;						\
-	dwData = ioread32(iobase + MAC_REG_RXDMACTL1);			\
-	if (dwData & DMACTL_RUN)					\
-		iowrite32(DMACTL_WAKE, iobase + MAC_REG_RXDMACTL1);	\
-	else								\
-		iowrite32(DMACTL_RUN, iobase + MAC_REG_RXDMACTL1);	\
-} while (0)
-
 #define MACvTransmit0(iobase)						\
 do {									\
 	unsigned long dwData;						\
Signature · 1 line
2.37.1
#4 lore raw

PATCH v2 4/5 staging: vt6655: Replace MACvTransmit0 with function vt6655_mac_dma_ctl

In reply to Philipp Hortmann

Convert macro MACvTransmit0 to existing static function. This saves codelines and multiline macros are not liked by kernel community.

---
V1 -> V2: Improved description

---
 drivers/staging/vt6655/device_main.c |  2 +-
 drivers/staging/vt6655/mac.h         | 10 ----------
 2 files changed, 1 insertion(+), 11 deletions(-)
drivers/staging/vt6655/device_main.c +1 -1
index 554531411dad..c0a00063e4d1 100644
@@ -1231,7 +1231,7 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
 	if (head_td->td_info->flags & TD_FLAGS_NETIF_SKB)
 		MACvTransmitAC0(priv->port_offset);
 	else
-		MACvTransmit0(priv->port_offset);
+		vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_TXDMACTL0);
 
 	priv->iTDUsed[dma_idx]++;
 
drivers/staging/vt6655/mac.h +0 -10
index 5a473ca393f2..be33da59dd84 100644
@@ -537,16 +537,6 @@
 
 /*---------------------  Export Macros ------------------------------*/
 
-#define MACvTransmit0(iobase)						\
-do {									\
-	unsigned long dwData;						\
-	dwData = ioread32(iobase + MAC_REG_TXDMACTL0);			\
-	if (dwData & DMACTL_RUN)					\
-		iowrite32(DMACTL_WAKE, iobase + MAC_REG_TXDMACTL0);	\
-	else								\
-		iowrite32(DMACTL_RUN, iobase + MAC_REG_TXDMACTL0);	\
-} while (0)
-
 #define MACvTransmitAC0(iobase)					\
 do {									\
 	unsigned long dwData;						\
Signature · 1 line
2.37.1
#5 lore raw

PATCH v2 5/5 staging: vt6655: Replace MACvTransmitAC0 with function vt6655_mac_dma_ctl

In reply to Philipp Hortmann

Convert macro MACvTransmitAC0 to existing static function. This saves codelines and multiline macros are not liked by kernel community.

---
V1 -> V2: Improved description

---
 drivers/staging/vt6655/device_main.c |  2 +-
 drivers/staging/vt6655/mac.h         | 10 ----------
 2 files changed, 1 insertion(+), 11 deletions(-)
drivers/staging/vt6655/device_main.c +1 -1
index c0a00063e4d1..1fc8bdf8a311 100644
@@ -1229,7 +1229,7 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
 	wmb(); /* second memory barrier */
 
 	if (head_td->td_info->flags & TD_FLAGS_NETIF_SKB)
-		MACvTransmitAC0(priv->port_offset);
+		vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_AC0DMACTL);
 	else
 		vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_TXDMACTL0);
 
drivers/staging/vt6655/mac.h +0 -10
index be33da59dd84..467c599a3289 100644
@@ -537,16 +537,6 @@
 
 /*---------------------  Export Macros ------------------------------*/
 
-#define MACvTransmitAC0(iobase)					\
-do {									\
-	unsigned long dwData;						\
-	dwData = ioread32(iobase + MAC_REG_AC0DMACTL);			\
-	if (dwData & DMACTL_RUN)					\
-		iowrite32(DMACTL_WAKE, iobase + MAC_REG_AC0DMACTL);	\
-	else								\
-		iowrite32(DMACTL_RUN, iobase + MAC_REG_AC0DMACTL);	\
-} while (0)
-
 #define MACvSelectPage0(iobase)				\
 	iowrite8(0, iobase + MAC_REG_PAGE1SEL)
 
Signature · 1 line
2.37.1