]> git.proxmox.com Git - qemu.git/blobdiff - hw/usb-ccid.c
Merge remote-tracking branch 'spice/spice.v39' into staging
[qemu.git] / hw / usb-ccid.c
index 44156cc1d8d3de24d5923c62a395675a030b9076..d3922998c5e45a7fedb482076e8cca4c36643751 100644 (file)
@@ -22,7 +22,7 @@
  *  "Universal Serial Bus, Device Class: Smart Card"
  *  Specification for Integrated Circuit(s) Cards Interface Devices
  *
- * Endianess note: from the spec (1.3)
+ * Endianness note: from the spec (1.3)
  *  "Fields that are larger than a byte are stored in little endian"
  *
  * KNOWN BUGS
@@ -172,7 +172,7 @@ enum {
     CLOCK_STATUS_RUNNING = 0,
     /*
      * 0 - Clock Running, 1 - Clock stopped in State L, 2 - H,
-     * 3 - unkonwn state. rest are RFU
+     * 3 - unknown state. rest are RFU
      */
 };
 
@@ -255,17 +255,18 @@ enum {
     MIGRATION_MIGRATED,
 };
 
-typedef struct CCIDBus CCIDBus;
-typedef struct USBCCIDState USBCCIDState;
+typedef struct CCIDBus {
+    BusState qbus;
+} CCIDBus;
 
 #define MAX_PROTOCOL_SIZE   7
 
 /*
  * powered - defaults to true, changed by PowerOn/PowerOff messages
  */
-struct USBCCIDState {
+typedef struct USBCCIDState {
     USBDevice dev;
-    CCIDBus *bus;
+    CCIDBus bus;
     CCIDCardState *card;
     CCIDCardInfo *cardinfo; /* caching the info pointer */
     BulkIn bulk_in_pending[BULK_IN_PENDING_NUM]; /* circular */
@@ -293,7 +294,7 @@ struct USBCCIDState {
     uint8_t  powered;
     uint8_t  notify_slot_change;
     uint8_t  debug;
-};
+} USBCCIDState;
 
 /*
  * CCID Spec chapter 4: CCID uses a standard device descriptor per Chapter 9,
@@ -602,8 +603,8 @@ static void ccid_handle_reset(USBDevice *dev)
     ccid_reset(s);
 }
 
-static int ccid_handle_control(USBDevice *dev, int request, int value,
-                                  int index, int length, uint8_t *data)
+static int ccid_handle_control(USBDevice *dev, USBPacket *p, int request,
+                               int value, int index, int length, uint8_t *data)
 {
     USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev);
     int ret = 0;
@@ -1113,10 +1114,6 @@ static void ccid_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
     }
 }
 
-struct CCIDBus {
-    BusState qbus;
-};
-
 static struct BusInfo ccid_bus_info = {
     .name = "ccid-bus",
     .size = sizeof(CCIDBus),
@@ -1127,16 +1124,6 @@ static struct BusInfo ccid_bus_info = {
     }
 };
 
-static CCIDBus *ccid_bus_new(DeviceState *dev)
-{
-    CCIDBus *bus;
-
-    bus = FROM_QBUS(CCIDBus, qbus_create(&ccid_bus_info, dev, NULL));
-    bus->qbus.allow_hotplug = 1;
-
-    return bus;
-}
-
 void ccid_card_send_apdu_to_guest(CCIDCardState *card,
                                   uint8_t *apdu, uint32_t len)
 {
@@ -1200,7 +1187,7 @@ void ccid_card_card_error(CCIDCardState *card, uint64_t error)
     s->bmCommandStatus = COMMAND_STATUS_FAILED;
     s->last_answer_error = error;
     DPRINTF(s, 1, "VSC_Error: %" PRIX64 "\n", s->last_answer_error);
-    /* TODO: these error's should be more verbose and propogated to the guest.*/
+    /* TODO: these errors should be more verbose and propagated to the guest.*/
     /*
      * We flush all pending answers on CardRemove message in ccid-card-passthru,
      * so check that first to not trigger abort
@@ -1253,7 +1240,7 @@ static int ccid_card_init(DeviceState *qdev, DeviceInfo *base)
         return -1;
     }
     if (s->card != NULL) {
-        error_report("Warning: usb-ccid card already full, not adding\n");
+        error_report("Warning: usb-ccid card already full, not adding");
         return -1;
     }
     ret = info->initfn ? info->initfn(card) : ret;
@@ -1276,13 +1263,15 @@ static int ccid_initfn(USBDevice *dev)
 {
     USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev);
 
-    s->bus = ccid_bus_new(&dev->qdev);
+    qbus_create_inplace(&s->bus.qbus, &ccid_bus_info, &dev->qdev, NULL);
+    s->bus.qbus.allow_hotplug = 1;
     s->card = NULL;
     s->cardinfo = NULL;
     s->migration_state = MIGRATION_NONE;
     s->migration_target_ip = 0;
     s->migration_target_port = 0;
     s->dev.speed = USB_SPEED_FULL;
+    s->dev.speedmask = USB_SPEED_MASK_FULL;
     s->notify_slot_change = false;
     s->powered = true;
     s->pending_answers_num = 0;
@@ -1319,7 +1308,7 @@ static void ccid_pre_save(void *opaque)
     if (s->dev.attached) {
         /*
          * Migrating an open device, ignore reconnection CHR_EVENT to avoid an
-         * erronous detach.
+         * erroneous detach.
          */
         s->migration_state = MIGRATION_MIGRATED;
     }