Skip to contentSkip to conversation

staging: vt6655: Convert two macros to static functions

PATCH In review Philipp Hortmann 2 participants 8 messages Jul 4, 2022 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: vt6655: Convert two macros to static functions

Convert two multiline macros used only once to static functions. checkpatch.pl does not accept multiline macros.

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

Philipp Hortmann (6):
staging: vt6655: Rename pbyEtherAddr to mac_addr
staging: vt6655: Rename MACvWriteBSSIDAddress
staging: vt6655: Rename MACvReadEtherAddress
staging: vt6655: Move two macros to file where those are used
staging: vt6655: Convert macro vt6655_mac_write_bssid_addr to function
staging: vt6655: Convert macro vt6655_mac_read_ether_addr to function

 drivers/staging/vt6655/device_main.c | 31 ++++++++++++++++++++++++++--
 drivers/staging/vt6655/mac.h         | 24 ---------------------
 2 files changed, 29 insertions(+), 26 deletions(-)
Signature · 1 line
2.36.1
#1 lore raw

PATCH 1/6 staging: vt6655: Rename pbyEtherAddr to mac_addr

Fix name of a variable in two macros that use CamelCase which is not accepted by checkpatch.pl

---
 drivers/staging/vt6655/mac.h | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/staging/vt6655/mac.h +14 -14
index 102e575c965d..541c6ed6a62f 100644
@@ -565,27 +565,27 @@ do {									\
 	iowrite16(wData & ~(wBits), iobase + byRegOfs);			\
 } while (0)
 
-#define MACvWriteBSSIDAddress(iobase, pbyEtherAddr)		\
+#define MACvWriteBSSIDAddress(iobase, mac_addr)		\
 do {								\
 	iowrite8(1, iobase + MAC_REG_PAGE1SEL);			\
-	iowrite8(pbyEtherAddr[0], iobase + MAC_REG_BSSID0);	\
-	iowrite8(pbyEtherAddr[1], iobase + MAC_REG_BSSID0 + 1);	\
-	iowrite8(pbyEtherAddr[2], iobase + MAC_REG_BSSID0 + 2);	\
-	iowrite8(pbyEtherAddr[3], iobase + MAC_REG_BSSID0 + 3);	\
-	iowrite8(pbyEtherAddr[4], iobase + MAC_REG_BSSID0 + 4);	\
-	iowrite8(pbyEtherAddr[5], iobase + MAC_REG_BSSID0 + 5);	\
+	iowrite8(mac_addr[0], iobase + MAC_REG_BSSID0);		\
+	iowrite8(mac_addr[1], iobase + MAC_REG_BSSID0 + 1);	\
+	iowrite8(mac_addr[2], iobase + MAC_REG_BSSID0 + 2);	\
+	iowrite8(mac_addr[3], iobase + MAC_REG_BSSID0 + 3);	\
+	iowrite8(mac_addr[4], iobase + MAC_REG_BSSID0 + 4);	\
+	iowrite8(mac_addr[5], iobase + MAC_REG_BSSID0 + 5);	\
 	iowrite8(0, iobase + MAC_REG_PAGE1SEL);			\
 } while (0)
 
