From: Anton Blanchard <anton@samba.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 33/39] powerpc/hvsi: Fix endian issues in HVSI driver
Date: Mon, 23 Sep 2013 12:05:07 +1000 [thread overview]
Message-ID: <1379901913-5945-34-git-send-email-anton@samba.org> (raw)
In-Reply-To: <1379901913-5945-1-git-send-email-anton@samba.org>
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
arch/powerpc/include/asm/hvsi.h | 16 ++++++++--------
drivers/tty/hvc/hvsi_lib.c | 25 ++++++++++++-------------
2 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/arch/powerpc/include/asm/hvsi.h b/arch/powerpc/include/asm/hvsi.h
index d3f64f3..d4a5315 100644
--- a/arch/powerpc/include/asm/hvsi.h
+++ b/arch/powerpc/include/asm/hvsi.h
@@ -25,7 +25,7 @@
struct hvsi_header {
uint8_t type;
uint8_t len;
- uint16_t seqno;
+ __be16 seqno;
} __attribute__((packed));
struct hvsi_data {
@@ -35,24 +35,24 @@ struct hvsi_data {
struct hvsi_control {
struct hvsi_header hdr;
- uint16_t verb;
+ __be16 verb;
/* optional depending on verb: */
- uint32_t word;
- uint32_t mask;
+ __be32 word;
+ __be32 mask;
} __attribute__((packed));
struct hvsi_query {
struct hvsi_header hdr;
- uint16_t verb;
+ __be16 verb;
} __attribute__((packed));
struct hvsi_query_response {
struct hvsi_header hdr;
- uint16_t verb;
- uint16_t query_seqno;
+ __be16 verb;
+ __be16 query_seqno;
union {
uint8_t version;
- uint32_t mctrl_word;
+ __be32 mctrl_word;
} u;
} __attribute__((packed));
diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
index ac27671..347050e 100644
--- a/drivers/tty/hvc/hvsi_lib.c
+++ b/drivers/tty/hvc/hvsi_lib.c
@@ -9,7 +9,7 @@
static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
{
- packet->seqno = atomic_inc_return(&pv->seqno);
+ packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno));
/* Assumes that always succeeds, works in practice */
return pv->put_chars(pv->termno, (char *)packet, packet->len);
@@ -28,7 +28,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
/* Send version query */
q.hdr.type = VS_QUERY_PACKET_HEADER;
q.hdr.len = sizeof(struct hvsi_query);
- q.verb = VSV_SEND_VERSION_NUMBER;
+ q.verb = cpu_to_be16(VSV_SEND_VERSION_NUMBER);
hvsi_send_packet(pv, &q.hdr);
}
@@ -40,7 +40,7 @@ static int hvsi_send_close(struct hvsi_priv *pv)
ctrl.hdr.type = VS_CONTROL_PACKET_HEADER;
ctrl.hdr.len = sizeof(struct hvsi_control);
- ctrl.verb = VSV_CLOSE_PROTOCOL;
+ ctrl.verb = cpu_to_be16(VSV_CLOSE_PROTOCOL);
return hvsi_send_packet(pv, &ctrl.hdr);
}
@@ -69,14 +69,14 @@ static void hvsi_got_control(struct hvsi_priv *pv)
{
struct hvsi_control *pkt = (struct hvsi_control *)pv->inbuf;
- switch (pkt->verb) {
+ switch (be16_to_cpu(pkt->verb)) {
case VSV_CLOSE_PROTOCOL:
/* We restart the handshaking */
hvsi_start_handshake(pv);
break;
case VSV_MODEM_CTL_UPDATE:
/* Transition of carrier detect */
- hvsi_cd_change(pv, pkt->word & HVSI_TSCD);
+ hvsi_cd_change(pv, be32_to_cpu(pkt->word) & HVSI_TSCD);
break;
}
}
@@ -87,7 +87,7 @@ static void hvsi_got_query(struct hvsi_priv *pv)
struct hvsi_query_response r;
/* We only handle version queries */
- if (pkt->verb != VSV_SEND_VERSION_NUMBER)
+ if (be16_to_cpu(pkt->verb) != VSV_SEND_VERSION_NUMBER)
return;
pr_devel("HVSI@%x: Got version query, sending response...\n",
@@ -96,7 +96,7 @@ static void hvsi_got_query(struct hvsi_priv *pv)
/* Send version response */
r.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
r.hdr.len = sizeof(struct hvsi_query_response);
- r.verb = VSV_SEND_VERSION_NUMBER;
+ r.verb = cpu_to_be16(VSV_SEND_VERSION_NUMBER);
r.u.version = HVSI_VERSION;
r.query_seqno = pkt->hdr.seqno;
hvsi_send_packet(pv, &r.hdr);
@@ -112,7 +112,7 @@ static void hvsi_got_response(struct hvsi_priv *pv)
switch(r->verb) {
case VSV_SEND_MODEM_CTL_STATUS:
- hvsi_cd_change(pv, r->u.mctrl_word & HVSI_TSCD);
+ hvsi_cd_change(pv, be32_to_cpu(r->u.mctrl_word) & HVSI_TSCD);
pv->mctrl_update = 1;
break;
}
@@ -265,8 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
pv->mctrl_update = 0;
q.hdr.type = VS_QUERY_PACKET_HEADER;
q.hdr.len = sizeof(struct hvsi_query);
- q.hdr.seqno = atomic_inc_return(&pv->seqno);
- q.verb = VSV_SEND_MODEM_CTL_STATUS;
+ q.verb = cpu_to_be16(VSV_SEND_MODEM_CTL_STATUS);
rc = hvsi_send_packet(pv, &q.hdr);
if (rc <= 0) {
pr_devel("HVSI@%x: Error %d...\n", pv->termno, rc);
@@ -304,9 +303,9 @@ int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr)
ctrl.hdr.type = VS_CONTROL_PACKET_HEADER,
ctrl.hdr.len = sizeof(struct hvsi_control);
- ctrl.verb = VSV_SET_MODEM_CTL;
- ctrl.mask = HVSI_TSDTR;
- ctrl.word = dtr ? HVSI_TSDTR : 0;
+ ctrl.verb = cpu_to_be16(VSV_SET_MODEM_CTL);
+ ctrl.mask = cpu_to_be32(HVSI_TSDTR);
+ ctrl.word = cpu_to_be32(dtr ? HVSI_TSDTR : 0);
return hvsi_send_packet(pv, &ctrl.hdr);
}
--
1.8.1.2
next prev parent reply other threads:[~2013-09-23 2:05 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-23 2:04 [PATCH 00/39] Second round of 64bit PowerPC little endian patches Anton Blanchard
2013-09-23 2:04 ` [PATCH 01/39] powerpc: Fix endian issues in VMX copy loops Anton Blanchard
2013-09-23 2:04 ` [PATCH 02/39] powerpc: Book 3S MMU little endian support Anton Blanchard
2013-09-23 2:04 ` [PATCH 03/39] powerpc: Fix offset of FPRs in VSX registers in little endian builds Anton Blanchard
2013-09-23 2:04 ` [PATCH 04/39] powerpc: PTRACE_PEEKUSR/PTRACE_POKEUSER of FPR " Anton Blanchard
2013-09-23 2:04 ` [PATCH 05/39] powerpc: Little endian builds double word swap VSX state during context save/restore Anton Blanchard
2013-09-23 2:04 ` [PATCH 06/39] powerpc: Support endian agnostic MMIO Anton Blanchard
2013-09-23 2:04 ` [PATCH 07/39] powerpc: Add little endian support for word-at-a-time functions Anton Blanchard
2013-09-23 2:04 ` [PATCH 08/39] powerpc: Set MSR_LE bit on little endian builds Anton Blanchard
2013-09-23 2:04 ` [PATCH 09/39] powerpc: Reset MSR_LE on signal entry Anton Blanchard
2013-09-23 2:04 ` [PATCH 10/39] powerpc: Include the appropriate endianness header Anton Blanchard
2013-09-23 2:04 ` [PATCH 11/39] powerpc: endian safe trampoline Anton Blanchard
2013-12-28 7:24 ` Olof Johansson
2013-12-28 7:58 ` Benjamin Herrenschmidt
2013-09-23 2:04 ` [PATCH 12/39] powerpc: Remove open coded byte swap macro in alignment handler Anton Blanchard
2013-09-23 2:04 ` [PATCH 13/39] powerpc: Remove hard coded FP offsets " Anton Blanchard
2013-09-23 2:04 ` [PATCH 14/39] powerpc: Alignment handler shouldn't access VSX registers with TS_FPR Anton Blanchard
2013-09-23 2:04 ` [PATCH 15/39] powerpc: Add little endian support to alignment handler Anton Blanchard
2013-09-23 2:04 ` [PATCH 16/39] powerpc: Handle VSX alignment faults in little endian mode Anton Blanchard
2013-09-23 2:04 ` [PATCH 17/39] powerpc: Use generic checksum code in little endian Anton Blanchard
2013-09-23 2:04 ` [PATCH 18/39] powerpc: Use generic memcpy " Anton Blanchard
2013-09-23 2:04 ` [PATCH 19/39] powerpc: uname should return ppc64le/ppcle on little endian builds Anton Blanchard
2013-09-23 2:04 ` [PATCH 20/39] powerpc: Little endian fixes for platforms/powernv/opal.c Anton Blanchard
2013-09-23 2:04 ` [PATCH 21/39] powerpc: Little endian fix for arch/powerpc/platforms/powernv/pci.c Anton Blanchard
2013-09-23 2:04 ` [PATCH 22/39] powerpc: Little endian fix for arch/powerpc/platforms/powernv/pci-p5ioc2.c Anton Blanchard
2013-09-23 2:04 ` [PATCH 23/39] powerpc: Little endian sparse clean up for arch/powerpc/platforms/powernv/pci-ioda.c Anton Blanchard
2013-09-23 2:04 ` [PATCH 24/39] powerpc/powernv: Fix endian issues in OPAL RTC driver Anton Blanchard
2013-09-23 2:04 ` [PATCH 25/39] powerpc/powernv: Fix endian issues in OPAL ICS backend Anton Blanchard
2013-09-23 2:05 ` [PATCH 26/39] powerpc/powernv: Make OPAL NVRAM device tree accesses endian safe Anton Blanchard
2013-09-23 2:05 ` [PATCH 27/39] powerpc/powernv: Fix endian issues in powernv PCI code Anton Blanchard
2013-09-23 2:05 ` [PATCH 28/39] powerpc/powernv: Fix endian issues in OPAL console and udbg backend Anton Blanchard
2013-09-23 2:05 ` [PATCH 29/39] powerpc/powernv: Fix OPAL entry and exit in little endian mode Anton Blanchard
2013-09-23 2:05 ` [PATCH 30/39] powerpc/powernv: Don't register exception handlers " Anton Blanchard
2013-09-23 2:05 ` [PATCH 31/39] powerpc/powernv: More little endian issues in OPAL RTC driver Anton Blanchard
2013-09-23 2:05 ` [PATCH 32/39] powerpc/powernv: Fix some PCI sparse errors and one LE bug Anton Blanchard
2013-09-23 2:05 ` Anton Blanchard [this message]
2013-09-23 2:05 ` [PATCH 34/39] tty/hvc_opal: powerpc: Make OPAL HVC device tree accesses endian safe Anton Blanchard
2013-09-23 2:05 ` [PATCH 35/39] KVM: PPC: Disable KVM on little endian builds Anton Blanchard
2013-09-23 2:05 ` [PATCH 36/39] powerpc/kvm/book3s_hv: Add little endian guest support Anton Blanchard
2013-09-25 12:10 ` [PATCH] powerpc/kvmbook3s_hv: propagate H_SET_MODE to the host Laurent Dufour
2013-09-25 12:27 ` Greg Kurz
2013-09-25 22:31 ` Paul Mackerras
2013-09-27 8:14 ` Laurent Dufour
2013-09-27 13:59 ` [PATCH V2] powerpc/kvm/book3s_hv: propagate H_SET_MODE_RESOURCE_LE " Laurent Dufour
2013-09-27 14:45 ` Greg Kurz
2013-09-30 18:40 ` [PATCH 36/39] powerpc/kvm/book3s_hv: Add little endian guest support Alexander Graf
2013-09-23 2:05 ` [PATCH 37/39] powerpc: Add ability to build little endian kernels Anton Blanchard
2013-09-23 2:05 ` [PATCH 38/39] powerpc: Don't set HAVE_EFFICIENT_UNALIGNED_ACCESS on little endian builds Anton Blanchard
2013-09-23 2:05 ` [PATCH 39/39] powerpc: Work around little endian gcc bug Anton Blanchard
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=1379901913-5945-34-git-send-email-anton@samba.org \
--to=anton@samba.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.org \
/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;
as well as URLs for NNTP newsgroup(s).