Skip to contentSkip to conversation

staging: slicoss: minor changes to clean some code

PATCH Superseded Sergio Paracuellos 2 participants 5 messages Nov 24, 2016 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover staging: slicoss: minor changes to clean some code

This patchset clean some code in slicoss driver:
* Removes not used macro.
* Remove a macro and just inline code.

Changes in v2:
* Remove inline function into inline code.

Sergio Paracuellos (2):
staging: slicoss: remove not used UPDATE_STATS macro
staging: slicoss: remove UPDATE_STATS_GB macro and inline code

 drivers/staging/slicoss/slic.h    | 13 ----------
 drivers/staging/slicoss/slicoss.c | 52 +++++++++++++++++++--------------------
 2 files changed, 25 insertions(+), 40 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/2 staging: slicoss: remove not used UPDATE_STATS macro

This patch remove UPDATE_STATS macro from
header slic.h which is not being used.

---
 drivers/staging/slicoss/slic.h | 8 --------
 1 file changed, 8 deletions(-)
drivers/staging/slicoss/slic.h +0 -8
index 1f6562c..2c05868 100644
@@ -548,14 +548,6 @@ static inline void slic_flush_write(struct adapter *adapter)
 	ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
-#define UPDATE_STATS(largestat, newstat, oldstat)                        \
-{                                                                        \
-	if ((newstat) < (oldstat))                                       \
-		(largestat) += ((newstat) + (0xFFFFFFFF - oldstat + 1)); \
-	else                                                             \
-		(largestat) += ((newstat) - (oldstat));                  \
-}
-
 #define UPDATE_STATS_GB(largestat, newstat, oldstat)                     \
 {                                                                        \
 	(largestat) += ((newstat) - (oldstat));                          \
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/2 staging: slicoss: remove UPDATE_STATS_GB macro and inline code

In reply to Sergio Paracuellos

This patch removes UPDATE_STATS_GB macro in slic.h header file and just inline code. This improve readability.

---
 drivers/staging/slicoss/slic.h    |  5 ----
 drivers/staging/slicoss/slicoss.c | 52 +++++++++++++++++++--------------------
 2 files changed, 25 insertions(+), 32 deletions(-)
drivers/staging/slicoss/slic.h +0 -5
index 2c05868..2893bdf 100644
@@ -548,11 +548,6 @@ static inline void slic_flush_write(struct adapter *adapter)
 	ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
-#define UPDATE_STATS_GB(largestat, newstat, oldstat)                     \
-{                                                                        \
-	(largestat) += ((newstat) - (oldstat));                          \
-}
-
 #if BITS_PER_LONG == 64
 #define   SLIC_GET_ADDR_LOW(_addr)  (u32)((u64)(_addr) & \
 	0x00000000FFFFFFFF)
drivers/staging/slicoss/slicoss.c +25 -27

70 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

Re: [PATCH v2 2/2] staging: slicoss: remove UPDATE_STATS_GB macro and inline code

Quoted 30 lines · Sergio Paracuellos

This patch removes UPDATE_STATS_GB macro in slic.h header file and just inline code. This improve readability.

---
 drivers/staging/slicoss/slic.h    |  5 ----
 drivers/staging/slicoss/slicoss.c | 52 +++++++++++++++++++--------------------
 2 files changed, 25 insertions(+), 32 deletions(-)
drivers/staging/slicoss/slic.h +0 -5
index 2c05868..2893bdf 100644
@@ -548,11 +548,6 @@ static inline void slic_flush_write(struct adapter *adapter)
 	ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
-#define UPDATE_STATS_GB(largestat, newstat, oldstat)                     \
-{                                                                        \
-	(largestat) += ((newstat) - (oldstat));                          \
-}
-
 #if BITS_PER_LONG == 64
 #define   SLIC_GET_ADDR_LOW(_addr)  (u32)((u64)(_addr) & \
 	0x00000000FFFFFFFF)
drivers/staging/slicoss/slicoss.c +0 -0
index b6ec0a1..ffc7c45 100644

drivers/staging/slicoss/slicoss.c static void slic_upr_request_complete(struct adapter *adapter, u32 isr) · line 1018

Quoted 7 lines
drivers/staging/slicoss/slicoss.c +2 -2
@@ -1014,45 +1014,43 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr)
 			break;
 		}
 
-		UPDATE_STATS_GB(stst->tcp.xmit_tcp_segs, stats->xmit_tcp_segs,
-				old->xmit_tcp_segs);
+		stst->tcp.xmit_tcp_segs =
+			stats->xmit_tcp_segs - old->xmit_tcp_segs;

Missed this the first time, but the difference should be added to the value in stst:

		stst->tcp.xmit_tcp_segs +=
			stats->xmit_tcp_segs - old->xmit_tcp_segs;

The same applies to the changes below.

Quoted 54 lines
drivers/staging/slicoss/slicoss.c +20 -23
-		UPDATE_STATS_GB(stst->tcp.xmit_tcp_bytes, stats->xmit_tcp_bytes,
-				old->xmit_tcp_bytes);
+		stst->tcp.xmit_tcp_bytes =
+			stats->xmit_tcp_bytes - old->xmit_tcp_bytes;
 