-#define MACvReadEtherAddress(iobase, pbyEtherAddr)		\
+#define MACvReadEtherAddress(iobase, mac_addr)			\
 do {								\
 	iowrite8(1, iobase + MAC_REG_PAGE1SEL);			\
-	pbyEtherAddr[0] = ioread8(iobase + MAC_REG_PAR0);	\
-	pbyEtherAddr[1] = ioread8(iobase + MAC_REG_PAR0 + 1);	\
-	pbyEtherAddr[2] = ioread8(iobase + MAC_REG_PAR0 + 2);	\
-	pbyEtherAddr[3] = ioread8(iobase + MAC_REG_PAR0 + 3);	\
-	pbyEtherAddr[4] = ioread8(iobase + MAC_REG_PAR0 + 4);	\
-	pbyEtherAddr[5] = ioread8(iobase + MAC_REG_PAR0 + 5);	\
+	mac_addr[0] = ioread8(iobase + MAC_REG_PAR0);		\
+	mac_addr[1] = ioread8(iobase + MAC_REG_PAR0 + 1);	\
+	mac_addr[2] = ioread8(iobase + MAC_REG_PAR0 + 2);	\
+	mac_addr[3] = ioread8(iobase + MAC_REG_PAR0 + 3);	\
+	mac_addr[4] = ioread8(iobase + MAC_REG_PAR0 + 4);	\
+	mac_addr[5] = ioread8(iobase + MAC_REG_PAR0 + 5);	\
 	iowrite8(0, iobase + MAC_REG_PAGE1SEL);			\
 } while (0)
 
Signature · 1 line
2.36.1
#2 lore raw

Re: [PATCH 1/6] staging: vt6655: Rename pbyEtherAddr to mac_addr

Quoted 2 lines · Philipp Hortmann

Fix name of a variable in two macros that use CamelCase which is not accepted by checkpatch.pl

These might be nicer as functions with for loops

drivers/staging/vt6655/mac.h

Quoted 1 line
drivers/staging/vt6655/mac.h +0 -0

maybe something like:

static inline void MACvWriteBSSIDAddress(void __iomem *iobase, u8 *addr)

{
	int i;

	for (i = 0; i < ETH_ALEN; i++)
		iowrite8(*addr++, iobase + MAC_REG_BSSID0 + i);
}

static inline void MACvReadEtherAddress(void __iomem *iobase, u8 *addr)

{
	int i;

	iowrite8(1, iobase + MAC_REG_PAGE1SEL);
	for (i = 0; i < ETH_ALEN; i++)
		*addr++ = ioread8(iobase + MAC_REG_PAR0 + i);
	iowrite8(0, iobase + MAC_REG_PAGE1SEL);
}
#3 lore raw

PATCH 2/6 staging: vt6655: Rename MACvWriteBSSIDAddress

In reply to Philipp Hortmann

Fix name of a macro that uses CamelCase which is not accepted by checkpatch.pl

---
 drivers/staging/vt6655/device_main.c | 2 +-
 drivers/staging/vt6655/mac.h         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vt6655/device_main.c +1 -1
index 204994692c90..6cf21883d1fe 100644
@@ -1405,7 +1405,7 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
 
 		spin_lock_irqsave(&priv->lock, flags);
 
-		MACvWriteBSSIDAddress(priv->port_offset, conf->bssid);
+		vt6655_mac_write_bssid_addr(priv->port_offset, conf->bssid);
 
 		spin_unlock_irqrestore(&priv->lock, flags);
 	}
drivers/staging/vt6655/mac.h +1 -1
index 541c6ed6a62f..cfebd126e42f 100644
@@ -565,7 +565,7 @@ do {									\
 	iowrite16(wData & ~(wBits), iobase + byRegOfs);			\
 } while (0)
 
-#define MACvWriteBSSIDAddress(iobase, mac_addr)		\
+#define vt6655_mac_write_bssid_addr(iobase, mac_addr)		\
 do {								\
 	iowrite8(1, iobase + MAC_REG_PAGE1SEL);			\
 	iowrite8(mac_addr[0], iobase + MAC_REG_BSSID0);		\
Signature · 1 line
2.36.1
#4 lore raw

PATCH 3/6 staging: vt6655: Rename MACvReadEtherAddress

In reply to Philipp Hortmann

Fix name of a macro that uses CamelCase which is not accepted by checkpatch.pl

---
 drivers/staging/vt6655/device_main.c | 2 +-
 drivers/staging/vt6655/mac.h         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vt6655/device_main.c +1 -1
index 6cf21883d1fe..b9c57c661729 100644
@@ -1722,7 +1722,7 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
 	}
 	/* initial to reload eeprom */
 	MACvInitialize(priv);
