vserver 2.0 rc7
[linux-2.6.git] / net / bluetooth / bnep / sock.c
index 990e503..9778c6a 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
-#include <linux/major.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/poll.h>
@@ -167,6 +166,12 @@ static struct proto_ops bnep_sock_ops = {
        .mmap       = sock_no_mmap
 };
 
+static struct proto bnep_proto = {
+       .name           = "BNEP",
+       .owner          = THIS_MODULE,
+       .obj_size       = sizeof(struct bt_sock)
+};
+
 static int bnep_sock_create(struct socket *sock, int protocol)
 {
        struct sock *sk;
@@ -176,17 +181,21 @@ static int bnep_sock_create(struct socket *sock, int protocol)
        if (sock->type != SOCK_RAW)
                return -ESOCKTNOSUPPORT;
 
-       if (!(sk = bt_sock_alloc(sock, PF_BLUETOOTH, 0, GFP_KERNEL)))
+       sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, &bnep_proto, 1);
+       if (!sk)
                return -ENOMEM;
 
-       sk_set_owner(sk, THIS_MODULE);
+       sock_init_data(sock, sk);
 
        sock->ops = &bnep_sock_ops;
 
-       sock->state  = SS_UNCONNECTED;
+       sock->state = SS_UNCONNECTED;
+
+       sock_reset_flag(sk, SOCK_ZAPPED);
 
-       sk->sk_destruct = NULL;
        sk->sk_protocol = protocol;
+       sk->sk_state    = BT_OPEN;
+
        return 0;
 }
 
@@ -198,13 +207,30 @@ static struct net_proto_family bnep_sock_family_ops = {
 
 int __init bnep_sock_init(void)
 {
-       bt_sock_register(BTPROTO_BNEP, &bnep_sock_family_ops);
+       int err;
+
+       err = proto_register(&bnep_proto, 0);
+       if (err < 0)
+               return err;
+
+       err = bt_sock_register(BTPROTO_BNEP, &bnep_sock_family_ops);
+       if (err < 0)
+               goto error;
+
        return 0;
+
+error:
+       BT_ERR("Can't register BNEP socket");
+       proto_unregister(&bnep_proto);
+       return err;
 }
 
 int __exit bnep_sock_cleanup(void)
 {
-       if (bt_sock_unregister(BTPROTO_BNEP))
+       if (bt_sock_unregister(BTPROTO_BNEP) < 0)
                BT_ERR("Can't unregister BNEP socket");
+
+       proto_unregister(&bnep_proto);
+
        return 0;
 }