Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1528664 > unrolled thread

[PATCH 0/2] staging: slicoss: minor changes to clean some code

Started bySergio Paracuellos <sergio.paracuellos@gmail.com>
First post2016-11-23 19:10 +0100
Last post2016-11-24 20:10 +0100
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/2] staging: slicoss: minor changes to clean some code Sergio Paracuellos <sergio.paracuellos@gmail.com> - 2016-11-23 19:10 +0100
    [PATCH 1/2] staging: slicoss: remove not used UPDATE_STATS macro Sergio Paracuellos <sergio.paracuellos@gmail.com> - 2016-11-23 19:20 +0100
    [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into an inline function Sergio Paracuellos <sergio.paracuellos@gmail.com> - 2016-11-23 19:20 +0100
      Re: [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into  an inline function Markus Böhme <markus.boehme@mailbox.org> - 2016-11-23 20:10 +0100
        Re: [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into  an inline function Markus Böhme <markus.boehme@mailbox.org> - 2016-11-23 23:40 +0100
          Re: [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into  an inline function Sergio Paracuellos <sergio.paracuellos@gmail.com> - 2016-11-24 20:10 +0100

#1528664 — [PATCH 0/2] staging: slicoss: minor changes to clean some code

FromSergio Paracuellos <sergio.paracuellos@gmail.com>
Date2016-11-23 19:10 +0100
Subject[PATCH 0/2] staging: slicoss: minor changes to clean some code
Message-ID<sGK9B-8fN-59@gated-at.bofh.it>
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(-)

-- 
1.9.1

[toc] | [next] | [standalone]


#1528668 — [PATCH 1/2] staging: slicoss: remove not used UPDATE_STATS macro

FromSergio Paracuellos <sergio.paracuellos@gmail.com>
Date2016-11-23 19:20 +0100
Subject[PATCH 1/2] staging: slicoss: remove not used UPDATE_STATS macro
Message-ID<sGKjg-8nq-27@gated-at.bofh.it>
In reply to#1528664
This patch remove UPDATE_STATS macro from
header slic.h which is not being used.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/slicoss/slic.h | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
index 1f6562c..2c05868 100644
--- a/drivers/staging/slicoss/slic.h
+++ b/drivers/staging/slicoss/slic.h
@@ -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));                          \
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1528669 — [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into an inline function

FromSergio Paracuellos <sergio.paracuellos@gmail.com>
Date2016-11-23 19:20 +0100
Subject[PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into an inline function
Message-ID<sGKjg-8nq-21@gated-at.bofh.it>
In reply to#1528664
This patch replaces UPDATE_STATS_GB macro in slic.h header file
into an inline function. This provides type safety and readability.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/slicoss/slic.h    |  6 ++---
 drivers/staging/slicoss/slicoss.c | 56 ++++++++++++++++++++-------------------
 2 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
index 2c05868..b19ddc9 100644
--- a/drivers/staging/slicoss/slic.h
+++ b/drivers/staging/slicoss/slic.h
@@ -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
diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
index b6ec0a1..6d2f9cc 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -1014,45 +1014,47 @@ 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 = update_stats_gb(stats->xmit_tcp_segs,
+							  old->xmit_tcp_segs);
 
-		UPDATE_STATS_GB(stst->tcp.xmit_tcp_bytes, stats->xmit_tcp_bytes,
-				old->xmit_tcp_bytes);
+		stst->tcp.xmit_tcp_bytes =
+			update_stats_gb(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 = update_stats_gb(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 = update_stats_gb(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 = update_stats_gb(stats->xmit_bytes,
+							old->xmit_bytes);
 
-		UPDATE_STATS_GB(stst->iface.xmt_ucast, stats->xmit_unicasts,
-				old->xmit_unicasts);
+		stst->iface.xmt_ucast = update_stats_gb(stats->xmit_unicasts,
+							old->xmit_unicasts);
 
-		UPDATE_STATS_GB(stst->iface.rcv_bytes, stats->rcv_bytes,
-				old->rcv_bytes);
+		stst->iface.rcv_bytes = update_stats_gb(stats->rcv_bytes,
+							old->rcv_bytes);
 
-		UPDATE_STATS_GB(stst->iface.rcv_ucast, stats->rcv_unicasts,
-				old->rcv_unicasts);
+		stst->iface.rcv_ucast = update_stats_gb(stats->rcv_unicasts,
+							old->rcv_unicasts);
 
-		UPDATE_STATS_GB(stst->iface.xmt_errors, stats->xmit_collisions,
-				old->xmit_collisions);
+		stst->iface.xmt_errors = update_stats_gb(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 =
+			update_stats_gb(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 =
+			update_stats_gb(stats->xmit_other_error,
+					old->xmit_other_error);
 
-		UPDATE_STATS_GB(stst->iface.rcv_errors, stats->rcv_other_error,
-				old->rcv_other_error);
+		stst->iface.rcv_errors = update_stats_gb(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 = update_stats_gb(stats->rcv_drops,
+							   old->rcv_drops);
 
 		if (stats->rcv_drops > old->rcv_drops)
 			adapter->rcv_drops += (stats->rcv_drops -
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


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

FromMarkus Böhme <markus.boehme@mailbox.org>
Date2016-11-23 20:10 +0100
SubjectRe: [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into an inline function
Message-ID<sGL5D-rk-5@gated-at.bofh.it>
In reply to#1528669
On 11/23/2016 07:10 PM, Sergio Paracuellos wrote:
> This patch replaces UPDATE_STATS_GB macro in slic.h header file
> into an inline function. This provides type safety and readability.
> 
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> ---
>  drivers/staging/slicoss/slic.h    |  6 ++---
>  drivers/staging/slicoss/slicoss.c | 56 ++++++++++++++++++++-------------------
>  2 files changed, 32 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
> index 2c05868..b19ddc9 100644
> --- a/drivers/staging/slicoss/slic.h
> +++ b/drivers/staging/slicoss/slic.h
> @@ -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);
>  }
>  

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

Regards,
Markus

[toc] | [prev] | [next] | [standalone]


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

FromMarkus Böhme <markus.boehme@mailbox.org>
Date2016-11-23 23:40 +0100
SubjectRe: [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into an inline function
Message-ID<sGOmR-2pg-3@gated-at.bofh.it>
In reply to#1528697
On 11/23/2016 08:00 PM, Markus Böhme wrote:
> On 11/23/2016 07:10 PM, Sergio Paracuellos wrote:
>> This patch replaces UPDATE_STATS_GB macro in slic.h header file
>> into an inline function. This provides type safety and readability.
>>
>> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
>> ---
>>  drivers/staging/slicoss/slic.h    |  6 ++---
>>  drivers/staging/slicoss/slicoss.c | 56 ++++++++++++++++++++-------------------
>>  2 files changed, 32 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
>> index 2c05868..b19ddc9 100644
>> --- a/drivers/staging/slicoss/slic.h
>> +++ b/drivers/staging/slicoss/slic.h
>> @@ -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);
>>  }
>>  
> 
> 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

[toc] | [prev] | [next] | [standalone]


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

FromSergio Paracuellos <sergio.paracuellos@gmail.com>
Date2016-11-24 20:10 +0100
SubjectRe: [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into an inline function
Message-ID<sH7zc-6SI-27@gated-at.bofh.it>
In reply to#1528806
On Wed, Nov 23, 2016 at 11:32 PM, Markus Böhme
<markus.boehme@mailbox.org> wrote:
> On 11/23/2016 08:00 PM, Markus Böhme wrote:
>> On 11/23/2016 07:10 PM, Sergio Paracuellos wrote:
>>> This patch replaces UPDATE_STATS_GB macro in slic.h header file
>>> into an inline function. This provides type safety and readability.
>>>
>>> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
>>> ---
>>>  drivers/staging/slicoss/slic.h    |  6 ++---
>>>  drivers/staging/slicoss/slicoss.c | 56 ++++++++++++++++++++-------------------
>>>  2 files changed, 32 insertions(+), 30 deletions(-)
>>>
>>> diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
>>> index 2c05868..b19ddc9 100644
>>> --- a/drivers/staging/slicoss/slic.h
>>> +++ b/drivers/staging/slicoss/slic.h
>>> @@ -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);
>>>  }
>>>
>>
>> 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.

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

Thanks,

Sergio Paracuellos

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web