-	MACvReadEtherAddress(priv->port_offset, priv->abyCurrentNetAddr);
+	vt6655_mac_read_ether_addr(priv->port_offset, priv->abyCurrentNetAddr);
 
 	/* Get RFType */
 	priv->byRFType = SROMbyReadEmbedded(priv->port_offset, EEP_OFS_RFTYPE);
drivers/staging/vt6655/mac.h +1 -1
index cfebd126e42f..ba5575d63db0 100644
@@ -577,7 +577,7 @@ do {								\
 	iowrite8(0, iobase + MAC_REG_PAGE1SEL);			\
 } while (0)
 
-#define MACvReadEtherAddress(iobase, mac_addr)			\
+#define vt6655_mac_read_ether_addr(iobase, mac_addr)		\
 do {								\
 	iowrite8(1, iobase + MAC_REG_PAGE1SEL);			\
 	mac_addr[0] = ioread8(iobase + MAC_REG_PAR0);		\
Signature · 1 line
2.36.1
#5 lore raw

PATCH 4/6 staging: vt6655: Move two macros to file where those are used

In reply to Philipp Hortmann

Move two multiline macros to file of only useage to convert them later to static functions. checkpatch.pl does not accept multiline macros.

---
 drivers/staging/vt6655/device_main.c | 24 ++++++++++++++++++++++++
 drivers/staging/vt6655/mac.h         | 24 ------------------------
 2 files changed, 24 insertions(+), 24 deletions(-)
drivers/staging/vt6655/device_main.c +24 -0
index b9c57c661729..fdb653071918 100644
@@ -186,6 +186,30 @@ device_set_options(struct vnt_private *priv)
 	pr_debug(" byBBType= %d\n", (int)priv->byBBType);
 }
 
+#define vt6655_mac_write_bssid_addr(iobase, mac_addr)		\
+do {								\
+	iowrite8(1, iobase + MAC_REG_PAGE1SEL);			\
+	iowrite8(mac_addr[0], iobase + MAC_REG_BSSID0);		\
+	iowrite8(mac_addr[1], iobase + MAC_REG_BSSID0 + 1);	\
+	iowrite8(mac_addr[2], iobase + MAC_REG_BSSID0 + 2);	\
+	iowrite8(mac_addr[3], iobase + MAC_REG_BSSID0 + 3);	\
+	iowrite8(mac_addr[4], iobase + MAC_REG_BSSID0 + 4);	\
+	iowrite8(mac_addr[5], iobase + MAC_REG_BSSID0 + 5);	\
+	iowrite8(0, iobase + MAC_REG_PAGE1SEL);			\
+} while (0)
+
+#define vt6655_mac_read_ether_addr(iobase, mac_addr)		\
+do {								\
+	iowrite8(1, iobase + MAC_REG_PAGE1SEL);			\
+	mac_addr[0] = ioread8(iobase + MAC_REG_PAR0);		\
+	mac_addr[1] = ioread8(iobase + MAC_REG_PAR0 + 1);	\
+	mac_addr[2] = ioread8(iobase + MAC_REG_PAR0 + 2);	\
+	mac_addr[3] = ioread8(iobase + MAC_REG_PAR0 + 3);	\
+	mac_addr[4] = ioread8(iobase + MAC_REG_PAR0 + 4);	\
+	mac_addr[5] = ioread8(iobase + MAC_REG_PAR0 + 5);	\
+	iowrite8(0, iobase + MAC_REG_PAGE1SEL);			\
+} while (0)
+
 /*
  * Initialisation of MAC & BBP registers
  */
drivers/staging/vt6655/mac.h +0 -24
index ba5575d63db0..5c14a76ed799 100644
@@ -565,30 +565,6 @@ do {									\
 	iowrite16(wData & ~(wBits), iobase + byRegOfs);			\
 } while (0)
 
