[Bluetooth] Integrate services into the driver model
[pandora-kernel.git] / net / bluetooth / af_bluetooth.c
index ea616e3..788ea7a 100644 (file)
@@ -24,7 +24,6 @@
 
 /* Bluetooth address family and sockets. */
 
-#include <linux/config.h>
 #include <linux/module.h>
 
 #include <linux/types.h>
@@ -49,7 +48,7 @@
 #define BT_DBG(D...)
 #endif
 
-#define VERSION "2.8"
+#define VERSION "2.10"
 
 /* Bluetooth sockets */
 #define BT_MAX_PROTO   8
@@ -238,6 +237,9 @@ unsigned int bt_sock_poll(struct file * file, struct socket *sock, poll_table *w
        if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
                mask |= POLLERR;
 
+       if (sk->sk_shutdown & RCV_SHUTDOWN)
+               mask |= POLLRDHUP;
+
        if (sk->sk_shutdown == SHUTDOWN_MASK)
                mask |= POLLHUP;
 
@@ -287,10 +289,9 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
                timeo = schedule_timeout(timeo);
                lock_sock(sk);
 
-               if (sk->sk_err) {
-                       err = sock_error(sk);
+               err = sock_error(sk);
+               if (err)
                        break;
-               }
        }
        set_current_state(TASK_RUNNING);
        remove_wait_queue(sk->sk_sleep, &wait);
@@ -306,13 +307,21 @@ static struct net_proto_family bt_sock_family_ops = {
 
 static int __init bt_init(void)
 {
+       int err;
+
        BT_INFO("Core ver %s", VERSION);
 
-       sock_register(&bt_sock_family_ops);
+       err = bt_sysfs_init();
+       if (err < 0)
+               return err;
 
-       BT_INFO("HCI device and connection manager initialized");
+       err = sock_register(&bt_sock_family_ops);
+       if (err < 0) {
+               bt_sysfs_cleanup();
+               return err;
+       }
 
-       bt_sysfs_init();
+       BT_INFO("HCI device and connection manager initialized");
 
        hci_sock_init();
 
@@ -323,9 +332,9 @@ static void __exit bt_exit(void)
 {
        hci_sock_cleanup();
 
-       bt_sysfs_cleanup();
-
        sock_unregister(PF_BLUETOOTH);
+
+       bt_sysfs_cleanup();
 }
 
 subsys_initcall(bt_init);