-		UPDATE_STATS_GB(stst->tcp.rcv_tcp_segs, stats->rcv_tcp_segs,
-				old->rcv_tcp_segs);
+		stst->tcp.rcv_tcp_segs =
+			stats->rcv_tcp_segs - old->rcv_tcp_segs;
 
-		UPDATE_STATS_GB(stst->tcp.rcv_tcp_bytes, stats->rcv_tcp_bytes,
-				old->rcv_tcp_bytes);
+		stst->tcp.rcv_tcp_bytes =
+			stats->rcv_tcp_bytes - old->rcv_tcp_bytes;
 
-		UPDATE_STATS_GB(stst->iface.xmt_bytes, stats->xmit_bytes,
-				old->xmit_bytes);
+		stst->iface.xmt_bytes =
+			stats->xmit_bytes - old->xmit_bytes;
 
-		UPDATE_STATS_GB(stst->iface.xmt_ucast, stats->xmit_unicasts,
-				old->xmit_unicasts);
+		stst->iface.xmt_ucast =
+			stats->xmit_unicasts - old->xmit_unicasts;
 
-		UPDATE_STATS_GB(stst->iface.rcv_bytes, stats->rcv_bytes,
-				old->rcv_bytes);
+		stst->iface.rcv_bytes =
+			stats->rcv_bytes - old->rcv_bytes;
 
-		UPDATE_STATS_GB(stst->iface.rcv_ucast, stats->rcv_unicasts,
-				old->rcv_unicasts);
+		stst->iface.rcv_ucast =
+			stats->rcv_unicasts - old->rcv_unicasts;
 
-		UPDATE_STATS_GB(stst->iface.xmt_errors, stats->xmit_collisions,
-				old->xmit_collisions);
+		stst->iface.xmt_errors =
+			stats->xmit_collisions - old->xmit_collisions;
 
-		UPDATE_STATS_GB(stst->iface.xmt_errors,
-				stats->xmit_excess_collisions,
-				old->xmit_excess_collisions);
+		stst->iface.xmt_errors = stats->xmit_excess_collisions -
+					old->xmit_excess_collisions;
 
-		UPDATE_STATS_GB(stst->iface.xmt_errors, stats->xmit_other_error,
-				old->xmit_other_error);
+		stst->iface.xmt_errors =
+			stats->xmit_other_error - old->xmit_other_error;
 
-		UPDATE_STATS_GB(stst->iface.rcv_errors, stats->rcv_other_error,
-				old->rcv_other_error);

drivers/staging/slicoss/slicoss.c static void slic_upr_request_complete(struct adapter *adapter, u32 isr)

Quoted 10 lines
drivers/staging/slicoss/slicoss.c +3 -2
+		stst->iface.rcv_errors =
+			stats->rcv_other_error - old->rcv_other_error;
 
-		UPDATE_STATS_GB(stst->iface.rcv_discards, stats->rcv_drops,
-				old->rcv_drops);
+		stst->iface.rcv_discards = stats->rcv_drops - old->rcv_drops;
 
 		if (stats->rcv_drops > old->rcv_drops)
 			adapter->rcv_drops += (stats->rcv_drops -
 

Regards,
Markus

#4 lore raw

Re: [PATCH v2 2/2] staging: slicoss: remove UPDATE_STATS_GB macro and inline code

Quoted 42 lines · Markus Böhme
Quoted 30 lines · Sergio Paracuellos

This patch removes UPDATE_STATS_GB macro in slic.h header file and just inline code. This improve readability.

---
 drivers/staging/slicoss/slic.h    |  5 ----
 drivers/staging/slicoss/slicoss.c | 52 +++++++++++++++++++--------------------
 2 files changed, 25 insertions(+), 32 deletions(-)
drivers/staging/slicoss/slic.h +0 -5
index 2c05868..2893bdf 100644
@@ -548,11 +548,6 @@ static inline void slic_flush_write(struct adapter *adapter)
      ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
-#define UPDATE_STATS_GB(largestat, newstat, oldstat)                     \
-{                                                                        \
-     (largestat) += ((newstat) - (oldstat));                          \
-}
-
 #if BITS_PER_LONG == 64
 #define   SLIC_GET_ADDR_LOW(_addr)  (u32)((u64)(_addr) & \
      0x00000000FFFFFFFF)
drivers/staging/slicoss/slicoss.c +0 -0
index b6ec0a1..ffc7c45 100644

drivers/staging/slicoss/slicoss.c static void slic_upr_request_complete(struct adapter *adapter, u32 isr) · line 1018

Quoted 7 lines
drivers/staging/slicoss/slicoss.c +2 -2
@@ -1014,45 +1014,43 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr)
                      break;
              }
 
-             UPDATE_STATS_GB(stst->tcp.xmit_tcp_segs, stats->xmit_tcp_segs,
-                             old->xmit_tcp_segs);
+             stst->tcp.xmit_tcp_segs =
+                     stats->xmit_tcp_segs - old->xmit_tcp_segs;

Missed this the first time, but the difference should be added to the value in stst:

Quoted 4 lines
                stst->tcp.xmit_tcp_segs +=
                        stats->xmit_tcp_segs - old->xmit_tcp_segs;

The same applies to the changes below.

True. I have just sent v3 with these fixed.

Thanks for let me know.

Cheers,
Sergio Paracuellos