#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>
.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;
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;
}
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;
}