[usbdev] Simple fixes to test software

Correct endpoint direction in handling of SETUP
Update macro-based logging to reflect renaming
Use correct type for returned byte count
Refined documentation for LinkOutErr

Change-Id: I888e826ff865ee52a0262aa143faff150ff89300
Signed-off-by: Adrian Lees <a.lees@lowrisc.org>
diff --git a/hw/ip/usbdev/data/usbdev.hjson b/hw/ip/usbdev/data/usbdev.hjson
index 749dcd2..87d89d3 100644
--- a/hw/ip/usbdev/data/usbdev.hjson
+++ b/hw/ip/usbdev/data/usbdev.hjson
@@ -265,7 +265,7 @@
     { name: "link_out_err",
       desc: '''
             Raised if a packet to an OUT endpoint started to be received but was then dropped due to an error.
-            This error is raised if either the data toggle, token, packet or CRC is invalid or if there is no buffer available in the Received Buffer FIFO.
+            This error is raised if the data toggle, token, packet and/or CRC are invalid, if the Available Buffer FIFO is empty or if the Received Buffer FIFO is full.
             '''
     }
   ]
diff --git a/sw/device/lib/dif/autogen/dif_usbdev_autogen.h b/sw/device/lib/dif/autogen/dif_usbdev_autogen.h
index 293587c..eff9c3f 100644
--- a/sw/device/lib/dif/autogen/dif_usbdev_autogen.h
+++ b/sw/device/lib/dif/autogen/dif_usbdev_autogen.h
@@ -159,9 +159,9 @@
   kDifUsbdevIrqPowered = 15,
   /**
    * Raised if a packet to an OUT endpoint started to be received but was then
-   * dropped due to an error. This error is raised if either the data toggle,
-   * token, packet or CRC is invalid or if there is no buffer available in the
-   * Received Buffer FIFO.
+   * dropped due to an error. This error is raised if the data toggle, token,
+   * packet and/or CRC are invalid, if the Available Buffer FIFO is empty or if
+   * the Received Buffer FIFO is full.
    */
   kDifUsbdevIrqLinkOutErr = 16,
 } dif_usbdev_irq_t;
diff --git a/sw/device/lib/testing/usb_testutils.c b/sw/device/lib/testing/usb_testutils.c
index bd1a1fa..bacc95b 100644
--- a/sw/device/lib/testing/usb_testutils.c
+++ b/sw/device/lib/testing/usb_testutils.c
@@ -161,7 +161,7 @@
       } else {
         // Note: this could happen following endpoint removal
         TRC_S("USB: unexpected RX ");
-        TRC_I(endpoint, 8);
+        TRC_I(ep, 8);
         CHECK_DIF_OK(
             dif_usbdev_buffer_return(ctx->dev, ctx->buffer_pool, &buffer));
       }
diff --git a/sw/device/lib/testing/usb_testutils_controlep.c b/sw/device/lib/testing/usb_testutils_controlep.c
index aada26d..513c0da 100644
--- a/sw/device/lib/testing/usb_testutils_controlep.c
+++ b/sw/device/lib/testing/usb_testutils_controlep.c
@@ -106,7 +106,7 @@
   // Endpoint for SetFeature/ClearFeature/GetStatus requests
   dif_usbdev_endpoint_id_t endpoint = {
       .number = (uint8_t)wIndex,
-      .direction = bmRequestType & 0x80,
+      .direction = ((bmRequestType & 0x80U) != 0U),
   };
   dif_usbdev_buffer_t buffer;
   CHECK_DIF_OK(dif_usbdev_buffer_request(ctx->dev, ctx->buffer_pool, &buffer));
@@ -321,7 +321,7 @@
                                               kDifToggleEnabled));
 
   TRC_C('0' + ctctx->ctrlstate);
-  uint32_t bytes_written;
+  size_t bytes_written;
   // TODO: Should check for canceled IN transactions due to receiving a SETUP
   // packet.
   switch (ctctx->ctrlstate) {