Skip to contentSkip to conversation

staging: slicoss: minor changes to clean some code

PATCH Superseded Sergio Paracuellos 2 participants 6 messages Nov 23, 2016 – Nov 24, 2016 Staging

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover staging: slicoss: minor changes to clean some code

This patchset clean some code in slicoss driver:
* Removes not used macro.
* Replaces a macro with an inline function.

Sergio Paracuellos (2):
staging: slicoss: remove not used UPDATE_STATS macro
staging: slicoss: replace UPDATE_STATS_GB macro into an inline
function

 drivers/staging/slicoss/slic.h    | 14 +++-------
 drivers/staging/slicoss/slicoss.c | 56 ++++++++++++++++++++-------------------
 2 files changed, 32 insertions(+), 38 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 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 2/2 staging: slicoss: replace UPDATE_STATS_GB macro into an inline function

In reply to Sergio Paracuellos

This patch replaces UPDATE_STATS_GB macro in slic.h header file into an inline function. This provides type safety and readability.

---
 drivers/staging/slicoss/slic.h    |  6 ++---
 drivers/staging/slicoss/slicoss.c | 56 ++++++++++++++++++++-------------------
 2 files changed, 32 insertions(+), 30 deletions(-)
drivers/staging/slicoss/slic.h +3 -3
index 2c05868..b19ddc9 100644
@@ -548,9 +548,9 @@ 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));                          \
+static inline u64 update_stats_gb(const u64 newstat, const u64 oldstat)
+{
+	return (newstat - oldstat);
 }
 
 #if BITS_PER_LONG == 64
drivers/staging/slicoss/slicoss.c +29 -27

74 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

Re: [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into an inline function

Quoted 15 lines · Sergio Paracuellos

This patch replaces UPDATE_STATS_GB macro in slic.h header file into an inline function. This provides type safety and readability.

---
 drivers/staging/slicoss/slic.h    |  6 ++---
 drivers/staging/slicoss/slicoss.c | 56 ++++++++++++++++++++-------------------
 2 files changed, 32 insertions(+), 30 deletions(-)
drivers/staging/slicoss/slic.h +0 -0
index 2c05868..b19ddc9 100644
@@ -548,9 +548,9 @@ static inline void slic_flush_write(struct adapter *adapter)
 	ioread32(adapter->regs + SLIC_REG_HOSTID);

drivers/staging/slicoss/slic.h static inline void slic_flush_write(struct adapter *adapter) · line 555

Quoted 10 lines
drivers/staging/slicoss/slic.h +3 -3
 }
 
-#define UPDATE_STATS_GB(largestat, newstat, oldstat)                     \
-{                                                                        \
-	(largestat) += ((newstat) - (oldstat));                          \
+static inline u64 update_stats_gb(const u64 newstat, const u64 oldstat)
+{
+	return (newstat - oldstat);
 }
 

I suggest dropping the parentheses here. They are unnecessary and likely to lead to a cleanup patch.

Regards,
Markus

#4 lore raw

Re: [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into an inline function

Quoted 18 lines · Markus Böhme
Quoted 17 lines · Sergio Paracuellos

This patch replaces UPDATE_STATS_GB macro in slic.h header file into an inline function. This provides type safety and readability.

---
 drivers/staging/slicoss/slic.h    |  6 ++---
 drivers/staging/slicoss/slicoss.c | 56 ++++++++++++++++++++-------------------
 2 files changed, 32 insertions(+), 30 deletions(-)
drivers/staging/slicoss/slic.h +0 -0
index 2c05868..b19ddc9 100644
@@ -548,9 +548,9 @@ static inline void slic_flush_write(struct adapter *adapter)
 	ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
Quoted 12 lines

drivers/staging/slicoss/slic.h static inline void slic_flush_write(struct adapter *adapter) · line 555

Quoted 8 lines
drivers/staging/slicoss/slic.h +3 -3
-#define UPDATE_STATS_GB(largestat, newstat, oldstat)                     \
-{                                                                        \
-	(largestat) += ((newstat) - (oldstat));                          \
+static inline u64 update_stats_gb(const u64 newstat, const u64 oldstat)
+{
+	return (newstat - oldstat);
 }
 

I suggest dropping the parentheses here. They are unnecessary and likely to lead to a cleanup patch.

Giving it a second thought, perhaps one should do without this macro/function and just inline the calculation. IMO this would improve readability even more.

Regards,
Markus

#5 lore raw

Re: [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into an inline function

Quoted 32 lines · Markus Böhme
Quoted 18 lines · Markus Böhme
Quoted 17 lines · Sergio Paracuellos

This patch replaces UPDATE_STATS_GB macro in slic.h header file into an inline function. This provides type safety and readability.

---
 drivers/staging/slicoss/slic.h    |  6 ++---
 drivers/staging/slicoss/slicoss.c | 56 ++++++++++++++++++++-------------------
 2 files changed, 32 insertions(+), 30 deletions(-)
drivers/staging/slicoss/slic.h +0 -0
index 2c05868..b19ddc9 100644
@@ -548,9 +548,9 @@ static inline void slic_flush_write(struct adapter *adapter)
     ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
Quoted 12 lines

drivers/staging/slicoss/slic.h static inline void slic_flush_write(struct adapter *adapter) · line 555

Quoted 8 lines
drivers/staging/slicoss/slic.h +3 -3
-#define UPDATE_STATS_GB(largestat, newstat, oldstat)                     \
-{                                                                        \
-    (largestat) += ((newstat) - (oldstat));                          \
+static inline u64 update_stats_gb(const u64 newstat, const u64 oldstat)
+{
+    return (newstat - oldstat);
 }
 

I suggest dropping the parentheses here. They are unnecessary and likely to lead to a cleanup patch.

Quoted 3 lines

Giving it a second thought, perhaps one should do without this macro/function and just inline the calculation. IMO this would improve readability even more.

I see. Ok, I'll remove this inline function and macro and send a V2 patchset with just the calculation inlined.

Thanks,

Sergio Paracuellos