Blame SOURCES/kvm-Preparation-for-usb-bt-dongle-conditional-build.patch

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