+static int detect_short_transfer_quirk(const struct sr_dev_inst *sdi)
+{
+ struct dev_context *devc;
+ struct sr_usb_dev_inst *usb;
+ int xfer_len, ret;
+ uint16_t command[3];
+ unsigned char buf[512];
+ const int lreg_count = 10;
+
+ devc = sdi->priv;
+ usb = sdi->conn;
+
+ command[0] = LWLA_WORD(CMD_READ_LREGS);
+ command[1] = LWLA_WORD(0);
+ command[2] = LWLA_WORD(lreg_count);
+
+ ret = lwla_send_command(usb, ARRAY_AND_SIZE(command));
+ if (ret != SR_OK)
+ return ret;
+
+ ret = lwla_receive_reply(usb, buf, sizeof(buf), &xfer_len);
+ if (ret != SR_OK)
+ return ret;
+
+ devc->short_transfer_quirk = (xfer_len == 64);
+
+ if (xfer_len == 8 * lreg_count)
+ return SR_OK;
+
+ if (xfer_len == 64) {
+ /* Drain the tailing portion of the split transfer. */
+ ret = lwla_receive_reply(usb, buf, sizeof(buf), &xfer_len);
+ if (ret != SR_OK)
+ return ret;
+
+ if (xfer_len == 8 * lreg_count - 64)
+ return SR_OK;
+ }
+ sr_err("Received response of unexpected length %d.", xfer_len);
+
+ return SR_ERR;
+}
+
+/* Select and transfer FPGA bitstream for the current configuration. */