mmu-hash*: Don't keep looking for PTEs after we find a match
[qemu/agraf.git] / hw / usb / quirks.c
bloba761a9603232e708a7630019fa65c5d9c17bb0ef
1 /*
2 * USB quirk handling
4 * Copyright (c) 2012 Red Hat, Inc.
6 * Red Hat Authors:
7 * Hans de Goede <hdegoede@redhat.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
15 #include "quirks.h"
16 #include "hw/usb.h"
18 static bool usb_id_match(const struct usb_device_id *ids,
19 uint16_t vendor_id, uint16_t product_id,
20 uint8_t interface_class, uint8_t interface_subclass,
21 uint8_t interface_protocol) {
22 int i;
24 for (i = 0; ids[i].vendor_id != -1; i++) {
25 if (ids[i].vendor_id == vendor_id &&
26 ids[i].product_id == product_id &&
27 (ids[i].interface_class == -1 ||
28 (ids[i].interface_class == interface_class &&
29 ids[i].interface_subclass == interface_subclass &&
30 ids[i].interface_protocol == interface_protocol))) {
31 return true;
34 return false;
37 int usb_get_quirks(uint16_t vendor_id, uint16_t product_id,
38 uint8_t interface_class, uint8_t interface_subclass,
39 uint8_t interface_protocol)
41 int quirks = 0;
43 if (usb_id_match(usbredir_raw_serial_ids, vendor_id, product_id,
44 interface_class, interface_subclass, interface_protocol)) {
45 quirks |= USB_QUIRK_BUFFER_BULK_IN;
47 if (usb_id_match(usbredir_ftdi_serial_ids, vendor_id, product_id,
48 interface_class, interface_subclass, interface_protocol)) {
49 quirks |= USB_QUIRK_BUFFER_BULK_IN | USB_QUIRK_IS_FTDI;
52 return quirks;