Commit 80b98027 authored by Gustavo Padovan's avatar Gustavo Padovan Committed by Johan Hedberg

Bluetooth: Use chan as parameters for l2cap chan ops

Use chan instead of void * makes more sense here.
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 3df92b31
...@@ -527,10 +527,12 @@ struct l2cap_chan { ...@@ -527,10 +527,12 @@ struct l2cap_chan {
struct l2cap_ops { struct l2cap_ops {
char *name; char *name;
struct l2cap_chan *(*new_connection) (void *data); struct l2cap_chan *(*new_connection) (struct l2cap_chan *chan);
int (*recv) (void *data, struct sk_buff *skb); int (*recv) (struct l2cap_chan * chan,
void (*close) (void *data); struct sk_buff *skb);
void (*state_change) (void *data, int state); void (*close) (struct l2cap_chan *chan);
void (*state_change) (struct l2cap_chan *chan,
int state);
struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
unsigned long len, int nb); unsigned long len, int nb);
}; };
......
...@@ -180,7 +180,7 @@ static void __l2cap_state_change(struct l2cap_chan *chan, int state) ...@@ -180,7 +180,7 @@ static void __l2cap_state_change(struct l2cap_chan *chan, int state)
state_to_string(state)); state_to_string(state));
chan->state = state; chan->state = state;
chan->ops->state_change(chan->data, state); chan->ops->state_change(chan, state);
} }
static void l2cap_state_change(struct l2cap_chan *chan, int state) static void l2cap_state_change(struct l2cap_chan *chan, int state)
...@@ -381,7 +381,7 @@ static void l2cap_chan_timeout(struct work_struct *work) ...@@ -381,7 +381,7 @@ static void l2cap_chan_timeout(struct work_struct *work)
l2cap_chan_unlock(chan); l2cap_chan_unlock(chan);
chan->ops->close(chan->data); chan->ops->close(chan);
mutex_unlock(&conn->chan_lock); mutex_unlock(&conn->chan_lock);
l2cap_chan_put(chan); l2cap_chan_put(chan);
...@@ -569,7 +569,7 @@ static void l2cap_chan_cleanup_listen(struct sock *parent) ...@@ -569,7 +569,7 @@ static void l2cap_chan_cleanup_listen(struct sock *parent)
l2cap_chan_close(chan, ECONNRESET); l2cap_chan_close(chan, ECONNRESET);
l2cap_chan_unlock(chan); l2cap_chan_unlock(chan);
chan->ops->close(chan->data); chan->ops->close(chan);
} }
} }
...@@ -1213,7 +1213,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) ...@@ -1213,7 +1213,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
goto clean; goto clean;
} }
chan = pchan->ops->new_connection(pchan->data); chan = pchan->ops->new_connection(pchan);
if (!chan) if (!chan)
goto clean; goto clean;
...@@ -1324,7 +1324,7 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) ...@@ -1324,7 +1324,7 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
l2cap_chan_unlock(chan); l2cap_chan_unlock(chan);
chan->ops->close(chan->data); chan->ops->close(chan);
l2cap_chan_put(chan); l2cap_chan_put(chan);
} }
...@@ -2568,7 +2568,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb) ...@@ -2568,7 +2568,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
if (!nskb) if (!nskb)
continue; continue;
if (chan->ops->recv(chan->data, nskb)) if (chan->ops->recv(chan, nskb))
kfree_skb(nskb); kfree_skb(nskb);
} }
...@@ -3411,7 +3411,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd ...@@ -3411,7 +3411,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
goto response; goto response;
} }
chan = pchan->ops->new_connection(pchan->data); chan = pchan->ops->new_connection(pchan);
if (!chan) if (!chan)
goto response; goto response;
...@@ -3420,7 +3420,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd ...@@ -3420,7 +3420,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
/* Check if we already have channel with that dcid */ /* Check if we already have channel with that dcid */
if (__l2cap_get_chan_by_dcid(conn, scid)) { if (__l2cap_get_chan_by_dcid(conn, scid)) {
sock_set_flag(sk, SOCK_ZAPPED); sock_set_flag(sk, SOCK_ZAPPED);
chan->ops->close(chan->data); chan->ops->close(chan);
goto response; goto response;
} }
...@@ -3831,7 +3831,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd ...@@ -3831,7 +3831,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd
l2cap_chan_unlock(chan); l2cap_chan_unlock(chan);
chan->ops->close(chan->data); chan->ops->close(chan);
l2cap_chan_put(chan); l2cap_chan_put(chan);
mutex_unlock(&conn->chan_lock); mutex_unlock(&conn->chan_lock);
...@@ -3865,7 +3865,7 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd ...@@ -3865,7 +3865,7 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd
l2cap_chan_unlock(chan); l2cap_chan_unlock(chan);
chan->ops->close(chan->data); chan->ops->close(chan);
l2cap_chan_put(chan); l2cap_chan_put(chan);
mutex_unlock(&conn->chan_lock); mutex_unlock(&conn->chan_lock);
...@@ -4435,7 +4435,7 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, ...@@ -4435,7 +4435,7 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb,
if (chan->sdu) if (chan->sdu)
break; break;
err = chan->ops->recv(chan->data, skb); err = chan->ops->recv(chan, skb);
break; break;
case L2CAP_SAR_START: case L2CAP_SAR_START:
...@@ -4485,7 +4485,7 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, ...@@ -4485,7 +4485,7 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb,
if (chan->sdu->len != chan->sdu_len) if (chan->sdu->len != chan->sdu_len)
break; break;
err = chan->ops->recv(chan->data, chan->sdu); err = chan->ops->recv(chan, chan->sdu);
if (!err) { if (!err) {
/* Reassembly complete */ /* Reassembly complete */
...@@ -5207,7 +5207,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk ...@@ -5207,7 +5207,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk
if (chan->imtu < skb->len) if (chan->imtu < skb->len)
goto drop; goto drop;
if (!chan->ops->recv(chan->data, skb)) if (!chan->ops->recv(chan, skb))
goto done; goto done;
break; break;
...@@ -5246,7 +5246,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str ...@@ -5246,7 +5246,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str
if (chan->imtu < skb->len) if (chan->imtu < skb->len)
goto drop; goto drop;
if (!chan->ops->recv(chan->data, skb)) if (!chan->ops->recv(chan, skb))
return 0; return 0;
drop: drop:
...@@ -5272,7 +5272,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, u16 cid, ...@@ -5272,7 +5272,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, u16 cid,
if (chan->imtu < skb->len) if (chan->imtu < skb->len)
goto drop; goto drop;
if (!chan->ops->recv(chan->data, skb)) if (!chan->ops->recv(chan, skb))
return 0; return 0;
drop: drop:
......
...@@ -872,9 +872,9 @@ static int l2cap_sock_release(struct socket *sock) ...@@ -872,9 +872,9 @@ static int l2cap_sock_release(struct socket *sock)
return err; return err;
} }
static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data) static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)
{ {
struct sock *sk, *parent = data; struct sock *sk, *parent = chan->data;
sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP,
GFP_ATOMIC); GFP_ATOMIC);
...@@ -888,10 +888,10 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data) ...@@ -888,10 +888,10 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data)
return l2cap_pi(sk)->chan; return l2cap_pi(sk)->chan;
} }
static int l2cap_sock_recv_cb(void *data, struct sk_buff *skb) static int l2cap_sock_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb)
{ {
int err; int err;
struct sock *sk = data; struct sock *sk = chan->data;
struct l2cap_pinfo *pi = l2cap_pi(sk); struct l2cap_pinfo *pi = l2cap_pi(sk);
lock_sock(sk); lock_sock(sk);
...@@ -924,16 +924,16 @@ static int l2cap_sock_recv_cb(void *data, struct sk_buff *skb) ...@@ -924,16 +924,16 @@ static int l2cap_sock_recv_cb(void *data, struct sk_buff *skb)
return err; return err;
} }
static void l2cap_sock_close_cb(void *data) static void l2cap_sock_close_cb(struct l2cap_chan *chan)
{ {
struct sock *sk = data; struct sock *sk = chan->data;
l2cap_sock_kill(sk); l2cap_sock_kill(sk);
} }
static void l2cap_sock_state_change_cb(void *data, int state) static void l2cap_sock_state_change_cb(struct l2cap_chan *chan, int state)
{ {
struct sock *sk = data; struct sock *sk = chan->data;
sk->sk_state = state; sk->sk_state = state;
} }
......
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