]> Git Repo - qemu.git/blobdiff - hw/bt-l2cap.c
net: reorganize headers
[qemu.git] / hw / bt-l2cap.c
index 0abcac0bc18a8ee15eb24277865d6e4ba688a501..cb43ee773340d8f5348b07d98fcaf6e4c6de60a5 100644 (file)
@@ -14,9 +14,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- * MA  02110-1301  USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "qemu-common.h"
@@ -401,7 +399,7 @@ static inline struct bt_l2cap_psm_s *l2cap_psm(
 static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap,
                 int psm, int source_cid)
 {
-    struct l2cap_chan_s *ch = 0;
+    struct l2cap_chan_s *ch = NULL;
     struct bt_l2cap_psm_s *psm_info;
     int result, status;
     int cid = l2cap_cid_new(l2cap);
@@ -412,7 +410,7 @@ static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap,
 
         if (psm_info) {
             /* Device supports this use-case.  */
-            ch = qemu_mallocz(sizeof(*ch));
+            ch = g_malloc0(sizeof(*ch));
             ch->params.sdu_out = l2cap_bframe_out;
             ch->params.sdu_submit = l2cap_bframe_submit;
             ch->frame_in = l2cap_bframe_in;
@@ -430,7 +428,7 @@ static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap,
                 result = L2CAP_CR_SUCCESS;
                 status = L2CAP_CS_NO_INFO;
             } else {
-                qemu_free(ch);
+                g_free(ch);
 
                 result = L2CAP_CR_NO_MEM;
                 status = L2CAP_CS_NO_INFO;
@@ -452,7 +450,7 @@ static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap,
 static void l2cap_channel_close(struct l2cap_instance_s *l2cap,
                 int cid, int source_cid)
 {
-    struct l2cap_chan_s *ch = 0;
+    struct l2cap_chan_s *ch = NULL;
 
     /* According to Volume 3, section 6.1.1, pg 1048 of BT Core V2.0, a
      * connection in CLOSED state still responds with a L2CAP_DisconnectRsp
@@ -472,10 +470,10 @@ static void l2cap_channel_close(struct l2cap_instance_s *l2cap,
             return;
         }
 
-        l2cap->cid[cid] = 0;
+        l2cap->cid[cid] = NULL;
 
         ch->params.close(ch->params.opaque);
-        qemu_free(ch);
+        g_free(ch);
     }
 
     l2cap_disconnection_response(l2cap, cid, source_cid);
@@ -484,7 +482,7 @@ static void l2cap_channel_close(struct l2cap_instance_s *l2cap,
 static void l2cap_channel_config_null(struct l2cap_instance_s *l2cap,
                 struct l2cap_chan_s *ch)
 {
-    l2cap_configuration_request(l2cap, ch->remote_cid, 0, 0, 0);
+    l2cap_configuration_request(l2cap, ch->remote_cid, 0, NULL, 0);
     ch->config_req_id = l2cap->last_id;
     ch->config &= ~L2CAP_CFG_INIT;
 }
@@ -998,11 +996,12 @@ static void l2cap_iframe_in(struct l2cap_chan_s *ch, uint16_t cid,
         l2cap_rexmit_enable(ch, !(hdr->data[0] >> 7));
 
     if (hdr->data[0] & 1) {
-        if (len != 4)
-            /* TODO: Signal an error? */;
+        if (len != 4) {
+            /* TODO: Signal an error? */
             return;
-
-        return l2cap_sframe_in(ch, le16_to_cpup((void *) hdr->data));
+        }
+        l2cap_sframe_in(ch, le16_to_cpup((void *) hdr->data));
+        return;
     }
 
     switch (hdr->data[1] >> 6) {       /* SAR */
@@ -1012,7 +1011,8 @@ static void l2cap_iframe_in(struct l2cap_chan_s *ch, uint16_t cid,
         if (len - 4 > ch->mps)
             goto len_error;
 
-        return ch->params.sdu_in(ch->params.opaque, hdr->data + 2, len - 4);
+        ch->params.sdu_in(ch->params.opaque, hdr->data + 2, len - 4);
+        break;
 
     case L2CAP_SAR_START:
         if (ch->len_total || len < 6)
@@ -1035,7 +1035,8 @@ static void l2cap_iframe_in(struct l2cap_chan_s *ch, uint16_t cid,
             goto len_error;
 
         memcpy(ch->sdu + ch->len_cur, hdr->data + 2, len - 4);
-        return ch->params.sdu_in(ch->params.opaque, ch->sdu, ch->len_total);
+        ch->params.sdu_in(ch->params.opaque, ch->sdu, ch->len_total);
+        break;
 
     case L2CAP_SAR_CONT:
         if (!ch->len_total || ch->len_cur + len - 4 >= ch->len_total)
@@ -1138,7 +1139,7 @@ static void l2cap_bframe_submit(struct bt_l2cap_conn_params_s *parms)
 {
     struct l2cap_chan_s *chan = (struct l2cap_chan_s *) parms;
 
-    return l2cap_pdu_submit(chan->l2cap);
+    l2cap_pdu_submit(chan->l2cap);
 }
 
 #if 0
@@ -1220,13 +1221,13 @@ static void l2cap_teardown(struct l2cap_instance_s *l2cap, int send_disconnect)
     for (cid = L2CAP_CID_ALLOC; cid < L2CAP_CID_MAX; cid ++)
         if (l2cap->cid[cid]) {
             l2cap->cid[cid]->params.close(l2cap->cid[cid]->params.opaque);
-            free(l2cap->cid[cid]);
+            g_free(l2cap->cid[cid]);
         }
 
     if (l2cap->role)
-        qemu_free(l2cap);
+        g_free(l2cap);
     else
-        qemu_free(l2cap->link);
+        g_free(l2cap->link);
 }
 
 /* L2CAP glue to lower layers in bluetooth stack (LMP) */
@@ -1238,7 +1239,7 @@ static void l2cap_lmp_connection_request(struct bt_link_s *link)
 
     /* Always accept - we only get called if (dev->device->page_scan).  */
 
-    l2cap = qemu_mallocz(sizeof(struct slave_l2cap_instance_s));
+    l2cap = g_malloc0(sizeof(struct slave_l2cap_instance_s));
     l2cap->link.slave = &dev->device;
     l2cap->link.host = link->host;
     l2cap_init(&l2cap->l2cap, &l2cap->link, 0);
@@ -1259,7 +1260,7 @@ static void l2cap_lmp_connection_complete(struct bt_link_s *link)
         return;
     }
 
-    l2cap = qemu_mallocz(sizeof(struct l2cap_instance_s));
+    l2cap = g_malloc0(sizeof(struct l2cap_instance_s));
     l2cap_init(l2cap, link, 1);
 
     link->acl_mode = acl_active;
@@ -1355,7 +1356,7 @@ void bt_l2cap_psm_register(struct bt_l2cap_device_s *dev, int psm, int min_mtu,
         exit(-1);
     }
 
-    new_psm = qemu_mallocz(sizeof(*new_psm));
+    new_psm = g_malloc0(sizeof(*new_psm));
     new_psm->psm = psm;
     new_psm->min_mtu = min_mtu;
     new_psm->new_channel = new_channel;
This page took 0.032501 seconds and 4 git commands to generate.