9ae3a8
From bc5c67b27d0c1d8ec6c4d09352f0de6b6cbddad0 Mon Sep 17 00:00:00 2001
9ae3a8
From: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
Date: Mon, 16 Sep 2013 14:38:24 +0200
9ae3a8
Subject: [PATCH 16/29] Preparation for usb-bt-dongle conditional build
9ae3a8
9ae3a8
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
Message-id: <0b3a39c76eac58a1b2f9f6c84016f234de0940c0.1379325610.git.mrezanin@redhat.com>
9ae3a8
Patchwork-id: 54394
9ae3a8
O-Subject: [RHEL7 qemu-kvm PATCH 1/2] Preparation for usb-bt-dongle conditional build
9ae3a8
Bugzilla: 1001131
9ae3a8
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
From: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
To allow disable usb-bt-dongle device using CONFIG_BLUETOOTH option, some of
9ae3a8
functions in vl.c file has to be made accessible in dev-bluetooth.c. This is
9ae3a8
pure code moving.
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
(cherry picked from commit 644e1a8a34d2f799bfeefae94b71593a2aa662ae)
9ae3a8
---
9ae3a8
 hw/bt/core.c    | 23 +++++++++++++++++++
9ae3a8
 hw/bt/hci.c     | 48 +++++++++++++++++++++++++++++++++++++++
9ae3a8
 include/hw/bt.h |  3 +++
9ae3a8
 vl.c            | 69 ---------------------------------------------------------
9ae3a8
 4 files changed, 74 insertions(+), 69 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/bt/core.c    |   23 ++++++++++++++++++
9ae3a8
 hw/bt/hci.c     |   48 ++++++++++++++++++++++++++++++++++++++
9ae3a8
 include/hw/bt.h |    3 ++
9ae3a8
 vl.c            |   69 -------------------------------------------------------
9ae3a8
 4 files changed, 74 insertions(+), 69 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/bt/core.c b/hw/bt/core.c
9ae3a8
index 49012e0..0ffc948 100644
9ae3a8
--- a/hw/bt/core.c
9ae3a8
+++ b/hw/bt/core.c
9ae3a8
@@ -119,3 +119,26 @@ void bt_device_done(struct bt_device_s *dev)
9ae3a8
 
9ae3a8
     *p = dev->next;
9ae3a8
 }
9ae3a8
+
9ae3a8
+static struct bt_vlan_s {
9ae3a8
+    struct bt_scatternet_s net;
9ae3a8
+    int id;
9ae3a8
+    struct bt_vlan_s *next;
9ae3a8
+} *first_bt_vlan;
9ae3a8
+
9ae3a8
+/* find or alloc a new bluetooth "VLAN" */
9ae3a8
+struct bt_scatternet_s *qemu_find_bt_vlan(int id)
9ae3a8
+{
9ae3a8
+    struct bt_vlan_s **pvlan, *vlan;
9ae3a8
+    for (vlan = first_bt_vlan; vlan != NULL; vlan = vlan->next) {
9ae3a8
+        if (vlan->id == id)
9ae3a8
+            return &vlan->net;
9ae3a8
+    }
9ae3a8
+    vlan = g_malloc0(sizeof(struct bt_vlan_s));
9ae3a8
+    vlan->id = id;
9ae3a8
+    pvlan = &first_bt_vlan;
9ae3a8
+    while (*pvlan != NULL)
9ae3a8
+        pvlan = &(*pvlan)->next;
9ae3a8
+    *pvlan = vlan;
9ae3a8
+    return &vlan->net;
9ae3a8
+}
9ae3a8
diff --git a/hw/bt/hci.c b/hw/bt/hci.c
9ae3a8
index b53cd5d..64e1745 100644
9ae3a8
--- a/hw/bt/hci.c
9ae3a8
+++ b/hw/bt/hci.c
9ae3a8
@@ -429,6 +429,24 @@ static const uint8_t bt_event_reserved_mask[8] = {
9ae3a8
     0xff, 0x9f, 0xfb, 0xff, 0x07, 0x18, 0x00, 0x00,
9ae3a8
 };
9ae3a8
 
