Skip to contentSkip to conversation

staging: vt6655: Reduce similar statements when working with mac addr

PATCH In review Philipp Hortmann 3 participants 6 messages Jul 6, 2022 – Jul 9, 2022 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: vt6655: Reduce similar statements when working with mac addr

Use loop in vt6655_mac_read_ether_addr and vt6655_mac_write_bssid_addr to avoid multiple similar statements.

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

Philipp Hortmann (2):
staging: vt6655: Use loop in vt6655_mac_write_bssid_addr
staging: vt6655: Use loop in vt6655_mac_read_ether_addr

 drivers/staging/vt6655/device_main.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
Signature · 1 line
2.37.0
#1 lore raw

PATCH 1/2 staging: vt6655: Use loop in vt6655_mac_write_bssid_addr

Use loop in vt6655_mac_write_bssid_addr to avoid multiple similar statements.

---
Code for testing:

for (int i = 0; i < 6; i++){
	iowrite8(mac_addr[i], iobase + MAC_REG_BSSID0 + i);
	printk("i = %i\n", i);
}

Log:

[ 2592.189081] i = 0
[ 2592.189083] i = 1
[ 2592.189083] i = 2
[ 2592.189084] i = 3
[ 2592.189084] i = 4
[ 2592.189085] i = 5
---
 drivers/staging/vt6655/device_main.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/vt6655/device_main.c +2 -6
index 298963cbca1d..099f0b95417a 100644
@@ -192,12 +192,8 @@ device_set_options(struct vnt_private *priv)
 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);
+	for (int i = 0; i < 6; i++)
+		iowrite8(mac_addr[i], iobase + MAC_REG_BSSID0 + i);
 	iowrite8(0, iobase + MAC_REG_PAGE1SEL);
 }
 
Signature · 1 line
2.37.0
#5 lore raw

PATCH 2/2 staging: vt6655: Use loop in vt6655_mac_read_ether_addr

In reply to Philipp Hortmann

Use loop in vt6655_mac_read_ether_addr to avoid multiple similar statements.

---
Code for testing:

	for (int i = 0; i < 6; i++){
		mac_addr[i] = ioread8(iobase + MAC_REG_PAR0 + i);
		printk("i = %i\n", i);
	}
Log:
[ 3608.011168] i = 0
[ 3608.011170] i = 1
[ 3608.011172] i = 2
[ 3608.011174] i = 3
[ 3608.011176] i = 4
[ 3608.011178] i = 5
---
 drivers/staging/vt6655/device_main.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/vt6655/device_main.c +2 -6
index 099f0b95417a..19840dddb4bf 100644
@@ -200,12 +200,8 @@ 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)
 {
 	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);
+	for (int i = 0; i < 6; i++)
+		mac_addr[i] = ioread8(iobase + MAC_REG_PAR0 + i);
 	iowrite8(0, iobase + MAC_REG_PAGE1SEL);
 }
 
Signature · 1 line
2.37.0
#2 lore raw

Re: [PATCH 1/2] staging: vt6655: Use loop in vt6655_mac_write_bssid_addr

In reply to Philipp Hortmann
Quoted 27 lines · Philipp Hortmann

Use loop in vt6655_mac_write_bssid_addr to avoid multiple similar statements.

---
Code for testing:

for (int i = 0; i < 6; i++){
	iowrite8(mac_addr[i], iobase + MAC_REG_BSSID0 + i);
	printk("i = %i\n", i);
}

Log:

[ 2592.189081] i = 0
[ 2592.189083] i = 1
[ 2592.189083] i = 2
[ 2592.189084] i = 3
[ 2592.189084] i = 4
[ 2592.189085] i = 5
---
 drivers/staging/vt6655/device_main.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/vt6655/device_main.c +0 -0
index 298963cbca1d..099f0b95417a 100644

drivers/staging/vt6655/device_main.c device_set_options(struct vnt_private *priv) · line 195

Quoted 10 lines
drivers/staging/vt6655/device_main.c +1 -6
@@ -192,12 +192,8 @@ device_set_options(struct vnt_private *priv)
 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);
+	for (int i = 0; i < 6; i++)

Taking advantage of the new compiler level I see, nice :)

#3 lore raw

Re: [PATCH 1/2] staging: vt6655: Use loop in vt6655_mac_write_bssid_addr

Quoted 3 lines · Greg Kroah-Hartman
Quoted 2 lines · Philipp Hortmann

Use loop in vt6655_mac_write_bssid_addr to avoid multiple similar statements.

[]

Quoted 1 line

drivers/staging/vt6655/device_main.c

Quoted 1 line
drivers/staging/vt6655/device_main.c +0 -0

[]

Quoted 2 lines

drivers/staging/vt6655/device_main.c device_set_options(struct vnt_private *priv) · line 192

Quoted 2 lines
drivers/staging/vt6655/device_main.c +0 -0
@@ -192,12 +192,8 @@ device_set_options(struct vnt_private *priv)
 static void vt6655_mac_write_bssid_addr(void __iomem *iobase, const u8 *mac_addr)

[]

Quoted 3 lines

drivers/staging/vt6655/device_main.c device_set_options(struct vnt_private *priv) · line 195

Quoted 1 line
drivers/staging/vt6655/device_main.c +1 -0
+	for (int i = 0; i < 6; i++)

Taking advantage of the new compiler level I see, nice :)

Not sure this is altogether a great idea as it may make backporting a bit difficult, but it's already in the kernel in a few places.

#4 lore raw

Re: [PATCH 1/2] staging: vt6655: Use loop in vt6655_mac_write_bssid_addr

Quoted 10 lines · Joe Perches
Quoted 3 lines · Greg Kroah-Hartman
Quoted 2 lines · Philipp Hortmann

Use loop in vt6655_mac_write_bssid_addr to avoid multiple similar statements.

[]

Quoted 1 line

drivers/staging/vt6655/device_main.c

Quoted 1 line
drivers/staging/vt6655/device_main.c +0 -0

[]

Quoted 2 lines

drivers/staging/vt6655/device_main.c device_set_options(struct vnt_private *priv) · line 192

Quoted 2 lines
drivers/staging/vt6655/device_main.c +0 -0
@@ -192,12 +192,8 @@ device_set_options(struct vnt_private *priv)
 static void vt6655_mac_write_bssid_addr(void __iomem *iobase, const u8 *mac_addr)

[]

Quoted 7 lines
Quoted 3 lines

drivers/staging/vt6655/device_main.c device_set_options(struct vnt_private *priv) · line 195

Quoted 1 line
drivers/staging/vt6655/device_main.c +1 -0
+	for (int i = 0; i < 6; i++)

Taking advantage of the new compiler level I see, nice :)

Not sure this is altogether a great idea as it may make backporting a bit difficult, but it's already in the kernel in a few places.

That's for the stable kernels to worry about, don't let that stop new development from happening for that reason please.

thanks,

greg k-h