From: Peng Sun <sironhide0null@gmail.com>
To: liodot@gmail.com, charrer@alacritech.com, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, Peng Sun <sironhide0null@gmail.com>
Subject: [PATCH 2/7] staging: slicoss: slicoss.c: fix different address space sparse warning
Date: Fri, 16 Sep 2016 19:05:47 -0700 [thread overview]
Message-ID: <1474077952-9265-3-git-send-email-sironhide0null@gmail.com> (raw)
In-Reply-To: <1474077952-9265-1-git-send-email-sironhide0null@gmail.com>
add IOMEM_GET_FIELDADDR to get address of a member of a __iomem structure;
add IOMEM_GET_FIELD64 to get u64 value of a member of a __iomem structure;
Signed-off-by: Peng Sun <sironhide0null@gmail.com>
---
drivers/staging/slicoss/slic.h | 32 +++++++++++++++++++++++++
drivers/staging/slicoss/slicoss.c | 49 +++++++++++++++++++++++++--------------
2 files changed, 64 insertions(+), 17 deletions(-)
diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
index 022e7f6..fec9ec5 100644
--- a/drivers/staging/slicoss/slic.h
+++ b/drivers/staging/slicoss/slic.h
@@ -539,6 +539,13 @@ static inline void slic_flush_write(struct adapter *adapter)
ioread32(adapter->regs + SLIC_REG_HOSTID);
}
+#define IOMEM_GET_FIELDADDR(base, member) \
+({ \
+ char __iomem *_base = (char __iomem *)base; \
+ _base += offsetof(typeof(*base), member); \
+ (void __iomem *)_base; \
+})
+
#define IOMEM_GET_FIELD32(base, member) \
({ \
char __iomem *_base = (char __iomem *)base; \
@@ -546,6 +553,31 @@ static inline void slic_flush_write(struct adapter *adapter)
ioread32(_base); \
})
+#ifdef CONFIG_64BIT
+#define IOMEM_GET_FIELD64(base, member) \
+({ \
+ char __iomem *_base = (char __iomem *)base; \
+ _base += offsetof(typeof(*base), member); \
+ readq(_base); \
+})
+#else
+#define IOMEM_GET_FIELD64(base, member) \
+({ \
+ char __iomem *_base = (char __iomem *)base; \
+ u64 val; \
+ _base += offsetof(typeof(*base), member); \
+ val = ((u64)ioread8(_base + 7)) << 56; \
+ val += ((u64)ioread8(_base + 6)) << 48; \
+ val += ((u64)ioread8(_base + 5)) << 40; \
+ val += ((u64)ioread8(_base + 4)) << 32; \
+ val += ((u64)ioread8(_base + 3)) << 24; \
+ val += ((u64)ioread8(_base + 2)) << 16; \
+ val += ((u64)ioread8(_base + 1)) << 8; \
+ val += ioread8(_base); \
+ le64_to_cpu(val); \
+})
+#endif
+
#define UPDATE_STATS(largestat, newstat, oldstat) \
{ \
if ((newstat) < (oldstat)) \
diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
index 929a0d5..8426392 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -1004,8 +1004,9 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr)
switch (upr->upr_request) {
case SLIC_UPR_STATS: {
struct slic_shmemory *sm = &adapter->shmem;
- struct slic_shmem_data *sm_data = sm->shmem_data;
- struct slic_stats *stats = &sm_data->stats;
+ struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
+ struct slic_stats __iomem *stats =
+ IOMEM_GET_FIELDADDR(sm_data, stats);
struct slic_stats *old = &adapter->inicstats_prev;
struct slicnet_stats *stst = &adapter->slic_stats;
@@ -1015,48 +1016,62 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr)
break;
}
- UPDATE_STATS_GB(stst->tcp.xmit_tcp_segs, stats->xmit_tcp_segs,
+ UPDATE_STATS_GB(stst->tcp.xmit_tcp_segs,
+ IOMEM_GET_FIELD64(stats, xmit_tcp_segs),
old->xmit_tcp_segs);
- UPDATE_STATS_GB(stst->tcp.xmit_tcp_bytes, stats->xmit_tcp_bytes,
+ UPDATE_STATS_GB(stst->tcp.xmit_tcp_bytes,
+ IOMEM_GET_FIELD64(stats, xmit_tcp_bytes),
old->xmit_tcp_bytes);
- UPDATE_STATS_GB(stst->tcp.rcv_tcp_segs, stats->rcv_tcp_segs,
+ UPDATE_STATS_GB(stst->tcp.rcv_tcp_segs,
+ IOMEM_GET_FIELD64(stats, rcv_tcp_segs),
old->rcv_tcp_segs);
- UPDATE_STATS_GB(stst->tcp.rcv_tcp_bytes, stats->rcv_tcp_bytes,
+ UPDATE_STATS_GB(stst->tcp.rcv_tcp_bytes,
+ IOMEM_GET_FIELD64(stats, rcv_tcp_bytes),
old->rcv_tcp_bytes);
- UPDATE_STATS_GB(stst->iface.xmt_bytes, stats->xmit_bytes,
+ UPDATE_STATS_GB(stst->iface.xmt_bytes,
+ IOMEM_GET_FIELD64(stats, xmit_bytes),
old->xmit_bytes);
- UPDATE_STATS_GB(stst->iface.xmt_ucast, stats->xmit_unicasts,
+ UPDATE_STATS_GB(stst->iface.xmt_ucast,
+ IOMEM_GET_FIELD64(stats, xmit_unicasts),
old->xmit_unicasts);
- UPDATE_STATS_GB(stst->iface.rcv_bytes, stats->rcv_bytes,
+ UPDATE_STATS_GB(stst->iface.rcv_bytes,
+ IOMEM_GET_FIELD64(stats, rcv_bytes),
old->rcv_bytes);
- UPDATE_STATS_GB(stst->iface.rcv_ucast, stats->rcv_unicasts,
+ UPDATE_STATS_GB(stst->iface.rcv_ucast,
+ IOMEM_GET_FIELD64(stats, rcv_unicasts),
old->rcv_unicasts);
- UPDATE_STATS_GB(stst->iface.xmt_errors, stats->xmit_collisions,
+ UPDATE_STATS_GB(stst->iface.xmt_errors,
+ IOMEM_GET_FIELD64(stats, xmit_collisions),
old->xmit_collisions);
UPDATE_STATS_GB(stst->iface.xmt_errors,
- stats->xmit_excess_collisions,
+ IOMEM_GET_FIELD64(stats,
+ xmit_excess_collisions),
old->xmit_excess_collisions);
- UPDATE_STATS_GB(stst->iface.xmt_errors, stats->xmit_other_error,
+ UPDATE_STATS_GB(stst->iface.xmt_errors,
+ IOMEM_GET_FIELD64(stats, xmit_other_error),
old->xmit_other_error);
- UPDATE_STATS_GB(stst->iface.rcv_errors, stats->rcv_other_error,
+ UPDATE_STATS_GB(stst->iface.rcv_errors,
+ IOMEM_GET_FIELD64(stats, rcv_other_error),
old->rcv_other_error);
- UPDATE_STATS_GB(stst->iface.rcv_discards, stats->rcv_drops,
+ UPDATE_STATS_GB(stst->iface.rcv_discards,
+ IOMEM_GET_FIELD64(stats, rcv_drops),
old->rcv_drops);
- if (stats->rcv_drops > old->rcv_drops)
- adapter->rcv_drops += (stats->rcv_drops -
+ if (IOMEM_GET_FIELD64(stats, rcv_drops) > old->rcv_drops)
+ adapter->rcv_drops +=
+ (IOMEM_GET_FIELD64(stats, rcv_drops) -
old->rcv_drops);
memcpy_fromio(old, stats, sizeof(*stats));
break;
--
2.7.4
next prev parent reply other threads:[~2016-09-17 2:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-17 2:05 [PATCH 0/7] staging: slicoss: fix different address space sparse warnings Peng Sun
2016-09-17 2:05 ` [PATCH 1/7] staging: slicoss: slicoss.c: fix different address space sparse warning Peng Sun
2016-09-17 2:05 ` Peng Sun [this message]
2016-09-17 2:05 ` [PATCH 3/7] " Peng Sun
2016-09-17 2:05 ` [PATCH 4/7] " Peng Sun
2016-09-17 2:05 ` [PATCH 5/7] " Peng Sun
2016-09-17 2:05 ` [PATCH 6/7] " Peng Sun
2016-09-17 2:05 ` [PATCH 7/7] " Peng Sun
2016-09-17 8:30 ` Greg KH
2016-09-17 8:30 ` [PATCH 0/7] staging: slicoss: fix different address space sparse warnings Greg KH
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=1474077952-9265-3-git-send-email-sironhide0null@gmail.com \
--to=sironhide0null@gmail.com \
--cc=charrer@alacritech.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.