9ae3a8
+
9ae3a8
+static void null_hci_send(struct HCIInfo *hci, const uint8_t *data, int len)
9ae3a8
+{
9ae3a8
+}
9ae3a8
+
9ae3a8
+static int null_hci_addr_set(struct HCIInfo *hci, const uint8_t *bd_addr)
9ae3a8
+{
9ae3a8
+    return -ENOTSUP;
9ae3a8
+}
9ae3a8
+
9ae3a8
+struct HCIInfo null_hci = {
9ae3a8
+    .cmd_send = null_hci_send,
9ae3a8
+    .sco_send = null_hci_send,
9ae3a8
+    .acl_send = null_hci_send,
9ae3a8
+    .bdaddr_set = null_hci_addr_set,
9ae3a8
+};
9ae3a8
+
9ae3a8
+
9ae3a8
 static inline uint8_t *bt_hci_event_start(struct bt_hci_s *hci,
9ae3a8
                 int evt, int len)
9ae3a8
 {
9ae3a8
@@ -2176,6 +2194,36 @@ struct HCIInfo *bt_new_hci(struct bt_scatternet_s *net)
9ae3a8
     return &s->info;
9ae3a8
 }
9ae3a8
 
9ae3a8
+struct HCIInfo *hci_init(const char *str)
9ae3a8
+{
9ae3a8
+    char *endp;
9ae3a8
+    struct bt_scatternet_s *vlan = 0;
9ae3a8
+
9ae3a8
+    if (!strcmp(str, "null"))
9ae3a8
+        /* null */
9ae3a8
+        return &null_hci;
9ae3a8
+    else if (!strncmp(str, "host", 4) && (str[4] == '\0' || str[4] == ':'))
9ae3a8
+        /* host[:hciN] */
9ae3a8
+        return bt_host_hci(str[4] ? str + 5 : "hci0");
9ae3a8
+    else if (!strncmp(str, "hci", 3)) {
9ae3a8
+        /* hci[,vlan=n] */
9ae3a8
+        if (str[3]) {
9ae3a8
+            if (!strncmp(str + 3, ",vlan=", 6)) {
9ae3a8
+                vlan = qemu_find_bt_vlan(strtol(str + 9, &endp, 0));
9ae3a8
+                if (*endp)
9ae3a8
+                    vlan = 0;
9ae3a8
+            }
9ae3a8
+        } else
9ae3a8
+            vlan = qemu_find_bt_vlan(0);
9ae3a8
+        if (vlan)
9ae3a8
+           return bt_new_hci(vlan);
9ae3a8
+    }
9ae3a8
+
9ae3a8
+    fprintf(stderr, "qemu: Unknown bluetooth HCI `%s'.\n", str);
9ae3a8
+
9ae3a8
+    return 0;
9ae3a8
+}
9ae3a8
+
9ae3a8
 static void bt_hci_done(struct HCIInfo *info)
