[dev][usb-peripheral] Fix support for control requests with USB_RECIP_DEVICE

Before this change, only requests with USB_RECIP_INTERFACE and USB_RECIP_ENDPOINT
were being delegated to the function driver.

TEST: This is a fix to unblock https://fuchsia-review.googlesource.com/c/fuchsia/+/285198
      which is adding tests to the FTDI driver to run in usb-virtual-bus.
      So this change will also be covered by that test.


Change-Id: I14379aea7fde25a37d7d69fbb322dcb78fad55bb
diff --git a/zircon/system/dev/usb/usb-peripheral/usb-peripheral.cpp b/zircon/system/dev/usb/usb-peripheral/usb-peripheral.cpp
index da0b1dc..eb974a0 100644
--- a/zircon/system/dev/usb/usb-peripheral/usb-peripheral.cpp
+++ b/zircon/system/dev/usb/usb-peripheral/usb-peripheral.cpp
@@ -626,6 +626,20 @@
             *static_cast<uint8_t*>(read_buffer) = configuration_;
             *out_read_actual = sizeof(uint8_t);
             return ZX_OK;
+        } else {
+            // Delegate to one of the function drivers.
+            // USB_RECIP_DEVICE should only be used when there is a single active interface.
+            // But just to be conservative, try all the available interfaces.
+            for (size_t i = 0; i < countof(interface_map_); i++) {
+                auto function = interface_map_[index];
+                if (function != nullptr) {
+                    auto status = function->Control(setup, write_buffer, write_size, read_buffer,
+                                                    read_size, out_read_actual);
+                    if (status == ZX_OK) {
+                        return ZX_OK;
+                    }
+                }
+            }
         }
         break;
     case USB_RECIP_INTERFACE: {