9ae3a8
From d23a5d0e1d9a437515d566e29706e12373de9e25 Mon Sep 17 00:00:00 2001
9ae3a8
From: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
Date: Mon, 16 Sep 2013 14:38:25 +0200
9ae3a8
Subject: [PATCH 17/29] Remove dev-bluetooth.c dependency from vl.c
9ae3a8
9ae3a8
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
Message-id: <1948c111aeb1ae630ad580f4805d57c35eccceef.1379325610.git.mrezanin@redhat.com>
9ae3a8
Patchwork-id: 54395
9ae3a8
O-Subject: [RHEL7 qemu-kvm PATCH 2/2] Remove dev-bluetooth.c dependency from vl.c
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
Use usb_legacy_register handling to create bt-dongle device and remove code
9ae3a8
dependency from vl.c so CONFIG_USB_BLUETOOTH can be disabled.
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
(cherry picked from commit 615fe4de4b3c26619611078960d3103550bde7d0)
9ae3a8
---
9ae3a8
 hw/usb/Makefile.objs   |  3 ---
9ae3a8
 hw/usb/dev-bluetooth.c | 10 +++++++++-
9ae3a8
 include/hw/usb.h       |  3 ---
9ae3a8
 vl.c                   | 13 ++++---------
9ae3a8
 4 files changed, 13 insertions(+), 16 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/usb/Makefile.objs   |    3 ---
9ae3a8
 hw/usb/dev-bluetooth.c |   10 +++++++++-
9ae3a8
 include/hw/usb.h       |    3 ---
9ae3a8
 vl.c                   |   13 ++++---------
9ae3a8
 4 files changed, 13 insertions(+), 16 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs
9ae3a8
index f9695e7..a3eac3e 100644
9ae3a8
--- a/hw/usb/Makefile.objs
9ae3a8
+++ b/hw/usb/Makefile.objs
9ae3a8
@@ -18,9 +18,6 @@ common-obj-$(CONFIG_USB_STORAGE_UAS)  += dev-uas.o
9ae3a8
 common-obj-$(CONFIG_USB_AUDIO)        += dev-audio.o
9ae3a8
 common-obj-$(CONFIG_USB_SERIAL)       += dev-serial.o
9ae3a8
 common-obj-$(CONFIG_USB_NETWORK)      += dev-network.o
9ae3a8
-
9ae3a8
-# FIXME: make configurable too
9ae3a8
-CONFIG_USB_BLUETOOTH := y
9ae3a8
 common-obj-$(CONFIG_USB_BLUETOOTH)    += dev-bluetooth.o
9ae3a8
 
9ae3a8
 ifeq ($(CONFIG_USB_SMARTCARD),y)
9ae3a8
diff --git a/hw/usb/dev-bluetooth.c b/hw/usb/dev-bluetooth.c
9ae3a8
index 68cc1d4..786e30e 100644
9ae3a8
--- a/hw/usb/dev-bluetooth.c
9ae3a8
+++ b/hw/usb/dev-bluetooth.c
9ae3a8
@@ -511,10 +511,17 @@ static int usb_bt_initfn(USBDevice *dev)
9ae3a8
     return 0;
9ae3a8
 }
9ae3a8
 
9ae3a8
-USBDevice *usb_bt_init(USBBus *bus, HCIInfo *hci)
9ae3a8
+static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline)
9ae3a8
 {
9ae3a8
     USBDevice *dev;
9ae3a8
     struct USBBtState *s;
9ae3a8
+    HCIInfo *hci;
9ae3a8
+
9ae3a8
+    if (*cmdline) {
9ae3a8
+        hci = hci_init(cmdline);
9ae3a8
+    } else {
9ae3a8
+        hci = bt_new_hci(qemu_find_bt_vlan(0));
9ae3a8
+    }
9ae3a8
 
9ae3a8
     if (!hci)
9ae3a8
         return NULL;
9ae3a8
@@ -565,6 +572,7 @@ static const TypeInfo bt_info = {
9ae3a8
 static void usb_bt_register_types(void)
9ae3a8
 {
9ae3a8
     type_register_static(&bt_info);
9ae3a8
+    usb_legacy_register("usb-bt-dongle", "bt", usb_bt_init);
9ae3a8
 }
9ae3a8
 
9ae3a8
 type_init(usb_bt_register_types)
9ae3a8
diff --git a/include/hw/usb.h b/include/hw/usb.h
9ae3a8
index 901b0da..695d853 100644
9ae3a8
--- a/include/hw/usb.h
9ae3a8
+++ b/include/hw/usb.h
9ae3a8
@@ -442,9 +442,6 @@ int set_usb_string(uint8_t *buf, const char *str);
9ae3a8
 USBDevice *usb_host_device_open(USBBus *bus, const char *devname);
9ae3a8
 void usb_host_info(Monitor *mon, const QDict *qdict);
9ae3a8
 
9ae3a8
-/* usb-bt.c */
9ae3a8
-USBDevice *usb_bt_init(USBBus *bus, HCIInfo *hci);
9ae3a8
-
9ae3a8
 /* usb ports of the VM */
9ae3a8
 
9ae3a8
 #define VM_USB_HUB_SIZE 8
9ae3a8
diff --git a/vl.c b/vl.c
9ae3a8
index d022f50..a40ab13 100644
9ae3a8
--- a/vl.c
9ae3a8
+++ b/vl.c
9ae3a8
@@ -1427,8 +1427,10 @@ static void configure_msg(QemuOpts *opts)
9ae3a8
 
9ae3a8
 static int usb_device_add(const char *devname)
9ae3a8
 {
9ae3a8
-    const char *p;
9ae3a8
     USBDevice *dev = NULL;
9ae3a8
+#ifndef CONFIG_LINUX
9ae3a8
+    const char *p;
9ae3a8
+#endif
9ae3a8
 
9ae3a8
     if (!usb_enabled(false)) {
9ae3a8
         return -1;
9ae3a8
@@ -1444,15 +1446,8 @@ static int usb_device_add(const char *devname)
9ae3a8
     /* only the linux version is qdev-ified, usb-bsd still needs this */
9ae3a8
     if (strstart(devname, "host:", &p)) {
9ae3a8
         dev = usb_host_device_open(usb_bus_find(-1), p);
9ae3a8
-    } else
9ae3a8
-#endif
9ae3a8
-    if (!strcmp(devname, "bt") || strstart(devname, "bt:", &p)) {
9ae3a8
-        dev = usb_bt_init(usb_bus_find(-1),
9ae3a8
-                          devname[2] ? hci_init(p)
9ae3a8
-                                     : bt_new_hci(qemu_find_bt_vlan(0)));
9ae3a8
-    } else {
9ae3a8
-        return -1;
9ae3a8
     }
9ae3a8
+#endif
9ae3a8
     if (!dev)
9ae3a8
         return -1;
9ae3a8
 
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8