-#define vt6655_mac_write_bssid_addr(iobase, mac_addr)		\
-do {								\
-	iowrite8(1, iobase + MAC_REG_PAGE1SEL);			\
-	iowrite8(mac_addr[0], iobase + MAC_REG_BSSID0);		\
-	iowrite8(mac_addr[1], iobase + MAC_REG_BSSID0 + 1);	\
-	iowrite8(mac_addr[2], iobase + MAC_REG_BSSID0 + 2);	\
-	iowrite8(mac_addr[3], iobase + MAC_REG_BSSID0 + 3);	\
-	iowrite8(mac_addr[4], iobase + MAC_REG_BSSID0 + 4);	\
-	iowrite8(mac_addr[5], iobase + MAC_REG_BSSID0 + 5);	\
-	iowrite8(0, iobase + MAC_REG_PAGE1SEL);			\
-} while (0)
-
-#define vt6655_mac_read_ether_addr(iobase, mac_addr)		\
-do {								\
-	iowrite8(1, iobase + MAC_REG_PAGE1SEL);			\
-	mac_addr[0] = ioread8(iobase + MAC_REG_PAR0);		\
-	mac_addr[1] = ioread8(iobase + MAC_REG_PAR0 + 1);	\
-	mac_addr[2] = ioread8(iobase + MAC_REG_PAR0 + 2);	\
-	mac_addr[3] = ioread8(iobase + MAC_REG_PAR0 + 3);	\
-	mac_addr[4] = ioread8(iobase + MAC_REG_PAR0 + 4);	\
-	mac_addr[5] = ioread8(iobase + MAC_REG_PAR0 + 5);	\
-	iowrite8(0, iobase + MAC_REG_PAGE1SEL);			\
-} while (0)
-
 #define MACvReceive0(iobase)						\
 do {									\
 	unsigned long dwData;						\
Signature · 1 line
2.36.1
#6 lore raw

PATCH 5/6 staging: vt6655: Convert macro vt6655_mac_write_bssid_addr to function

In reply to Philipp Hortmann

Convert macro vt6655_mac_write_bssid_addr to static function. checkpatch.pl does not accept multiline macros.

---
 drivers/staging/vt6655/device_main.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/staging/vt6655/device_main.c +13 -11
index fdb653071918..025a53b493d3 100644
@@ -122,6 +122,8 @@ static int  vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent);
 static void device_free_info(struct vnt_private *priv);
 static void device_print_info(struct vnt_private *priv);
 
+static void vt6655_mac_write_bssid_addr(void __iomem *iobase, const u8 *mac_addr);
+
 static int device_init_rd0_ring(struct vnt_private *priv);
 static int device_init_rd1_ring(struct vnt_private *priv);
 static int device_init_td0_ring(struct vnt_private *priv);
@@ -186,17 +188,17 @@ device_set_options(struct vnt_private *priv)
 	pr_debug(" byBBType= %d\n", (int)priv->byBBType);
 }
 