9ae3a8
 {
9ae3a8
     struct bt_hci_s *hci = hci_from_info(info);
9ae3a8
diff --git a/include/hw/bt.h b/include/hw/bt.h
9ae3a8
index 830af94..49a9d03 100644
9ae3a8
--- a/include/hw/bt.h
9ae3a8
+++ b/include/hw/bt.h
9ae3a8
@@ -108,12 +108,15 @@ struct bt_device_s {
9ae3a8
     uint16_t clkoff;	/* Note: Always little-endian */
9ae3a8
 };
9ae3a8
 
9ae3a8
+extern struct HCIInfo null_hci;
9ae3a8
 /* bt.c */
9ae3a8
 void bt_device_init(struct bt_device_s *dev, struct bt_scatternet_s *net);
9ae3a8
 void bt_device_done(struct bt_device_s *dev);
9ae3a8
+struct bt_scatternet_s *qemu_find_bt_vlan(int id);
9ae3a8
 
9ae3a8
 /* bt-hci.c */
9ae3a8
 struct HCIInfo *bt_new_hci(struct bt_scatternet_s *net);
9ae3a8
+struct HCIInfo *hci_init(const char *str);
9ae3a8
 
9ae3a8
 /* bt-vhci.c */
9ae3a8
 void bt_vhci_init(struct HCIInfo *info);
9ae3a8
diff --git a/vl.c b/vl.c
9ae3a8
index 24536b5..d022f50 100644
9ae3a8
--- a/vl.c
9ae3a8
+++ b/vl.c
9ae3a8
@@ -844,45 +844,6 @@ static int nb_hcis;
9ae3a8
 static int cur_hci;
9ae3a8
 static struct HCIInfo *hci_table[MAX_NICS];
9ae3a8
 
9ae3a8
-static struct bt_vlan_s {
9ae3a8
-    struct bt_scatternet_s net;
9ae3a8
-    int id;
9ae3a8
-    struct bt_vlan_s *next;
9ae3a8
-} *first_bt_vlan;
9ae3a8
-
9ae3a8
-/* find or alloc a new bluetooth "VLAN" */
9ae3a8
-static struct bt_scatternet_s *qemu_find_bt_vlan(int id)
9ae3a8
-{
9ae3a8
-    struct bt_vlan_s **pvlan, *vlan;
9ae3a8
-    for (vlan = first_bt_vlan; vlan != NULL; vlan = vlan->next) {
9ae3a8
-        if (vlan->id == id)
9ae3a8
-            return &vlan->net;
9ae3a8
-    }
9ae3a8
-    vlan = g_malloc0(sizeof(struct bt_vlan_s));
9ae3a8
-    vlan->id = id;
9ae3a8
-    pvlan = &first_bt_vlan;
9ae3a8
-    while (*pvlan != NULL)
9ae3a8
-        pvlan = &(*pvlan)->next;
9ae3a8
-    *pvlan = vlan;
9ae3a8
-    return &vlan->net;
9ae3a8
-}
9ae3a8
-
9ae3a8
-static void null_hci_send(struct HCIInfo *hci, const uint8_t *data, int len)
9ae3a8
-{
9ae3a8
-}
9ae3a8
-
9ae3a8
-static int null_hci_addr_set(struct HCIInfo *hci, const uint8_t *bd_addr)
9ae3a8
-{
9ae3a8
-    return -ENOTSUP;
9ae3a8
-}
9ae3a8
-
9ae3a8
-static struct HCIInfo null_hci = {
9ae3a8
-    .cmd_send = null_hci_send,
9ae3a8
-    .sco_send = null_hci_send,
9ae3a8
-    .acl_send = null_hci_send,
9ae3a8
-    .bdaddr_set = null_hci_addr_set,
9ae3a8
-};
9ae3a8
-
9ae3a8
 struct HCIInfo *qemu_next_hci(void)
9ae3a8
 {
9ae3a8
     if (cur_hci == nb_hcis)
9ae3a8
@@ -891,36 +852,6 @@ struct HCIInfo *qemu_next_hci(void)
9ae3a8
     return hci_table[cur_hci++];
9ae3a8
 }
9ae3a8
 
9ae3a8
-static struct HCIInfo *hci_init(const char *str)
9ae3a8
-{
9ae3a8
-    char *endp;
9ae3a8
-    struct bt_scatternet_s *vlan = 0;
9ae3a8
-
9ae3a8
-    if (!strcmp(str, "null"))
9ae3a8
-        /* null */
9ae3a8
-        return &null_hci;
9ae3a8
-    else if (!strncmp(str, "host", 4) && (str[4] == '\0' || str[4] == ':'))
9ae3a8
-        /* host[:hciN] */
9ae3a8
-        return bt_host_hci(str[4] ? str + 5 : "hci0");
9ae3a8
-    else if (!strncmp(str, "hci", 3)) {
9ae3a8
-        /* hci[,vlan=n] */
9ae3a8
-        if (str[3]) {
9ae3a8
-            if (!strncmp(str + 3, ",vlan=", 6)) {
9ae3a8
-                vlan = qemu_find_bt_vlan(strtol(str + 9, &endp, 0));
9ae3a8
-                if (*endp)
9ae3a8
-                    vlan = 0;
9ae3a8
-            }
9ae3a8
-        } else
9ae3a8
-            vlan = qemu_find_bt_vlan(0);
9ae3a8
-        if (vlan)
9ae3a8
-           return bt_new_hci(vlan);
9ae3a8
-    }
9ae3a8
-
9ae3a8
-    fprintf(stderr, "qemu: Unknown bluetooth HCI `%s'.\n", str);
9ae3a8
-
9ae3a8
-    return 0;
9ae3a8
-}
9ae3a8
-
9ae3a8
 static int bt_hci_parse(const char *str)
9ae3a8
 {
9ae3a8
     struct HCIInfo *hci;
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8