[Bluetooth] Handle return values from driver core functions
[pandora-kernel.git] / net / bluetooth / sco.c
index a5f1e44..14b0f69 100644 (file)
@@ -108,17 +108,14 @@ static void sco_sock_init_timer(struct sock *sk)
 static struct sco_conn *sco_conn_add(struct hci_conn *hcon, __u8 status)
 {
        struct hci_dev *hdev = hcon->hdev;
-       struct sco_conn *conn;
-
-       if ((conn = hcon->sco_data))
-               return conn;
+       struct sco_conn *conn = hcon->sco_data;
 
-       if (status)
+       if (conn || status)
                return conn;
 
-       if (!(conn = kmalloc(sizeof(struct sco_conn), GFP_ATOMIC)))
+       conn = kzalloc(sizeof(struct sco_conn), GFP_ATOMIC);
+       if (!conn)
                return NULL;
-       memset(conn, 0, sizeof(struct sco_conn));
 
        spin_lock_init(&conn->lock);
 
@@ -134,6 +131,7 @@ static struct sco_conn *sco_conn_add(struct hci_conn *hcon, __u8 status)
                conn->mtu = 60;
 
        BT_DBG("hcon %p conn %p", hcon, conn);
+
        return conn;
 }
 
@@ -969,7 +967,8 @@ static int __init sco_init(void)
                goto error;
        }
 
-       class_create_file(&bt_class, &class_attr_sco);
+       if (class_create_file(bt_class, &class_attr_sco) < 0)
+               BT_ERR("Failed to create SCO info file");
 
        BT_INFO("SCO (Voice Link) ver %s", VERSION);
        BT_INFO("SCO socket layer initialized");
@@ -983,7 +982,7 @@ error:
 
 static void __exit sco_exit(void)
 {
-       class_remove_file(&bt_class, &class_attr_sco);
+       class_remove_file(bt_class, &class_attr_sco);
 
        if (bt_sock_unregister(BTPROTO_SCO) < 0)
                BT_ERR("SCO socket unregistration failed");