Commit 2d792818 authored by Gustavo Padovan's avatar Gustavo Padovan

Bluetooth: Fix L2CAP coding style

Follow the net subsystem coding style
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent 4c89b6aa
...@@ -60,7 +60,8 @@ static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control, ...@@ -60,7 +60,8 @@ static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control,
/* ---- L2CAP channels ---- */ /* ---- L2CAP channels ---- */
static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16 cid) static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn,
u16 cid)
{ {
struct l2cap_chan *c; struct l2cap_chan *c;
...@@ -71,7 +72,8 @@ static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16 ...@@ -71,7 +72,8 @@ static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16
return NULL; return NULL;
} }
static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 cid) static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn,
u16 cid)
{ {
struct l2cap_chan *c; struct l2cap_chan *c;
...@@ -84,7 +86,8 @@ static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ...@@ -84,7 +86,8 @@ static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16
/* Find channel with given SCID. /* Find channel with given SCID.
* Returns locked channel. */ * Returns locked channel. */
static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 cid) static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn,
u16 cid)
{ {
struct l2cap_chan *c; struct l2cap_chan *c;
...@@ -97,7 +100,8 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ci ...@@ -97,7 +100,8 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ci
return c; return c;
} }
static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn, u8 ident) static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn,
u8 ident)
{ {
struct l2cap_chan *c; struct l2cap_chan *c;
...@@ -573,8 +577,8 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) ...@@ -573,8 +577,8 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
struct l2cap_conn *conn = chan->conn; struct l2cap_conn *conn = chan->conn;
struct sock *sk = chan->sk; struct sock *sk = chan->sk;
BT_DBG("chan %p state %s sk %p", chan, BT_DBG("chan %p state %s sk %p", chan, state_to_string(chan->state),
state_to_string(chan->state), sk); sk);
switch (chan->state) { switch (chan->state) {
case BT_LISTEN: case BT_LISTEN:
...@@ -691,7 +695,8 @@ static u8 l2cap_get_ident(struct l2cap_conn *conn) ...@@ -691,7 +695,8 @@ static u8 l2cap_get_ident(struct l2cap_conn *conn)
return id; return id;
} }
static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data) static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len,
void *data)
{ {
struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data); struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
u8 flags; u8 flags;
...@@ -1020,8 +1025,8 @@ static void l2cap_do_start(struct l2cap_chan *chan) ...@@ -1020,8 +1025,8 @@ static void l2cap_do_start(struct l2cap_chan *chan)
schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT); schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT);
l2cap_send_cmd(conn, conn->info_ident, l2cap_send_cmd(conn, conn->info_ident, L2CAP_INFO_REQ,
L2CAP_INFO_REQ, sizeof(req), &req); sizeof(req), &req);
} }
} }
...@@ -1041,7 +1046,8 @@ static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask) ...@@ -1041,7 +1046,8 @@ static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask)
} }
} }
static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err) static void l2cap_send_disconn_req(struct l2cap_conn *conn,
struct l2cap_chan *chan, int err)
{ {
struct sock *sk = chan->sk; struct sock *sk = chan->sk;
struct l2cap_disconn_req req; struct l2cap_disconn_req req;
...@@ -1062,8 +1068,8 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *c ...@@ -1062,8 +1068,8 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *c
req.dcid = cpu_to_le16(chan->dcid); req.dcid = cpu_to_le16(chan->dcid);
req.scid = cpu_to_le16(chan->scid); req.scid = cpu_to_le16(chan->scid);
l2cap_send_cmd(conn, l2cap_get_ident(conn), l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_DISCONN_REQ,
L2CAP_DISCONN_REQ, sizeof(req), &req); sizeof(req), &req);
lock_sock(sk); lock_sock(sk);
__l2cap_state_change(chan, BT_DISCONN); __l2cap_state_change(chan, BT_DISCONN);
...@@ -2653,7 +2659,8 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, u8 code, ...@@ -2653,7 +2659,8 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, u8 code,
return NULL; return NULL;
} }
static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned long *val) static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen,
unsigned long *val)
{ {
struct l2cap_conf_opt *opt = *ptr; struct l2cap_conf_opt *opt = *ptr;
int len; int len;
...@@ -2900,8 +2907,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) ...@@ -2900,8 +2907,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
rfc.monitor_timeout = 0; rfc.monitor_timeout = 0;
size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu -
L2CAP_EXT_HDR_SIZE - L2CAP_EXT_HDR_SIZE - L2CAP_SDULEN_SIZE -
L2CAP_SDULEN_SIZE -
L2CAP_FCS_SIZE); L2CAP_FCS_SIZE);
rfc.max_pdu_size = cpu_to_le16(size); rfc.max_pdu_size = cpu_to_le16(size);
...@@ -2939,8 +2945,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) ...@@ -2939,8 +2945,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
rfc.monitor_timeout = 0; rfc.monitor_timeout = 0;
size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu -
L2CAP_EXT_HDR_SIZE - L2CAP_EXT_HDR_SIZE - L2CAP_SDULEN_SIZE -
L2CAP_SDULEN_SIZE -
L2CAP_FCS_SIZE); L2CAP_FCS_SIZE);
rfc.max_pdu_size = cpu_to_le16(size); rfc.max_pdu_size = cpu_to_le16(size);
...@@ -3071,8 +3076,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) ...@@ -3071,8 +3076,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
if (chan->num_conf_rsp == 1) if (chan->num_conf_rsp == 1)
return -ECONNREFUSED; return -ECONNREFUSED;
l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
sizeof(rfc), (unsigned long) &rfc); (unsigned long) &rfc);
} }
if (result == L2CAP_CONF_SUCCESS) { if (result == L2CAP_CONF_SUCCESS) {
...@@ -3122,10 +3127,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) ...@@ -3122,10 +3127,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
chan->remote_max_tx = rfc.max_transmit; chan->remote_max_tx = rfc.max_transmit;
size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), size = min_t(u16, le16_to_cpu(rfc.max_pdu_size),
chan->conn->mtu - chan->conn->mtu - L2CAP_EXT_HDR_SIZE -
L2CAP_EXT_HDR_SIZE - L2CAP_SDULEN_SIZE - L2CAP_FCS_SIZE);
L2CAP_SDULEN_SIZE -
L2CAP_FCS_SIZE);
rfc.max_pdu_size = cpu_to_le16(size); rfc.max_pdu_size = cpu_to_le16(size);
chan->remote_mps = size; chan->remote_mps = size;
...@@ -3150,23 +3153,22 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) ...@@ -3150,23 +3153,22 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
chan->remote_sdu_itime = chan->remote_sdu_itime =
le32_to_cpu(efs.sdu_itime); le32_to_cpu(efs.sdu_itime);
l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS,
sizeof(efs), (unsigned long) &efs); sizeof(efs),
(unsigned long) &efs);
} }
break; break;
case L2CAP_MODE_STREAMING: case L2CAP_MODE_STREAMING:
size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), size = min_t(u16, le16_to_cpu(rfc.max_pdu_size),
chan->conn->mtu - chan->conn->mtu - L2CAP_EXT_HDR_SIZE -
L2CAP_EXT_HDR_SIZE - L2CAP_SDULEN_SIZE - L2CAP_FCS_SIZE);
L2CAP_SDULEN_SIZE -
L2CAP_FCS_SIZE);
rfc.max_pdu_size = cpu_to_le16(size); rfc.max_pdu_size = cpu_to_le16(size);
chan->remote_mps = size; chan->remote_mps = size;
set_bit(CONF_MODE_DONE, &chan->conf_state); set_bit(CONF_MODE_DONE, &chan->conf_state);
l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
sizeof(rfc), (unsigned long) &rfc); (unsigned long) &rfc);
break; break;
...@@ -3187,7 +3189,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) ...@@ -3187,7 +3189,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
return ptr - data; return ptr - data;
} }
static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, void *data, u16 *result) static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
void *data, u16 *result)
{ {
struct l2cap_conf_req *req = data; struct l2cap_conf_req *req = data;
void *ptr = req->data; void *ptr = req->data;
...@@ -3246,8 +3249,8 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi ...@@ -3246,8 +3249,8 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
efs.stype != chan->local_stype) efs.stype != chan->local_stype)
return -ECONNREFUSED; return -ECONNREFUSED;
l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, sizeof(efs),
sizeof(efs), (unsigned long) &efs); (unsigned long) &efs);
break; break;
} }
} }
...@@ -3288,7 +3291,8 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi ...@@ -3288,7 +3291,8 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
return ptr - data; return ptr - data;
} }
static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data, u16 result, u16 flags) static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data,
u16 result, u16 flags)
{ {
struct l2cap_conf_rsp *rsp = data; struct l2cap_conf_rsp *rsp = data;
void *ptr = rsp->data; void *ptr = rsp->data;
...@@ -3312,8 +3316,7 @@ void __l2cap_connect_rsp_defer(struct l2cap_chan *chan) ...@@ -3312,8 +3316,7 @@ void __l2cap_connect_rsp_defer(struct l2cap_chan *chan)
rsp.dcid = cpu_to_le16(chan->scid); rsp.dcid = cpu_to_le16(chan->scid);
rsp.result = __constant_cpu_to_le16(L2CAP_CR_SUCCESS); rsp.result = __constant_cpu_to_le16(L2CAP_CR_SUCCESS);
rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO);
l2cap_send_cmd(conn, chan->ident, l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
L2CAP_CONN_RSP, sizeof(rsp), &rsp);
if (test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) if (test_and_set_bit(CONF_REQ_SENT, &chan->conf_state))
return; return;
...@@ -3374,7 +3377,8 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len) ...@@ -3374,7 +3377,8 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len)
} }
} }
static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) static inline int l2cap_command_rej(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd, u8 *data)
{ {
struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data; struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data;
...@@ -3500,8 +3504,8 @@ static void __l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, ...@@ -3500,8 +3504,8 @@ static void __l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd,
schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT); schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT);
l2cap_send_cmd(conn, conn->info_ident, l2cap_send_cmd(conn, conn->info_ident, L2CAP_INFO_REQ,
L2CAP_INFO_REQ, sizeof(info), &info); sizeof(info), &info);
} }
if (chan && !test_bit(CONF_REQ_SENT, &chan->conf_state) && if (chan && !test_bit(CONF_REQ_SENT, &chan->conf_state) &&
...@@ -3521,7 +3525,8 @@ static int l2cap_connect_req(struct l2cap_conn *conn, ...@@ -3521,7 +3525,8 @@ static int l2cap_connect_req(struct l2cap_conn *conn,
return 0; return 0;
} }
static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) static inline int l2cap_connect_rsp(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd, u8 *data)
{ {
struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data; struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data;
u16 scid, dcid, result, status; u16 scid, dcid, result, status;
...@@ -3616,7 +3621,9 @@ static void l2cap_send_efs_conf_rsp(struct l2cap_chan *chan, void *data, ...@@ -3616,7 +3621,9 @@ static void l2cap_send_efs_conf_rsp(struct l2cap_chan *chan, void *data,
L2CAP_CONF_SUCCESS, flags), data); L2CAP_CONF_SUCCESS, flags), data);
} }
static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data) static inline int l2cap_config_req(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd, u16 cmd_len,
u8 *data)
{ {
struct l2cap_conf_req *req = (struct l2cap_conf_req *) data; struct l2cap_conf_req *req = (struct l2cap_conf_req *) data;
u16 dcid, flags; u16 dcid, flags;
...@@ -3719,7 +3726,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr ...@@ -3719,7 +3726,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
return err; return err;
} }
static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) static inline int l2cap_config_rsp(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd, u8 *data)
{ {
struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data; struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data;
u16 scid, flags, result; u16 scid, flags, result;
...@@ -3820,7 +3828,8 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr ...@@ -3820,7 +3828,8 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
return err; return err;
} }
static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) static inline int l2cap_disconnect_req(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd, u8 *data)
{ {
struct l2cap_disconn_req *req = (struct l2cap_disconn_req *) data; struct l2cap_disconn_req *req = (struct l2cap_disconn_req *) data;
struct l2cap_disconn_rsp rsp; struct l2cap_disconn_rsp rsp;
...@@ -3866,7 +3875,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd ...@@ -3866,7 +3875,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd
return 0; return 0;
} }
static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd, u8 *data)
{ {
struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data; struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data;
u16 dcid, scid; u16 dcid, scid;
...@@ -3900,7 +3910,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd ...@@ -3900,7 +3910,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd
return 0; return 0;
} }
static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) static inline int l2cap_information_req(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd, u8 *data)
{ {
struct l2cap_info_req *req = (struct l2cap_info_req *) data; struct l2cap_info_req *req = (struct l2cap_info_req *) data;
u16 type; u16 type;
...@@ -3923,8 +3934,8 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm ...@@ -3923,8 +3934,8 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm
| L2CAP_FEAT_EXT_WINDOW; | L2CAP_FEAT_EXT_WINDOW;
put_unaligned_le32(feat_mask, rsp->data); put_unaligned_le32(feat_mask, rsp->data);
l2cap_send_cmd(conn, cmd->ident, l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(buf),
L2CAP_INFO_RSP, sizeof(buf), buf); buf);
} else if (type == L2CAP_IT_FIXED_CHAN) { } else if (type == L2CAP_IT_FIXED_CHAN) {
u8 buf[12]; u8 buf[12];
struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf; struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf;
...@@ -3937,20 +3948,21 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm ...@@ -3937,20 +3948,21 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm
rsp->type = __constant_cpu_to_le16(L2CAP_IT_FIXED_CHAN); rsp->type = __constant_cpu_to_le16(L2CAP_IT_FIXED_CHAN);
rsp->result = __constant_cpu_to_le16(L2CAP_IR_SUCCESS); rsp->result = __constant_cpu_to_le16(L2CAP_IR_SUCCESS);
memcpy(rsp->data, l2cap_fixed_chan, sizeof(l2cap_fixed_chan)); memcpy(rsp->data, l2cap_fixed_chan, sizeof(l2cap_fixed_chan));
l2cap_send_cmd(conn, cmd->ident, l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(buf),
L2CAP_INFO_RSP, sizeof(buf), buf); buf);
} else { } else {
struct l2cap_info_rsp rsp; struct l2cap_info_rsp rsp;
rsp.type = cpu_to_le16(type); rsp.type = cpu_to_le16(type);
rsp.result = __constant_cpu_to_le16(L2CAP_IR_NOTSUPP); rsp.result = __constant_cpu_to_le16(L2CAP_IR_NOTSUPP);
l2cap_send_cmd(conn, cmd->ident, l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(rsp),
L2CAP_INFO_RSP, sizeof(rsp), &rsp); &rsp);
} }
return 0; return 0;
} }
static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) static inline int l2cap_information_rsp(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd, u8 *data)
{ {
struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) data; struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) data;
u16 type, result; u16 type, result;
...@@ -4009,8 +4021,8 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm ...@@ -4009,8 +4021,8 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
} }
static inline int l2cap_create_channel_req(struct l2cap_conn *conn, static inline int l2cap_create_channel_req(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd, u16 cmd_len, struct l2cap_cmd_hdr *cmd,
void *data) u16 cmd_len, void *data)
{ {
struct l2cap_create_chan_req *req = data; struct l2cap_create_chan_req *req = data;
struct l2cap_create_chan_rsp rsp; struct l2cap_create_chan_rsp rsp;
...@@ -4039,6 +4051,15 @@ static inline int l2cap_create_channel_req(struct l2cap_conn *conn, ...@@ -4039,6 +4051,15 @@ static inline int l2cap_create_channel_req(struct l2cap_conn *conn,
return 0; return 0;
} }
static inline int l2cap_create_channel_rsp(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd,
void *data)
{
BT_DBG("conn %p", conn);
return l2cap_connect_rsp(conn, cmd, data);
}
static void l2cap_send_move_chan_rsp(struct l2cap_conn *conn, u8 ident, static void l2cap_send_move_chan_rsp(struct l2cap_conn *conn, u8 ident,
u16 icid, u16 result) u16 icid, u16 result)
{ {
...@@ -4186,7 +4207,8 @@ static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency, ...@@ -4186,7 +4207,8 @@ static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency,
} }
static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd, u8 *data) struct l2cap_cmd_hdr *cmd,
u8 *data)
{ {
struct hci_conn *hcon = conn->hcon; struct hci_conn *hcon = conn->hcon;
struct l2cap_conn_param_update_req *req; struct l2cap_conn_param_update_req *req;
...@@ -4228,7 +4250,8 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, ...@@ -4228,7 +4250,8 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
} }
static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn, static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data) struct l2cap_cmd_hdr *cmd, u16 cmd_len,
u8 *data)
{ {
int err = 0; int err = 0;
...@@ -4343,7 +4366,8 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, ...@@ -4343,7 +4366,8 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
cmd_len = le16_to_cpu(cmd.len); cmd_len = le16_to_cpu(cmd.len);
BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd_len, cmd.ident); BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd_len,
cmd.ident);
if (cmd_len > len || !cmd.ident) { if (cmd_len > len || !cmd.ident) {
BT_DBG("corrupted command"); BT_DBG("corrupted command");
...@@ -4362,7 +4386,8 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, ...@@ -4362,7 +4386,8 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
/* FIXME: Map err to a valid reason */ /* FIXME: Map err to a valid reason */
rej.reason = __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD); rej.reason = __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej); l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ,
sizeof(rej), &rej);
} }
data += cmd_len; data += cmd_len;
...@@ -4427,8 +4452,8 @@ static void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) ...@@ -4427,8 +4452,8 @@ static void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan)
} }
} }
static void append_skb_frag(struct sk_buff *skb, static void append_skb_frag(struct sk_buff *skb, struct sk_buff *new_frag,
struct sk_buff *new_frag, struct sk_buff **last_frag) struct sk_buff **last_frag)
{ {
/* skb->len reflects data in skb as well as all fragments /* skb->len reflects data in skb as well as all fragments
* skb->data_len reflects only data in fragments * skb->data_len reflects only data in fragments
...@@ -4718,8 +4743,7 @@ static u8 l2cap_classify_txseq(struct l2cap_chan *chan, u16 txseq) ...@@ -4718,8 +4743,7 @@ static u8 l2cap_classify_txseq(struct l2cap_chan *chan, u16 txseq)
} }
if (__seq_offset(chan, txseq, chan->last_acked_seq) < if (__seq_offset(chan, txseq, chan->last_acked_seq) <
__seq_offset(chan, chan->expected_tx_seq, __seq_offset(chan, chan->expected_tx_seq, chan->last_acked_seq)) {
chan->last_acked_seq)){
BT_DBG("Duplicate - expected_tx_seq later than txseq"); BT_DBG("Duplicate - expected_tx_seq later than txseq");
return L2CAP_TXSEQ_DUPLICATE; return L2CAP_TXSEQ_DUPLICATE;
} }
...@@ -5688,8 +5712,8 @@ int __init l2cap_init(void) ...@@ -5688,8 +5712,8 @@ int __init l2cap_init(void)
return err; return err;
if (bt_debugfs) { if (bt_debugfs) {
l2cap_debugfs = debugfs_create_file("l2cap", 0444, l2cap_debugfs = debugfs_create_file("l2cap", 0444, bt_debugfs,
bt_debugfs, NULL, &l2cap_debugfs_fops); NULL, &l2cap_debugfs_fops);
if (!l2cap_debugfs) if (!l2cap_debugfs)
BT_ERR("Failed to create L2CAP debug file"); BT_ERR("Failed to create L2CAP debug file");
} }
......
...@@ -40,7 +40,8 @@ static struct bt_sock_list l2cap_sk_list = { ...@@ -40,7 +40,8 @@ static struct bt_sock_list l2cap_sk_list = {
static const struct proto_ops l2cap_sock_ops; static const struct proto_ops l2cap_sock_ops;
static void l2cap_sock_init(struct sock *sk, struct sock *parent); static void l2cap_sock_init(struct sock *sk, struct sock *parent);
static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio); static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
int proto, gfp_t prio);
static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
{ {
...@@ -106,7 +107,8 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) ...@@ -106,7 +107,8 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
return err; return err;
} }
static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int alen, int flags) static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
int alen, int flags)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct l2cap_chan *chan = l2cap_pi(sk)->chan;
...@@ -185,7 +187,8 @@ static int l2cap_sock_listen(struct socket *sock, int backlog) ...@@ -185,7 +187,8 @@ static int l2cap_sock_listen(struct socket *sock, int backlog)
return err; return err;
} }
static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int flags) static int l2cap_sock_accept(struct socket *sock, struct socket *newsock,
int flags)
{ {
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
struct sock *sk = sock->sk, *nsk; struct sock *sk = sock->sk, *nsk;
...@@ -241,7 +244,8 @@ static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int fl ...@@ -241,7 +244,8 @@ static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int fl
return err; return err;
} }
static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *len, int peer) static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr,
int *len, int peer)
{ {
struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr; struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr;
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
...@@ -265,7 +269,8 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l ...@@ -265,7 +269,8 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l
return 0; return 0;
} }
static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __user *optval, int __user *optlen) static int l2cap_sock_getsockopt_old(struct socket *sock, int optname,
char __user *optval, int __user *optlen)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct l2cap_chan *chan = l2cap_pi(sk)->chan;
...@@ -352,7 +357,8 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us ...@@ -352,7 +357,8 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us
return err; return err;
} }
static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,
char __user *optval, int __user *optlen)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct l2cap_chan *chan = l2cap_pi(sk)->chan;
...@@ -466,7 +472,8 @@ static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu) ...@@ -466,7 +472,8 @@ static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu)
return true; return true;
} }
static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen) static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
char __user *optval, unsigned int optlen)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct l2cap_chan *chan = l2cap_pi(sk)->chan;
...@@ -565,7 +572,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us ...@@ -565,7 +572,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
return err; return err;
} }
static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
char __user *optval, unsigned int optlen)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct l2cap_chan *chan = l2cap_pi(sk)->chan;
...@@ -738,7 +746,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch ...@@ -738,7 +746,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
return err; return err;
} }
static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t len)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct l2cap_chan *chan = l2cap_pi(sk)->chan;
...@@ -763,7 +772,8 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms ...@@ -763,7 +772,8 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
return err; return err;
} }
static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags) static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t len, int flags)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct l2cap_pinfo *pi = l2cap_pi(sk); struct l2cap_pinfo *pi = l2cap_pi(sk);
...@@ -1161,7 +1171,8 @@ static struct proto l2cap_proto = { ...@@ -1161,7 +1171,8 @@ static struct proto l2cap_proto = {
.obj_size = sizeof(struct l2cap_pinfo) .obj_size = sizeof(struct l2cap_pinfo)
}; };
static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio) static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
int proto, gfp_t prio)
{ {
struct sock *sk; struct sock *sk;
struct l2cap_chan *chan; struct l2cap_chan *chan;
...@@ -1263,7 +1274,8 @@ int __init l2cap_init_sockets(void) ...@@ -1263,7 +1274,8 @@ int __init l2cap_init_sockets(void)
goto error; goto error;
} }
err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list, NULL); err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list,
NULL);
if (err < 0) { if (err < 0) {
BT_ERR("Failed to create L2CAP proc file"); BT_ERR("Failed to create L2CAP proc file");
bt_sock_unregister(BTPROTO_L2CAP); bt_sock_unregister(BTPROTO_L2CAP);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment