aboutsummaryrefslogtreecommitdiff
path: root/hw/bt/l2cap.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-07-07 17:20:57 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-07-12 15:08:53 +0100
commit43120576cb6a9db070fd300da69fe61f5e5cc281 (patch)
treec29ccb78cff18d7dc77ab52edff3d97aa23076ef /hw/bt/l2cap.c
parentb442642da145cb10293f577f3b43bda8beeb31cf (diff)
downloadqemu-43120576cb6a9db070fd300da69fe61f5e5cc281.zip
qemu-43120576cb6a9db070fd300da69fe61f5e5cc281.tar.gz
qemu-43120576cb6a9db070fd300da69fe61f5e5cc281.tar.bz2
hw/bt: Don't use cpu_to_*w() and *_to_cpup()
Don't use cpu_to_*w() and *_to_cpup() to do byte-swapped loads and stores; instead use ld*_p() and st*_p() which correctly handle misaligned accesses. Bring the HNDL() macro into line with how we deal with PARAMHANDLE(), by using cpu_to_le16() rather than an ifdef HOST_WORDS_BIGENDIAN. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1467908460-27048-3-git-send-email-peter.maydell@linaro.org
Diffstat (limited to 'hw/bt/l2cap.c')
-rw-r--r--hw/bt/l2cap.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/hw/bt/l2cap.c b/hw/bt/l2cap.c
index dfc95ed..e342045 100644
--- a/hw/bt/l2cap.c
+++ b/hw/bt/l2cap.c
@@ -526,9 +526,9 @@ static int l2cap_channel_config(struct l2cap_instance_s *l2cap,
}
/* MTU */
- val = le16_to_cpup((void *) opt->val);
+ val = lduw_le_p(opt->val);
if (val < ch->min_mtu) {
- cpu_to_le16w((void *) opt->val, ch->min_mtu);
+ stw_le_p(opt->val, ch->min_mtu);
result = L2CAP_CONF_UNACCEPT;
break;
}
@@ -543,7 +543,7 @@ static int l2cap_channel_config(struct l2cap_instance_s *l2cap,
}
/* Flush Timeout */
- val = le16_to_cpup((void *) opt->val);
+ val = lduw_le_p(opt->val);
if (val < 0x0001) {
opt->val[0] = 0xff;
opt->val[1] = 0xff;
@@ -987,7 +987,7 @@ static void l2cap_bframe_in(struct l2cap_chan_s *ch, uint16_t cid,
static void l2cap_iframe_in(struct l2cap_chan_s *ch, uint16_t cid,
const l2cap_hdr *hdr, int len)
{
- uint16_t fcs = le16_to_cpup((void *) (hdr->data + len - 2));
+ uint16_t fcs = lduw_le_p(hdr->data + len - 2);
if (len < 4)
goto len_error;
@@ -1002,7 +1002,7 @@ static void l2cap_iframe_in(struct l2cap_chan_s *ch, uint16_t cid,
/* TODO: Signal an error? */
return;
}
- l2cap_sframe_in(ch, le16_to_cpup((void *) hdr->data));
+ l2cap_sframe_in(ch, lduw_le_p(hdr->data));
return;
}
@@ -1022,7 +1022,7 @@ static void l2cap_iframe_in(struct l2cap_chan_s *ch, uint16_t cid,
if (len - 6 > ch->mps)
goto len_error;
- ch->len_total = le16_to_cpup((void *) (hdr->data + 2));
+ ch->len_total = lduw_le_p(hdr->data + 2);
if (len >= 6 + ch->len_total)
goto seg_error;