Bluetooth: Remove pointless endian conversion helpers
The Bluetooth source uses some endian conversion helpers, that in the end translate to kernel standard routines. So remove this obfuscation since it is fully pointless. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
47ec1dcd69
commit
b4324b5dc5
|
@ -81,12 +81,6 @@ enum {
|
||||||
BT_CLOSED
|
BT_CLOSED
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Endianness conversions */
|
|
||||||
#define htobs(a) __cpu_to_le16(a)
|
|
||||||
#define htobl(a) __cpu_to_le32(a)
|
|
||||||
#define btohs(a) __le16_to_cpu(a)
|
|
||||||
#define btohl(a) __le32_to_cpu(a)
|
|
||||||
|
|
||||||
/* BD Address */
|
/* BD Address */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
__u8 b[6];
|
__u8 b[6];
|
||||||
|
|
|
@ -812,7 +812,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (la.l2_psm && btohs(la.l2_psm) < 0x1001 &&
|
if (la.l2_psm && __le16_to_cpu(la.l2_psm) < 0x1001 &&
|
||||||
!capable(CAP_NET_BIND_SERVICE)) {
|
!capable(CAP_NET_BIND_SERVICE)) {
|
||||||
err = -EACCES;
|
err = -EACCES;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -829,7 +829,8 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
|
||||||
l2cap_pi(sk)->sport = la.l2_psm;
|
l2cap_pi(sk)->sport = la.l2_psm;
|
||||||
sk->sk_state = BT_BOUND;
|
sk->sk_state = BT_BOUND;
|
||||||
|
|
||||||
if (btohs(la.l2_psm) == 0x0001 || btohs(la.l2_psm) == 0x0003)
|
if (__le16_to_cpu(la.l2_psm) == 0x0001 ||
|
||||||
|
__le16_to_cpu(la.l2_psm) == 0x0003)
|
||||||
l2cap_pi(sk)->sec_level = BT_SECURITY_SDP;
|
l2cap_pi(sk)->sec_level = BT_SECURITY_SDP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1015,9 +1016,9 @@ static int l2cap_sock_listen(struct socket *sock, int backlog)
|
||||||
write_lock_bh(&l2cap_sk_list.lock);
|
write_lock_bh(&l2cap_sk_list.lock);
|
||||||
|
|
||||||
for (psm = 0x1001; psm < 0x1100; psm += 2)
|
for (psm = 0x1001; psm < 0x1100; psm += 2)
|
||||||
if (!__l2cap_get_sock_by_addr(htobs(psm), src)) {
|
if (!__l2cap_get_sock_by_addr(cpu_to_le16(psm), src)) {
|
||||||
l2cap_pi(sk)->psm = htobs(psm);
|
l2cap_pi(sk)->psm = cpu_to_le16(psm);
|
||||||
l2cap_pi(sk)->sport = htobs(psm);
|
l2cap_pi(sk)->sport = cpu_to_le16(psm);
|
||||||
err = 0;
|
err = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1106,11 +1107,11 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l
|
||||||
if (peer) {
|
if (peer) {
|
||||||
la->l2_psm = l2cap_pi(sk)->psm;
|
la->l2_psm = l2cap_pi(sk)->psm;
|
||||||
bacpy(&la->l2_bdaddr, &bt_sk(sk)->dst);
|
bacpy(&la->l2_bdaddr, &bt_sk(sk)->dst);
|
||||||
la->l2_cid = htobs(l2cap_pi(sk)->dcid);
|
la->l2_cid = cpu_to_le16(l2cap_pi(sk)->dcid);
|
||||||
} else {
|
} else {
|
||||||
la->l2_psm = l2cap_pi(sk)->sport;
|
la->l2_psm = l2cap_pi(sk)->sport;
|
||||||
bacpy(&la->l2_bdaddr, &bt_sk(sk)->src);
|
bacpy(&la->l2_bdaddr, &bt_sk(sk)->src);
|
||||||
la->l2_cid = htobs(l2cap_pi(sk)->scid);
|
la->l2_cid = cpu_to_le16(l2cap_pi(sk)->scid);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2720,8 +2721,8 @@ static ssize_t l2cap_sysfs_show(struct class *dev, char *buf)
|
||||||
|
|
||||||
str += sprintf(str, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n",
|
str += sprintf(str, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n",
|
||||||
batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
|
batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
|
||||||
sk->sk_state, btohs(pi->psm), pi->scid, pi->dcid,
|
sk->sk_state, __le16_to_cpu(pi->psm), pi->scid,
|
||||||
pi->imtu, pi->omtu, pi->sec_level);
|
pi->dcid, pi->imtu, pi->omtu, pi->sec_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
read_unlock_bh(&l2cap_sk_list.lock);
|
read_unlock_bh(&l2cap_sk_list.lock);
|
||||||
|
|
|
@ -679,7 +679,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, bdaddr_t *dst
|
||||||
|
|
||||||
bacpy(&addr.l2_bdaddr, dst);
|
bacpy(&addr.l2_bdaddr, dst);
|
||||||
addr.l2_family = AF_BLUETOOTH;
|
addr.l2_family = AF_BLUETOOTH;
|
||||||
addr.l2_psm = htobs(RFCOMM_PSM);
|
addr.l2_psm = cpu_to_le16(RFCOMM_PSM);
|
||||||
addr.l2_cid = 0;
|
addr.l2_cid = 0;
|
||||||
*err = kernel_connect(sock, (struct sockaddr *) &addr, sizeof(addr), O_NONBLOCK);
|
*err = kernel_connect(sock, (struct sockaddr *) &addr, sizeof(addr), O_NONBLOCK);
|
||||||
if (*err == 0 || *err == -EINPROGRESS)
|
if (*err == 0 || *err == -EINPROGRESS)
|
||||||
|
@ -852,9 +852,9 @@ static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cr && channel_mtu >= 0)
|
if (cr && channel_mtu >= 0)
|
||||||
pn->mtu = htobs(channel_mtu);
|
pn->mtu = cpu_to_le16(channel_mtu);
|
||||||
else
|
else
|
||||||
pn->mtu = htobs(d->mtu);
|
pn->mtu = cpu_to_le16(d->mtu);
|
||||||
|
|
||||||
*ptr = __fcs(buf); ptr++;
|
*ptr = __fcs(buf); ptr++;
|
||||||
|
|
||||||
|
@ -1056,7 +1056,7 @@ static void rfcomm_make_uih(struct sk_buff *skb, u8 addr)
|
||||||
|
|
||||||
if (len > 127) {
|
if (len > 127) {
|
||||||
hdr = (void *) skb_push(skb, 4);
|
hdr = (void *) skb_push(skb, 4);
|
||||||
put_unaligned(htobs(__len16(len)), (__le16 *) &hdr->len);
|
put_unaligned(cpu_to_le16(__len16(len)), (__le16 *) &hdr->len);
|
||||||
} else {
|
} else {
|
||||||
hdr = (void *) skb_push(skb, 3);
|
hdr = (void *) skb_push(skb, 3);
|
||||||
hdr->len = __len8(len);
|
hdr->len = __len8(len);
|
||||||
|
@ -1289,7 +1289,7 @@ static int rfcomm_apply_pn(struct rfcomm_dlc *d, int cr, struct rfcomm_pn *pn)
|
||||||
|
|
||||||
d->priority = pn->priority;
|
d->priority = pn->priority;
|
||||||
|
|
||||||
d->mtu = btohs(pn->mtu);
|
d->mtu = __le16_to_cpu(pn->mtu);
|
||||||
|
|
||||||
if (cr && d->mtu > s->mtu)
|
if (cr && d->mtu > s->mtu)
|
||||||
d->mtu = s->mtu;
|
d->mtu = s->mtu;
|
||||||
|
@ -1922,7 +1922,7 @@ static int rfcomm_add_listener(bdaddr_t *ba)
|
||||||
/* Bind socket */
|
/* Bind socket */
|
||||||
bacpy(&addr.l2_bdaddr, ba);
|
bacpy(&addr.l2_bdaddr, ba);
|
||||||
addr.l2_family = AF_BLUETOOTH;
|
addr.l2_family = AF_BLUETOOTH;
|
||||||
addr.l2_psm = htobs(RFCOMM_PSM);
|
addr.l2_psm = cpu_to_le16(RFCOMM_PSM);
|
||||||
addr.l2_cid = 0;
|
addr.l2_cid = 0;
|
||||||
err = kernel_bind(sock, (struct sockaddr *) &addr, sizeof(addr));
|
err = kernel_bind(sock, (struct sockaddr *) &addr, sizeof(addr));
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
|
|
Loading…
Reference in a new issue