Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
99fc1d91
Commit
99fc1d91
authored
Sep 23, 2013
by
Benjamin Herrenschmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
powerpc/hvsi: Fix endian issues in HVSI driver
Signed-off-by:
Benjamin Herrenschmidt
<
benh@kernel.crashing.org
>
parent
5e4da530
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
21 deletions
+20
-21
arch/powerpc/include/asm/hvsi.h
arch/powerpc/include/asm/hvsi.h
+8
-8
drivers/tty/hvc/hvsi_lib.c
drivers/tty/hvc/hvsi_lib.c
+12
-13
No files found.
arch/powerpc/include/asm/hvsi.h
View file @
99fc1d91
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
struct
hvsi_header
{
struct
hvsi_header
{
uint8_t
type
;
uint8_t
type
;
uint8_t
len
;
uint8_t
len
;
uint16_t
seqno
;
__be16
seqno
;
}
__attribute__
((
packed
));
}
__attribute__
((
packed
));
struct
hvsi_data
{
struct
hvsi_data
{
...
@@ -35,24 +35,24 @@ struct hvsi_data {
...
@@ -35,24 +35,24 @@ struct hvsi_data {
struct
hvsi_control
{
struct
hvsi_control
{
struct
hvsi_header
hdr
;
struct
hvsi_header
hdr
;
uint16_t
verb
;
__be16
verb
;
/* optional depending on verb: */
/* optional depending on verb: */
uint32_t
word
;
__be32
word
;
uint32_t
mask
;
__be32
mask
;
}
__attribute__
((
packed
));
}
__attribute__
((
packed
));
struct
hvsi_query
{
struct
hvsi_query
{
struct
hvsi_header
hdr
;
struct
hvsi_header
hdr
;
uint16_t
verb
;
__be16
verb
;
}
__attribute__
((
packed
));
}
__attribute__
((
packed
));
struct
hvsi_query_response
{
struct
hvsi_query_response
{
struct
hvsi_header
hdr
;
struct
hvsi_header
hdr
;
uint16_t
verb
;
__be16
verb
;
uint16_t
query_seqno
;
__be16
query_seqno
;
union
{
union
{
uint8_t
version
;
uint8_t
version
;
uint32_t
mctrl_word
;
__be32
mctrl_word
;
}
u
;
}
u
;
}
__attribute__
((
packed
));
}
__attribute__
((
packed
));
...
...
drivers/tty/hvc/hvsi_lib.c
View file @
99fc1d91
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
static
int
hvsi_send_packet
(
struct
hvsi_priv
*
pv
,
struct
hvsi_header
*
packet
)
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 */
/* Assumes that always succeeds, works in practice */
return
pv
->
put_chars
(
pv
->
termno
,
(
char
*
)
packet
,
packet
->
len
);
return
pv
->
put_chars
(
pv
->
termno
,
(
char
*
)
packet
,
packet
->
len
);
...
@@ -28,7 +28,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
...
@@ -28,7 +28,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
/* Send version query */
/* Send version query */
q
.
hdr
.
type
=
VS_QUERY_PACKET_HEADER
;
q
.
hdr
.
type
=
VS_QUERY_PACKET_HEADER
;
q
.
hdr
.
len
=
sizeof
(
struct
hvsi_query
);
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
);
hvsi_send_packet
(
pv
,
&
q
.
hdr
);
}
}
...
@@ -40,7 +40,7 @@ static int hvsi_send_close(struct hvsi_priv *pv)
...
@@ -40,7 +40,7 @@ static int hvsi_send_close(struct hvsi_priv *pv)
ctrl
.
hdr
.
type
=
VS_CONTROL_PACKET_HEADER
;
ctrl
.
hdr
.
type
=
VS_CONTROL_PACKET_HEADER
;
ctrl
.
hdr
.
len
=
sizeof
(
struct
hvsi_control
);
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
);
return
hvsi_send_packet
(
pv
,
&
ctrl
.
hdr
);
}
}
...
@@ -69,14 +69,14 @@ static void hvsi_got_control(struct hvsi_priv *pv)
...
@@ -69,14 +69,14 @@ static void hvsi_got_control(struct hvsi_priv *pv)
{
{
struct
hvsi_control
*
pkt
=
(
struct
hvsi_control
*
)
pv
->
inbuf
;
struct
hvsi_control
*
pkt
=
(
struct
hvsi_control
*
)
pv
->
inbuf
;
switch
(
pkt
->
verb
)
{
switch
(
be16_to_cpu
(
pkt
->
verb
)
)
{
case
VSV_CLOSE_PROTOCOL
:
case
VSV_CLOSE_PROTOCOL
:
/* We restart the handshaking */
/* We restart the handshaking */
hvsi_start_handshake
(
pv
);
hvsi_start_handshake
(
pv
);
break
;
break
;
case
VSV_MODEM_CTL_UPDATE
:
case
VSV_MODEM_CTL_UPDATE
:
/* Transition of carrier detect */
/* Transition of carrier detect */
hvsi_cd_change
(
pv
,
pkt
->
word
&
HVSI_TSCD
);
hvsi_cd_change
(
pv
,
be32_to_cpu
(
pkt
->
word
)
&
HVSI_TSCD
);
break
;
break
;
}
}
}
}
...
@@ -87,7 +87,7 @@ static void hvsi_got_query(struct hvsi_priv *pv)
...
@@ -87,7 +87,7 @@ static void hvsi_got_query(struct hvsi_priv *pv)
struct
hvsi_query_response
r
;
struct
hvsi_query_response
r
;
/* We only handle version queries */
/* We only handle version queries */
if
(
pkt
->
verb
!=
VSV_SEND_VERSION_NUMBER
)
if
(
be16_to_cpu
(
pkt
->
verb
)
!=
VSV_SEND_VERSION_NUMBER
)
return
;
return
;
pr_devel
(
"HVSI@%x: Got version query, sending response...
\n
"
,
pr_devel
(
"HVSI@%x: Got version query, sending response...
\n
"
,
...
@@ -96,7 +96,7 @@ static void hvsi_got_query(struct hvsi_priv *pv)
...
@@ -96,7 +96,7 @@ static void hvsi_got_query(struct hvsi_priv *pv)
/* Send version response */
/* Send version response */
r
.
hdr
.
type
=
VS_QUERY_RESPONSE_PACKET_HEADER
;
r
.
hdr
.
type
=
VS_QUERY_RESPONSE_PACKET_HEADER
;
r
.
hdr
.
len
=
sizeof
(
struct
hvsi_query_response
);
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
.
u
.
version
=
HVSI_VERSION
;
r
.
query_seqno
=
pkt
->
hdr
.
seqno
;
r
.
query_seqno
=
pkt
->
hdr
.
seqno
;
hvsi_send_packet
(
pv
,
&
r
.
hdr
);
hvsi_send_packet
(
pv
,
&
r
.
hdr
);
...
@@ -112,7 +112,7 @@ static void hvsi_got_response(struct hvsi_priv *pv)
...
@@ -112,7 +112,7 @@ static void hvsi_got_response(struct hvsi_priv *pv)
switch
(
r
->
verb
)
{
switch
(
r
->
verb
)
{
case
VSV_SEND_MODEM_CTL_STATUS
:
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
;
pv
->
mctrl_update
=
1
;
break
;
break
;
}
}
...
@@ -265,8 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
...
@@ -265,8 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
pv
->
mctrl_update
=
0
;
pv
->
mctrl_update
=
0
;
q
.
hdr
.
type
=
VS_QUERY_PACKET_HEADER
;
q
.
hdr
.
type
=
VS_QUERY_PACKET_HEADER
;
q
.
hdr
.
len
=
sizeof
(
struct
hvsi_query
);
q
.
hdr
.
len
=
sizeof
(
struct
hvsi_query
);
q
.
hdr
.
seqno
=
atomic_inc_return
(
&
pv
->
seqno
);
q
.
verb
=
cpu_to_be16
(
VSV_SEND_MODEM_CTL_STATUS
);
q
.
verb
=
VSV_SEND_MODEM_CTL_STATUS
;
rc
=
hvsi_send_packet
(
pv
,
&
q
.
hdr
);
rc
=
hvsi_send_packet
(
pv
,
&
q
.
hdr
);
if
(
rc
<=
0
)
{
if
(
rc
<=
0
)
{
pr_devel
(
"HVSI@%x: Error %d...
\n
"
,
pv
->
termno
,
rc
);
pr_devel
(
"HVSI@%x: Error %d...
\n
"
,
pv
->
termno
,
rc
);
...
@@ -304,9 +303,9 @@ int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr)
...
@@ -304,9 +303,9 @@ int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr)
ctrl
.
hdr
.
type
=
VS_CONTROL_PACKET_HEADER
,
ctrl
.
hdr
.
type
=
VS_CONTROL_PACKET_HEADER
,
ctrl
.
hdr
.
len
=
sizeof
(
struct
hvsi_control
);
ctrl
.
hdr
.
len
=
sizeof
(
struct
hvsi_control
);
ctrl
.
verb
=
VSV_SET_MODEM_CTL
;
ctrl
.
verb
=
cpu_to_be16
(
VSV_SET_MODEM_CTL
)
;
ctrl
.
mask
=
HVSI_TSDTR
;
ctrl
.
mask
=
cpu_to_be32
(
HVSI_TSDTR
)
;
ctrl
.
word
=
dtr
?
HVSI_TSDTR
:
0
;
ctrl
.
word
=
cpu_to_be32
(
dtr
?
HVSI_TSDTR
:
0
)
;
return
hvsi_send_packet
(
pv
,
&
ctrl
.
hdr
);
return
hvsi_send_packet
(
pv
,
&
ctrl
.
hdr
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment