mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergio Paracuellos <sergio.paracuellos@gmail.com>
To: gregkh@linuxfoundation.org
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	liodot@gmail.com, charrer@alacritech.com
Subject: [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into an inline function
Date: Wed, 23 Nov 2016 19:10:29 +0100	[thread overview]
Message-ID: <1479924629-20231-3-git-send-email-sergio.paracuellos@gmail.com> (raw)
In-Reply-To: <1479924629-20231-1-git-send-email-sergio.paracuellos@gmail.com>

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

  parent reply	other threads:[~2016-11-23 18:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-23 18:10 [PATCH 0/2] staging: slicoss: minor changes to clean some code Sergio Paracuellos
2016-11-23 18:10 ` [PATCH 1/2] staging: slicoss: remove not used UPDATE_STATS macro Sergio Paracuellos
2016-11-23 18:10 ` Sergio Paracuellos [this message]
2016-11-23 19:00   ` [PATCH 2/2] staging: slicoss: replace UPDATE_STATS_GB macro into an inline function Markus Böhme
2016-11-23 22:32     ` Markus Böhme
2016-11-24 19:01       ` Sergio Paracuellos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1479924629-20231-3-git-send-email-sergio.paracuellos@gmail.com \
    --to=sergio.paracuellos@gmail.com \
    --cc=charrer@alacritech.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liodot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®