Skip to contentSkip to conversation

Make usb-bt-dongle configurable

PATCH In review [email protected] 2 participants 4 messages Sep 3, 2013

lore
Share & tools
lore
#0 lore raw

v3 cover Make usb-bt-dongle configurable

From: Miroslav Rezanina <[email protected]>

There's group of options allowing enable/disable usb devices. However, CONFIG_USB_BLUETOOTH can't be removed as there's dependency in vl.c file.

This serie allow CONFIG_USB_BLUETOOTH to be disabled.

v3:
- split patch to two parts

v2:
- patch rewritten to use usb_legacy_register

Miroslav Rezanina (2):
Preparation for usb-bt-dongle conditional build
Make usb-bt-dongle configurable

 hw/bt/core.c           | 23 ++++++++++++++
 hw/bt/hci.c            | 48 +++++++++++++++++++++++++++++
 hw/usb/Makefile.objs   |  3 --
 hw/usb/dev-bluetooth.c | 10 +++++-
 include/hw/bt.h        |  3 ++
 include/hw/usb.h       |  3 --
 vl.c                   | 82 +++-----------------------------------------------
 7 files changed, 87 insertions(+), 85 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v3 1/2 Preparation for usb-bt-dongle conditional build

From: Miroslav Rezanina <[email protected]>

To allow disable usb-bt-dongle device using CONFIG_BLUETOOTH option, some of functions in vl.c file has to be made accessible in dev-bluetooth.c. This is pure code moving.

---
 hw/bt/core.c    | 23 +++++++++++++++++++
 hw/bt/hci.c     | 48 +++++++++++++++++++++++++++++++++++++++
 include/hw/bt.h |  3 +++
 vl.c            | 69 ---------------------------------------------------------
 4 files changed, 74 insertions(+), 69 deletions(-)
hw/bt/core.c +23 -0
index 49012e0..0ffc948 100644
@@ -119,3 +119,26 @@ void bt_device_done(struct bt_device_s *dev)
 
     *p = dev->next;
 }
+
+static struct bt_vlan_s {
+    struct bt_scatternet_s net;
+    int id;
+    struct bt_vlan_s *next;
+} *first_bt_vlan;
+
+/* find or alloc a new bluetooth "VLAN" */
+struct bt_scatternet_s *qemu_find_bt_vlan(int id)
+{
+    struct bt_vlan_s **pvlan, *vlan;
+    for (vlan = first_bt_vlan; vlan != NULL; vlan = vlan->next) {
+        if (vlan->id == id)
+            return &vlan->net;
+    }
+    vlan = g_malloc0(sizeof(struct bt_vlan_s));
+    vlan->id = id;
+    pvlan = &first_bt_vlan;
+    while (*pvlan != NULL)
+        pvlan = &(*pvlan)->next;
+    *pvlan = vlan;
+    return &vlan->net;
+}
hw/bt/hci.c +48 -0

60 lines not on this page · raw message

include/hw/bt.h +3 -0
index 830af94..49a9d03 100644
@@ -108,12 +108,15 @@ struct bt_device_s {
     uint16_t clkoff;	/* Note: Always little-endian */
 };
 
+extern struct HCIInfo null_hci;
 /* bt.c */
 void bt_device_init(struct bt_device_s *dev, struct bt_scatternet_s *net);
 void bt_device_done(struct bt_device_s *dev);
+struct bt_scatternet_s *qemu_find_bt_vlan(int id);
 
 /* bt-hci.c */
 struct HCIInfo *bt_new_hci(struct bt_scatternet_s *net);
+struct HCIInfo *hci_init(const char *str);
 
 /* bt-vhci.c */
 void bt_vhci_init(struct HCIInfo *info);
vl.c +0 -69

81 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v3 2/2 Remove dev-bluetooth.c dependency from vl.c

In reply to [email protected]

From: Miroslav Rezanina <[email protected]>

Use usb_legacy_register handling to create bt-dongle device and remove code dependency from vl.c so CONFIG_USB_BLUETOOTH can be disabled.

---
 hw/usb/Makefile.objs   |  3 ---
 hw/usb/dev-bluetooth.c | 10 +++++++++-
 include/hw/usb.h       |  3 ---
 vl.c                   | 13 ++++---------
 4 files changed, 13 insertions(+), 16 deletions(-)
hw/usb/Makefile.objs +0 -3
index f9695e7..a3eac3e 100644
@@ -18,9 +18,6 @@ common-obj-$(CONFIG_USB_STORAGE_UAS)  += dev-uas.o
 common-obj-$(CONFIG_USB_AUDIO)        += dev-audio.o
 common-obj-$(CONFIG_USB_SERIAL)       += dev-serial.o
 common-obj-$(CONFIG_USB_NETWORK)      += dev-network.o
-
-# FIXME: make configurable too
-CONFIG_USB_BLUETOOTH := y
 common-obj-$(CONFIG_USB_BLUETOOTH)    += dev-bluetooth.o
 
 ifeq ($(CONFIG_USB_SMARTCARD),y)
hw/usb/dev-bluetooth.c +9 -1
index f2fc2a8..7f292b1 100644
@@ -511,10 +511,17 @@ static int usb_bt_initfn(USBDevice *dev)
     return 0;
 }
 
-USBDevice *usb_bt_init(USBBus *bus, HCIInfo *hci)
+static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline)
 {
     USBDevice *dev;
     struct USBBtState *s;
+    HCIInfo *hci;
+
+    if (*cmdline) {
+        hci = hci_init(cmdline);
+    } else {
+        hci = bt_new_hci(qemu_find_bt_vlan(0));
+    }
 
     if (!hci)
         return NULL;
@@ -566,6 +573,7 @@ static const TypeInfo bt_info = {
 static void usb_bt_register_types(void)
 {
     type_register_static(&bt_info);
+    usb_legacy_register("usb-bt-dongle", "bt", usb_bt_init);
 }
 
 type_init(usb_bt_register_types)
include/hw/usb.h +0 -3
index 901b0da..695d853 100644
@@ -442,9 +442,6 @@ int set_usb_string(uint8_t *buf, const char *str);
 USBDevice *usb_host_device_open(USBBus *bus, const char *devname);
 void usb_host_info(Monitor *mon, const QDict *qdict);
 
-/* usb-bt.c */
-USBDevice *usb_bt_init(USBBus *bus, HCIInfo *hci);
-
 /* usb ports of the VM */
 
 #define VM_USB_HUB_SIZE 8
vl.c +4 -9
index 2721a62..794e6b3 100644
@@ -1457,8 +1457,10 @@ static void configure_msg(QemuOpts *opts)
 
 static int usb_device_add(const char *devname)
 {
-    const char *p;
     USBDevice *dev = NULL;
+#ifndef CONFIG_LINUX
+    const char *p;
+#endif
 
     if (!usb_enabled(false)) {
         return -1;
@@ -1474,15 +1476,8 @@ static int usb_device_add(const char *devname)
     /* only the linux version is qdev-ified, usb-bsd still needs this */
     if (strstart(devname, "host:", &p)) {
         dev = usb_host_device_open(usb_bus_find(-1), p);
-    } else
-#endif
-    if (!strcmp(devname, "bt") || strstart(devname, "bt:", &p)) {
-        dev = usb_bt_init(usb_bus_find(-1),
-                          devname[2] ? hci_init(p)
-                                     : bt_new_hci(qemu_find_bt_vlan(0)));
-    } else {
-        return -1;
     }
+#endif
     if (!dev)
         return -1;
 
Signature · 1 line
1.8.3.1