diff options
-rw-r--r-- | hw/input/hid.c | 4 | ||||
-rw-r--r-- | hw/usb/ccid-card-emulated.c | 29 | ||||
-rw-r--r-- | hw/usb/dev-bluetooth.c | 24 | ||||
-rw-r--r-- | hw/usb/host-libusb.c | 4 |
4 files changed, 30 insertions, 31 deletions
diff --git a/hw/input/hid.c b/hw/input/hid.c index 9656e90c59..148c003bb2 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -124,7 +124,7 @@ static void hid_pointer_event(DeviceState *dev, QemuConsole *src, if (evt->rel->axis == INPUT_AXIS_X) { e->xdx += evt->rel->value; } else if (evt->rel->axis == INPUT_AXIS_Y) { - e->ydy -= evt->rel->value; + e->ydy += evt->rel->value; } break; @@ -191,7 +191,7 @@ static void hid_pointer_sync(DeviceState *dev) if (hs->kind == HID_MOUSE) { prev->xdx += curr->xdx; curr->xdx = 0; - prev->ydy -= curr->ydy; + prev->ydy += curr->ydy; curr->ydy = 0; } else { prev->xdx = curr->xdx; diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c index 7213c8909c..aa1c37aabd 100644 --- a/hw/usb/ccid-card-emulated.c +++ b/hw/usb/ccid-card-emulated.c @@ -126,7 +126,7 @@ struct EmulatedState { QemuMutex vreader_mutex; /* and guest_apdu_list mutex */ QemuMutex handle_apdu_mutex; QemuCond handle_apdu_cond; - int pipe[2]; + EventNotifier notifier; int quit_apdu_thread; QemuThread apdu_thread_id; }; @@ -162,9 +162,7 @@ static void emulated_push_event(EmulatedState *card, EmulEvent *event) qemu_mutex_lock(&card->event_list_mutex); QSIMPLEQ_INSERT_TAIL(&(card->event_list), event, entry); qemu_mutex_unlock(&card->event_list_mutex); - if (write(card->pipe[1], card, 1) != 1) { - DPRINTF(card, 1, "write to pipe failed\n"); - } + event_notifier_set(&card->notifier); } static void emulated_push_type(EmulatedState *card, uint32_t type) @@ -358,16 +356,12 @@ static void *event_thread(void *arg) return NULL; } -static void pipe_read(void *opaque) +static void card_event_handler(EventNotifier *notifier) { - EmulatedState *card = opaque; + EmulatedState *card = container_of(notifier, EmulatedState, notifier); EmulEvent *event, *next; - char dummy; - int len; - do { - len = read(card->pipe[0], &dummy, sizeof(dummy)); - } while (len == sizeof(dummy)); + event_notifier_test_and_clear(&card->notifier); qemu_mutex_lock(&card->event_list_mutex); QSIMPLEQ_FOREACH_SAFE(event, &card->event_list, entry, next) { DPRINTF(card, 2, "event %s\n", emul_event_to_string(event->p.gen.type)); @@ -404,16 +398,13 @@ static void pipe_read(void *opaque) qemu_mutex_unlock(&card->event_list_mutex); } -static int init_pipe_signaling(EmulatedState *card) +static int init_event_notifier(EmulatedState *card) { - if (pipe(card->pipe) < 0) { - DPRINTF(card, 2, "pipe creation failed\n"); + if (event_notifier_init(&card->notifier, false) < 0) { + DPRINTF(card, 2, "event notifier creation failed\n"); return -1; } - fcntl(card->pipe[0], F_SETFL, O_NONBLOCK); - fcntl(card->pipe[1], F_SETFL, O_NONBLOCK); - fcntl(card->pipe[0], F_SETOWN, getpid()); - qemu_set_fd_handler(card->pipe[0], pipe_read, NULL, card); + event_notifier_set_handler(&card->notifier, card_event_handler); return 0; } @@ -500,7 +491,7 @@ static int emulated_initfn(CCIDCardState *base) qemu_cond_init(&card->handle_apdu_cond); card->reader = NULL; card->quit_apdu_thread = 0; - if (init_pipe_signaling(card) < 0) { + if (init_event_notifier(card) < 0) { return -1; } diff --git a/hw/usb/dev-bluetooth.c b/hw/usb/dev-bluetooth.c index a9661d2801..a76e58191e 100644 --- a/hw/usb/dev-bluetooth.c +++ b/hw/usb/dev-bluetooth.c @@ -19,6 +19,7 @@ */ #include "qemu-common.h" +#include "qemu/error-report.h" #include "hw/usb.h" #include "hw/usb/desc.h" #include "sysemu/bt.h" @@ -506,6 +507,14 @@ static int usb_bt_initfn(USBDevice *dev) usb_desc_create_serial(dev); usb_desc_init(dev); + s->dev.opaque = s; + if (!s->hci) { + s->hci = bt_new_hci(qemu_find_bt_vlan(0)); + } + s->hci->opaque = s; + s->hci->evt_recv = usb_bt_out_hci_packet_event; + s->hci->acl_recv = usb_bt_out_hci_packet_acl; + usb_bt_handle_reset(&s->dev); s->intr = usb_ep_get(dev, USB_TOKEN_IN, USB_EVT_EP); return 0; @@ -516,6 +525,7 @@ static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline) USBDevice *dev; struct USBBtState *s; HCIInfo *hci; + const char *name = "usb-bt-dongle"; if (*cmdline) { hci = hci_init(cmdline); @@ -525,19 +535,17 @@ static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline) if (!hci) return NULL; - dev = usb_create_simple(bus, "usb-bt-dongle"); + dev = usb_create(bus, name); if (!dev) { + error_report("Failed to create USB device '%s'", name); return NULL; } s = DO_UPCAST(struct USBBtState, dev, dev); - s->dev.opaque = s; - s->hci = hci; - s->hci->opaque = s; - s->hci->evt_recv = usb_bt_out_hci_packet_event; - s->hci->acl_recv = usb_bt_out_hci_packet_acl; - - usb_bt_handle_reset(&s->dev); + if (qdev_init(&dev->qdev) < 0) { + error_report("Failed to initialize USB device '%s'", name); + return NULL; + } return dev; } diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 33b5b9ff19..c189147f91 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -1522,7 +1522,7 @@ static void usb_host_auto_check(void *unused) { struct USBHostDevice *s; struct USBAutoFilter *f; - libusb_device **devs; + libusb_device **devs = NULL; struct libusb_device_descriptor ddesc; int unconnected = 0; int i, n; @@ -1623,7 +1623,7 @@ static void usb_host_auto_check(void *unused) void usb_host_info(Monitor *mon, const QDict *qdict) { - libusb_device **devs; + libusb_device **devs = NULL; struct libusb_device_descriptor ddesc; char port[16]; int i, n; |