-#define vt6655_mac_write_bssid_addr(iobase, mac_addr)		\
-do {								\
-	iowrite8(1, iobase + MAC_REG_PAGE1SEL);			\
-	iowrite8(mac_addr[0], iobase + MAC_REG_BSSID0);		\
-	iowrite8(mac_addr[1], iobase + MAC_REG_BSSID0 + 1);	\
-	iowrite8(mac_addr[2], iobase + MAC_REG_BSSID0 + 2);	\
-	iowrite8(mac_addr[3], iobase + MAC_REG_BSSID0 + 3);	\
-	iowrite8(mac_addr[4], iobase + MAC_REG_BSSID0 + 4);	\
-	iowrite8(mac_addr[5], iobase + MAC_REG_BSSID0 + 5);	\
-	iowrite8(0, iobase + MAC_REG_PAGE1SEL);			\
-} while (0)
+static void vt6655_mac_write_bssid_addr(void __iomem *iobase, const u8 *mac_addr)
+{
+	iowrite8(1, iobase + MAC_REG_PAGE1SEL);
+	iowrite8(mac_addr[0], iobase + MAC_REG_BSSID0);
+	iowrite8(mac_addr[1], iobase + MAC_REG_BSSID0 + 1);
+	iowrite8(mac_addr[2], iobase + MAC_REG_BSSID0 + 2);
+	iowrite8(mac_addr[3], iobase + MAC_REG_BSSID0 + 3);
+	iowrite8(mac_addr[4], iobase + MAC_REG_BSSID0 + 4);
+	iowrite8(mac_addr[5], iobase + MAC_REG_BSSID0 + 5);
+	iowrite8(0, iobase + MAC_REG_PAGE1SEL);
+}
 
 #define vt6655_mac_read_ether_addr(iobase, mac_addr)		\
 do {								\
Signature · 1 line
2.36.1
#7 lore raw

PATCH 6/6 staging: vt6655: Convert macro vt6655_mac_read_ether_addr to function

In reply to Philipp Hortmann

Convert macro vt6655_mac_read_ether_addr to static function. checkpatch.pl does not accept multiline macros.

---
 drivers/staging/vt6655/device_main.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/staging/vt6655/device_main.c +12 -11
index 025a53b493d3..298963cbca1d 100644
@@ -123,6 +123,7 @@ static void device_free_info(struct vnt_private *priv);
 static void device_print_info(struct vnt_private *priv);
 
 static void vt6655_mac_write_bssid_addr(void __iomem *iobase, const u8 *mac_addr);
+static void vt6655_mac_read_ether_addr(void __iomem *iobase, u8 *mac_addr);
 
 static int device_init_rd0_ring(struct vnt_private *priv);
 static int device_init_rd1_ring(struct vnt_private *priv);
@@ -200,17 +201,17 @@ static void vt6655_mac_write_bssid_addr(void __iomem *iobase, const u8 *mac_addr
 	iowrite8(0, iobase + MAC_REG_PAGE1SEL);
 }
 
-#define vt6655_mac_read_ether_addr(iobase, mac_addr)		\
-do {								\
-	iowrite8(1, iobase + MAC_REG_PAGE1SEL);			\
-	mac_addr[0] = ioread8(iobase + MAC_REG_PAR0);		\
-	mac_addr[1] = ioread8(iobase + MAC_REG_PAR0 + 1);	\
-	mac_addr[2] = ioread8(iobase + MAC_REG_PAR0 + 2);	\
-	mac_addr[3] = ioread8(iobase + MAC_REG_PAR0 + 3);	\
-	mac_addr[4] = ioread8(iobase + MAC_REG_PAR0 + 4);	\
-	mac_addr[5] = ioread8(iobase + MAC_REG_PAR0 + 5);	\
-	iowrite8(0, iobase + MAC_REG_PAGE1SEL);			\
-} while (0)
+static void vt6655_mac_read_ether_addr(void __iomem *iobase, u8 *mac_addr)
+{
+	iowrite8(1, iobase + MAC_REG_PAGE1SEL);
+	mac_addr[0] = ioread8(iobase + MAC_REG_PAR0);
+	mac_addr[1] = ioread8(iobase + MAC_REG_PAR0 + 1);
+	mac_addr[2] = ioread8(iobase + MAC_REG_PAR0 + 2);
+	mac_addr[3] = ioread8(iobase + MAC_REG_PAR0 + 3);
+	mac_addr[4] = ioread8(iobase + MAC_REG_PAR0 + 4);
+	mac_addr[5] = ioread8(iobase + MAC_REG_PAR0 + 5);
+	iowrite8(0, iobase + MAC_REG_PAGE1SEL);
+}
 
 /*
  * Initialisation of MAC & BBP registers
Signature · 1 line
2.36.1