aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/l2cap_sock.c
diff options
context:
space:
mode:
authorGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-10-06 05:07:01 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-10-12 06:06:05 -0400
commit2d7928184c3d8724064de282be4e3c3d70f39d32 (patch)
tree4997dbe597e980349eb1fa51a10f15c0064ce436 /net/bluetooth/l2cap_sock.c
parent4c89b6aad5b7c5c56dadca66af6ceae0addbf2bf (diff)
Bluetooth: Fix L2CAP coding style
Follow the net subsystem coding style Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/l2cap_sock.c')
-rw-r--r--net/bluetooth/l2cap_sock.c62
1 files changed, 37 insertions, 25 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index ed2dfc942c3c..f95fc7ed0a09 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -40,7 +40,8 @@ static struct bt_sock_list l2cap_sk_list = {
40 40
41static const struct proto_ops l2cap_sock_ops; 41static const struct proto_ops l2cap_sock_ops;
42static void l2cap_sock_init(struct sock *sk, struct sock *parent); 42static void l2cap_sock_init(struct sock *sk, struct sock *parent);
43static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio); 43static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
44 int proto, gfp_t prio);
44 45
45static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) 46static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
46{ 47{
@@ -106,7 +107,8 @@ done:
106 return err; 107 return err;
107} 108}
108 109
109static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int alen, int flags) 110static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
111 int alen, int flags)
110{ 112{
111 struct sock *sk = sock->sk; 113 struct sock *sk = sock->sk;
112 struct l2cap_chan *chan = l2cap_pi(sk)->chan; 114 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
@@ -134,7 +136,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
134 lock_sock(sk); 136 lock_sock(sk);
135 137
136 err = bt_sock_wait_state(sk, BT_CONNECTED, 138 err = bt_sock_wait_state(sk, BT_CONNECTED,
137 sock_sndtimeo(sk, flags & O_NONBLOCK)); 139 sock_sndtimeo(sk, flags & O_NONBLOCK));
138 140
139 release_sock(sk); 141 release_sock(sk);
140 142
@@ -185,7 +187,8 @@ done:
185 return err; 187 return err;
186} 188}
187 189
188static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int flags) 190static int l2cap_sock_accept(struct socket *sock, struct socket *newsock,
191 int flags)
189{ 192{
190 DECLARE_WAITQUEUE(wait, current); 193 DECLARE_WAITQUEUE(wait, current);
191 struct sock *sk = sock->sk, *nsk; 194 struct sock *sk = sock->sk, *nsk;
@@ -241,7 +244,8 @@ done:
241 return err; 244 return err;
242} 245}
243 246
244static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *len, int peer) 247static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr,
248 int *len, int peer)
245{ 249{
246 struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr; 250 struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr;
247 struct sock *sk = sock->sk; 251 struct sock *sk = sock->sk;
@@ -265,7 +269,8 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l
265 return 0; 269 return 0;
266} 270}
267 271
268static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __user *optval, int __user *optlen) 272static int l2cap_sock_getsockopt_old(struct socket *sock, int optname,
273 char __user *optval, int __user *optlen)
269{ 274{
270 struct sock *sk = sock->sk; 275 struct sock *sk = sock->sk;
271 struct l2cap_chan *chan = l2cap_pi(sk)->chan; 276 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
@@ -308,7 +313,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us
308 break; 313 break;
309 case BT_SECURITY_HIGH: 314 case BT_SECURITY_HIGH:
310 opt = L2CAP_LM_AUTH | L2CAP_LM_ENCRYPT | 315 opt = L2CAP_LM_AUTH | L2CAP_LM_ENCRYPT |
311 L2CAP_LM_SECURE; 316 L2CAP_LM_SECURE;
312 break; 317 break;
313 default: 318 default:
314 opt = 0; 319 opt = 0;
@@ -352,7 +357,8 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us
352 return err; 357 return err;
353} 358}
354 359
355static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) 360static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,
361 char __user *optval, int __user *optlen)
356{ 362{
357 struct sock *sk = sock->sk; 363 struct sock *sk = sock->sk;
358 struct l2cap_chan *chan = l2cap_pi(sk)->chan; 364 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
@@ -376,7 +382,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
376 switch (optname) { 382 switch (optname) {
377 case BT_SECURITY: 383 case BT_SECURITY:
378 if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && 384 if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED &&
379 chan->chan_type != L2CAP_CHAN_RAW) { 385 chan->chan_type != L2CAP_CHAN_RAW) {
380 err = -EINVAL; 386 err = -EINVAL;
381 break; 387 break;
382 } 388 }
@@ -411,14 +417,14 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
411 417
412 case BT_FLUSHABLE: 418 case BT_FLUSHABLE:
413 if (put_user(test_bit(FLAG_FLUSHABLE, &chan->flags), 419 if (put_user(test_bit(FLAG_FLUSHABLE, &chan->flags),
414 (u32 __user *) optval)) 420 (u32 __user *) optval))
415 err = -EFAULT; 421 err = -EFAULT;
416 422
417 break; 423 break;
418 424
419 case BT_POWER: 425 case BT_POWER:
420 if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM 426 if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM
421 && sk->sk_type != SOCK_RAW) { 427 && sk->sk_type != SOCK_RAW) {
422 err = -EINVAL; 428 err = -EINVAL;
423 break; 429 break;
424 } 430 }
@@ -466,7 +472,8 @@ static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu)
466 return true; 472 return true;
467} 473}
468 474
469static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen) 475static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
476 char __user *optval, unsigned int optlen)
470{ 477{
471 struct sock *sk = sock->sk; 478 struct sock *sk = sock->sk;
472 struct l2cap_chan *chan = l2cap_pi(sk)->chan; 479 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 return err; 572 return err;
566} 573}
567 574
568static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) 575static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
576 char __user *optval, unsigned int optlen)
569{ 577{
570 struct sock *sk = sock->sk; 578 struct sock *sk = sock->sk;
571 struct l2cap_chan *chan = l2cap_pi(sk)->chan; 579 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
@@ -588,7 +596,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
588 switch (optname) { 596 switch (optname) {
589 case BT_SECURITY: 597 case BT_SECURITY:
590 if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && 598 if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED &&
591 chan->chan_type != L2CAP_CHAN_RAW) { 599 chan->chan_type != L2CAP_CHAN_RAW) {
592 err = -EINVAL; 600 err = -EINVAL;
593 break; 601 break;
594 } 602 }
@@ -602,7 +610,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
602 } 610 }
603 611
604 if (sec.level < BT_SECURITY_LOW || 612 if (sec.level < BT_SECURITY_LOW ||
605 sec.level > BT_SECURITY_HIGH) { 613 sec.level > BT_SECURITY_HIGH) {
606 err = -EINVAL; 614 err = -EINVAL;
607 break; 615 break;
608 } 616 }
@@ -628,7 +636,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
628 636
629 /* or for ACL link */ 637 /* or for ACL link */
630 } else if ((sk->sk_state == BT_CONNECT2 && 638 } else if ((sk->sk_state == BT_CONNECT2 &&
631 test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) || 639 test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) ||
632 sk->sk_state == BT_CONNECTED) { 640 sk->sk_state == BT_CONNECTED) {
633 if (!l2cap_chan_check_security(chan)) 641 if (!l2cap_chan_check_security(chan))
634 set_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags); 642 set_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags);
@@ -685,7 +693,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
685 693
686 case BT_POWER: 694 case BT_POWER:
687 if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && 695 if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED &&
688 chan->chan_type != L2CAP_CHAN_RAW) { 696 chan->chan_type != L2CAP_CHAN_RAW) {
689 err = -EINVAL; 697 err = -EINVAL;
690 break; 698 break;
691 } 699 }
@@ -721,7 +729,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
721 } 729 }
722 730
723 if (chan->mode != L2CAP_MODE_ERTM && 731 if (chan->mode != L2CAP_MODE_ERTM &&
724 chan->mode != L2CAP_MODE_STREAMING) { 732 chan->mode != L2CAP_MODE_STREAMING) {
725 err = -EOPNOTSUPP; 733 err = -EOPNOTSUPP;
726 break; 734 break;
727 } 735 }
@@ -738,7 +746,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
738 return err; 746 return err;
739} 747}
740 748
741static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) 749static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
750 struct msghdr *msg, size_t len)
742{ 751{
743 struct sock *sk = sock->sk; 752 struct sock *sk = sock->sk;
744 struct l2cap_chan *chan = l2cap_pi(sk)->chan; 753 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 return err; 772 return err;
764} 773}
765 774
766static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags) 775static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
776 struct msghdr *msg, size_t len, int flags)
767{ 777{
768 struct sock *sk = sock->sk; 778 struct sock *sk = sock->sk;
769 struct l2cap_pinfo *pi = l2cap_pi(sk); 779 struct l2cap_pinfo *pi = l2cap_pi(sk);
@@ -867,7 +877,7 @@ static int l2cap_sock_shutdown(struct socket *sock, int how)
867 877
868 if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) 878 if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime)
869 err = bt_sock_wait_state(sk, BT_CLOSED, 879 err = bt_sock_wait_state(sk, BT_CLOSED,
870 sk->sk_lingertime); 880 sk->sk_lingertime);
871 } 881 }
872 882
873 if (!err && sk->sk_err) 883 if (!err && sk->sk_err)
@@ -931,7 +941,7 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)
931 } 941 }
932 942
933 sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, 943 sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP,
934 GFP_ATOMIC); 944 GFP_ATOMIC);
935 if (!sk) 945 if (!sk)
936 return NULL; 946 return NULL;
937 947
@@ -1161,7 +1171,8 @@ static struct proto l2cap_proto = {
1161 .obj_size = sizeof(struct l2cap_pinfo) 1171 .obj_size = sizeof(struct l2cap_pinfo)
1162}; 1172};
1163 1173
1164static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio) 1174static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
1175 int proto, gfp_t prio)
1165{ 1176{
1166 struct sock *sk; 1177 struct sock *sk;
1167 struct l2cap_chan *chan; 1178 struct l2cap_chan *chan;
@@ -1206,7 +1217,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol,
1206 sock->state = SS_UNCONNECTED; 1217 sock->state = SS_UNCONNECTED;
1207 1218
1208 if (sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM && 1219 if (sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM &&
1209 sock->type != SOCK_DGRAM && sock->type != SOCK_RAW) 1220 sock->type != SOCK_DGRAM && sock->type != SOCK_RAW)
1210 return -ESOCKTNOSUPPORT; 1221 return -ESOCKTNOSUPPORT;
1211 1222
1212 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW)) 1223 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
@@ -1263,7 +1274,8 @@ int __init l2cap_init_sockets(void)
1263 goto error; 1274 goto error;
1264 } 1275 }
1265 1276
1266 err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list, NULL); 1277 err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list,
1278 NULL);
1267 if (err < 0) { 1279 if (err < 0) {
1268 BT_ERR("Failed to create L2CAP proc file"); 1280 BT_ERR("Failed to create L2CAP proc file");
1269 bt_sock_unregister(BTPROTO_L2CAP); 1281 bt_sock_unregister(BTPROTO_L2CAP);