+ DB(USBSerial *fds = USB_SERIAL_CAST(fd));
+
+ /* Silent compiler warnings if _DEBUG is not enabled */
+ (void)fd;
+ ASSERT(fds->is_open);
+ return usb_ep_read(usb_serial_ep_out_descriptor.bEndpointAddress,
+ buf, size);
+}
+
+/**
+ * Return the status of a usb-serial port.
+ *
+ * \todo properly implement usb-serial error handling.
+ */
+static int usb_serial_error(struct KFile *fd)
+{
+ USBSerial *fds = USB_SERIAL_CAST(fd);
+ return fds->status;
+}
+
+/**
+ * Clear the status of a usb-serial port.
+ *
+ * \todo properly implement usb-serial error handling.
+ */
+static void usb_serial_clearerr(struct KFile *fd)
+{
+ USBSerial *fds = USB_SERIAL_CAST(fd);
+ fds->status = 0;
+}
+
+/**
+ * Close an USB serial port.
+ */
+static int usb_serial_close(struct KFile *fd)
+{
+ DB(USBSerial *fds = USB_SERIAL_CAST(fd));
+
+ /* Silent compiler warnings if _DEBUG is not enabled */
+ (void)fd;
+ ASSERT(fds->is_open);
+ DB(fds->is_open = false);
+ return 0;
+}
+
+/**
+ * Initialize an USB serial port.
+ *
+ * \param fd KFile Serial struct interface.
+ * \param unit Serial unit to open.
+ */
+static int usb_serial_open(struct USBSerial *fds, int unit)
+{
+ unit = unit;
+ ASSERT(!fds->is_open);
+ /* TODO: only a single usb-serial unit is supported for now */
+ ASSERT(unit == 0);
+
+ /* Initialize usb-serial driver */
+ if (usb_serial_hw_init() < 0)