Commit a640f07c authored by Anthony Liguori's avatar Anthony Liguori
Browse files

Merge remote-tracking branch 'kraxel/usb.89' into staging



# By Gerd Hoffmann (2) and Miroslav Rezanina (2)
# Via Gerd Hoffmann
* kraxel/usb.89:
  ehci: save device pointer in EHCIState
  Remove dev-bluetooth.c dependency from vl.c
  Preparation for usb-bt-dongle conditional build
  usb: sanity check setup_index+setup_len in post_load

Message-id: 1378806073-25197-1-git-send-email-kraxel@redhat.com
Signed-off-by: default avatarAnthony Liguori <anthony@codemonkey.ws>
parents f69f0bca adbecc89
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -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;
}
+48 −0
Original line number Diff line number Diff line
@@ -429,6 +429,24 @@ static const uint8_t bt_event_reserved_mask[8] = {
    0xff, 0x9f, 0xfb, 0xff, 0x07, 0x18, 0x00, 0x00,
};


static void null_hci_send(struct HCIInfo *hci, const uint8_t *data, int len)
{
}

static int null_hci_addr_set(struct HCIInfo *hci, const uint8_t *bd_addr)
{
    return -ENOTSUP;
}

struct HCIInfo null_hci = {
    .cmd_send = null_hci_send,
    .sco_send = null_hci_send,
    .acl_send = null_hci_send,
    .bdaddr_set = null_hci_addr_set,
};


static inline uint8_t *bt_hci_event_start(struct bt_hci_s *hci,
                int evt, int len)
{
@@ -2176,6 +2194,36 @@ struct HCIInfo *bt_new_hci(struct bt_scatternet_s *net)
    return &s->info;
}

struct HCIInfo *hci_init(const char *str)
{
    char *endp;
    struct bt_scatternet_s *vlan = 0;

    if (!strcmp(str, "null"))
        /* null */
        return &null_hci;
    else if (!strncmp(str, "host", 4) && (str[4] == '\0' || str[4] == ':'))
        /* host[:hciN] */
        return bt_host_hci(str[4] ? str + 5 : "hci0");
    else if (!strncmp(str, "hci", 3)) {
        /* hci[,vlan=n] */
        if (str[3]) {
            if (!strncmp(str + 3, ",vlan=", 6)) {
                vlan = qemu_find_bt_vlan(strtol(str + 9, &endp, 0));
                if (*endp)
                    vlan = 0;
            }
        } else
            vlan = qemu_find_bt_vlan(0);
        if (vlan)
           return bt_new_hci(vlan);
    }

    fprintf(stderr, "qemu: Unknown bluetooth HCI `%s'.\n", str);

    return 0;
}

static void bt_hci_done(struct HCIInfo *info)
{
    struct bt_hci_s *hci = hci_from_info(info);
+0 −3
Original line number Diff line number Diff line
@@ -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)
+4 −0
Original line number Diff line number Diff line
@@ -47,6 +47,10 @@ static int usb_device_post_load(void *opaque, int version_id)
    } else {
        dev->attached = 1;
    }
    if (dev->setup_index >= sizeof(dev->data_buf) ||
        dev->setup_len >= sizeof(dev->data_buf)) {
        return -EINVAL;
    }
    return 0;
}

+9 −1
Original line number Diff line number Diff line
@@ -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)
Loading