提交 af05b30b 编写于 作者: G Gustavo F. Padovan 提交者: Marcel Holtmann

Bluetooth: Fix errors and warnings in L2CAP reported by checkpatch.pl

This patch fixes the errors without changing the l2cap.o binary:

 text    data     bss     dec     hex filename
18059     568       0   18627    48c3 l2cap.o.after
18059     568       0   18627    48c3 l2cap.o.before
Signed-off-by: NGustavo F. Padovan <gustavo@las.ic.unicamp.br>
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
上级 44d0e48e
...@@ -40,10 +40,10 @@ ...@@ -40,10 +40,10 @@
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/uaccess.h>
#include <net/sock.h> #include <net/sock.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/uaccess.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include <net/bluetooth/bluetooth.h> #include <net/bluetooth/bluetooth.h>
...@@ -134,7 +134,8 @@ static inline struct sock *l2cap_get_chan_by_scid(struct l2cap_chan_list *l, u16 ...@@ -134,7 +134,8 @@ static inline struct sock *l2cap_get_chan_by_scid(struct l2cap_chan_list *l, u16
struct sock *s; struct sock *s;
read_lock(&l->lock); read_lock(&l->lock);
s = __l2cap_get_chan_by_scid(l, cid); s = __l2cap_get_chan_by_scid(l, cid);
if (s) bh_lock_sock(s); if (s)
bh_lock_sock(s);
read_unlock(&l->lock); read_unlock(&l->lock);
return s; return s;
} }
...@@ -154,7 +155,8 @@ static inline struct sock *l2cap_get_chan_by_ident(struct l2cap_chan_list *l, u8 ...@@ -154,7 +155,8 @@ static inline struct sock *l2cap_get_chan_by_ident(struct l2cap_chan_list *l, u8
struct sock *s; struct sock *s;
read_lock(&l->lock); read_lock(&l->lock);
s = __l2cap_get_chan_by_ident(l, ident); s = __l2cap_get_chan_by_ident(l, ident);
if (s) bh_lock_sock(s); if (s)
bh_lock_sock(s);
read_unlock(&l->lock); read_unlock(&l->lock);
return s; return s;
} }
...@@ -164,7 +166,7 @@ static u16 l2cap_alloc_cid(struct l2cap_chan_list *l) ...@@ -164,7 +166,7 @@ static u16 l2cap_alloc_cid(struct l2cap_chan_list *l)
u16 cid = L2CAP_CID_DYN_START; u16 cid = L2CAP_CID_DYN_START;
for (; cid < L2CAP_CID_DYN_END; cid++) { for (; cid < L2CAP_CID_DYN_END; cid++) {
if(!__l2cap_get_chan_by_scid(l, cid)) if (!__l2cap_get_chan_by_scid(l, cid))
return cid; return cid;
} }
...@@ -204,7 +206,8 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, struct so ...@@ -204,7 +206,8 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, struct so
{ {
struct l2cap_chan_list *l = &conn->chan_list; struct l2cap_chan_list *l = &conn->chan_list;
BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn, l2cap_pi(sk)->psm, l2cap_pi(sk)->dcid); BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn,
l2cap_pi(sk)->psm, l2cap_pi(sk)->dcid);
conn->disc_reason = 0x13; conn->disc_reason = 0x13;
...@@ -588,7 +591,8 @@ static inline struct sock *l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t ...@@ -588,7 +591,8 @@ static inline struct sock *l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t
struct sock *s; struct sock *s;
read_lock(&l2cap_sk_list.lock); read_lock(&l2cap_sk_list.lock);
s = __l2cap_get_sock_by_psm(state, psm, src); s = __l2cap_get_sock_by_psm(state, psm, src);
if (s) bh_lock_sock(s); if (s)
bh_lock_sock(s);
read_unlock(&l2cap_sk_list.lock); read_unlock(&l2cap_sk_list.lock);
return s; return s;
} }
...@@ -849,7 +853,8 @@ static int l2cap_do_connect(struct sock *sk) ...@@ -849,7 +853,8 @@ static int l2cap_do_connect(struct sock *sk)
BT_DBG("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst), BT_DBG("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst),
l2cap_pi(sk)->psm); l2cap_pi(sk)->psm);
if (!(hdev = hci_get_route(dst, src))) hdev = hci_get_route(dst, src);
if (!hdev)
return -EHOSTUNREACH; return -EHOSTUNREACH;
hci_dev_lock_bh(hdev); hci_dev_lock_bh(hdev);
...@@ -950,7 +955,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al ...@@ -950,7 +955,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
goto done; goto done;
} }
switch(sk->sk_state) { switch (sk->sk_state) {
case BT_CONNECT: case BT_CONNECT:
case BT_CONNECT2: case BT_CONNECT2:
case BT_CONFIG: case BT_CONFIG:
...@@ -975,7 +980,8 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al ...@@ -975,7 +980,8 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
bacpy(&bt_sk(sk)->dst, &la.l2_bdaddr); bacpy(&bt_sk(sk)->dst, &la.l2_bdaddr);
l2cap_pi(sk)->psm = la.l2_psm; l2cap_pi(sk)->psm = la.l2_psm;
if ((err = l2cap_do_connect(sk))) err = l2cap_do_connect(sk);
if (err)
goto done; goto done;
wait: wait:
...@@ -1114,7 +1120,7 @@ static inline int l2cap_do_send(struct sock *sk, struct msghdr *msg, int len) ...@@ -1114,7 +1120,7 @@ static inline int l2cap_do_send(struct sock *sk, struct msghdr *msg, int len)
{ {
struct l2cap_conn *conn = l2cap_pi(sk)->conn; struct l2cap_conn *conn = l2cap_pi(sk)->conn;
struct sk_buff *skb, **frag; struct sk_buff *skb, **frag;
int err, hlen, count, sent=0; int err, hlen, count, sent = 0;
struct l2cap_hdr *lh; struct l2cap_hdr *lh;
BT_DBG("sk %p len %d", sk, len); BT_DBG("sk %p len %d", sk, len);
...@@ -1167,8 +1173,8 @@ static inline int l2cap_do_send(struct sock *sk, struct msghdr *msg, int len) ...@@ -1167,8 +1173,8 @@ static inline int l2cap_do_send(struct sock *sk, struct msghdr *msg, int len)
frag = &(*frag)->next; frag = &(*frag)->next;
} }
err = hci_send_acl(conn->hcon, skb, 0);
if ((err = hci_send_acl(conn->hcon, skb, 0)) < 0) if (err < 0)
goto fail; goto fail;
return sent; return sent;
...@@ -1556,7 +1562,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb) ...@@ -1556,7 +1562,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
{ {
struct l2cap_chan_list *l = &conn->chan_list; struct l2cap_chan_list *l = &conn->chan_list;
struct sk_buff *nskb; struct sk_buff *nskb;
struct sock * sk; struct sock *sk;
BT_DBG("conn %p", conn); BT_DBG("conn %p", conn);
...@@ -1568,8 +1574,8 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb) ...@@ -1568,8 +1574,8 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
/* Don't send frame to the socket it came from */ /* Don't send frame to the socket it came from */
if (skb->sk == sk) if (skb->sk == sk)
continue; continue;
nskb = skb_clone(skb, GFP_ATOMIC);
if (!(nskb = skb_clone(skb, GFP_ATOMIC))) if (!nskb)
continue; continue;
if (sock_queue_rcv_skb(sk, nskb)) if (sock_queue_rcv_skb(sk, nskb))
...@@ -1587,7 +1593,8 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, ...@@ -1587,7 +1593,8 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
struct l2cap_hdr *lh; struct l2cap_hdr *lh;
int len, count; int len, count;
BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %d", conn, code, ident, dlen); BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %d",
conn, code, ident, dlen);
len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen; len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen;
count = min_t(unsigned int, conn->mtu, len); count = min_t(unsigned int, conn->mtu, len);
...@@ -1966,10 +1973,12 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd ...@@ -1966,10 +1973,12 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", dcid, scid, result, status); BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", dcid, scid, result, status);
if (scid) { if (scid) {
if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, scid))) sk = l2cap_get_chan_by_scid(&conn->chan_list, scid);
if (!sk)
return 0; return 0;
} else { } else {
if (!(sk = l2cap_get_chan_by_ident(&conn->chan_list, cmd->ident))) sk = l2cap_get_chan_by_ident(&conn->chan_list, cmd->ident);
if (!sk)
return 0; return 0;
} }
...@@ -2012,7 +2021,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr ...@@ -2012,7 +2021,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
BT_DBG("dcid 0x%4.4x flags 0x%2.2x", dcid, flags); BT_DBG("dcid 0x%4.4x flags 0x%2.2x", dcid, flags);
if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, dcid))) sk = l2cap_get_chan_by_scid(&conn->chan_list, dcid);
if (!sk)
return -ENOENT; return -ENOENT;
if (sk->sk_state == BT_DISCONN) if (sk->sk_state == BT_DISCONN)
...@@ -2079,9 +2089,11 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr ...@@ -2079,9 +2089,11 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
flags = __le16_to_cpu(rsp->flags); flags = __le16_to_cpu(rsp->flags);
result = __le16_to_cpu(rsp->result); result = __le16_to_cpu(rsp->result);
BT_DBG("scid 0x%4.4x flags 0x%2.2x result 0x%2.2x", scid, flags, result); BT_DBG("scid 0x%4.4x flags 0x%2.2x result 0x%2.2x",
scid, flags, result);
if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, scid))) sk = l2cap_get_chan_by_scid(&conn->chan_list, scid);
if (!sk)
return 0; return 0;
switch (result) { switch (result) {
...@@ -2142,7 +2154,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd ...@@ -2142,7 +2154,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd
BT_DBG("scid 0x%4.4x dcid 0x%4.4x", scid, dcid); BT_DBG("scid 0x%4.4x dcid 0x%4.4x", scid, dcid);
if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, dcid))) sk = l2cap_get_chan_by_scid(&conn->chan_list, dcid);
if (!sk)
return 0; return 0;
rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid);
...@@ -2169,7 +2182,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd ...@@ -2169,7 +2182,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd
BT_DBG("dcid 0x%4.4x scid 0x%4.4x", dcid, scid); BT_DBG("dcid 0x%4.4x scid 0x%4.4x", dcid, scid);
if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, scid))) sk = l2cap_get_chan_by_scid(&conn->chan_list, scid);
if (!sk)
return 0; return 0;
l2cap_chan_del(sk, 0); l2cap_chan_del(sk, 0);
...@@ -2403,7 +2417,8 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str ...@@ -2403,7 +2417,8 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str
kfree_skb(skb); kfree_skb(skb);
done: done:
if (sk) bh_unlock_sock(sk); if (sk)
bh_unlock_sock(sk);
return 0; return 0;
} }
...@@ -2650,7 +2665,8 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl ...@@ -2650,7 +2665,8 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
} }
/* Allocate skb for the complete frame (with header) */ /* Allocate skb for the complete frame (with header) */
if (!(conn->rx_skb = bt_skb_alloc(len, GFP_ATOMIC))) conn->rx_skb = bt_skb_alloc(len, GFP_ATOMIC);
if (!conn->rx_skb)
goto drop; goto drop;
skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len),
...@@ -2710,7 +2726,7 @@ static ssize_t l2cap_sysfs_show(struct class *dev, char *buf) ...@@ -2710,7 +2726,7 @@ static ssize_t l2cap_sysfs_show(struct class *dev, char *buf)
read_unlock_bh(&l2cap_sk_list.lock); read_unlock_bh(&l2cap_sk_list.lock);
return (str - buf); return str - buf;
} }
static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL); static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册