static int recv_from_unipro(unsigned int cportid, void *payload, size_t len) { char *buf; int ret; len = gb_packet_size(payload); buf = malloc(len + 1); if (!buf) return -ENOMEM; gb_dump(payload, len); /* * TODO * Update UniPro driver to allocate a buffer that can contain * the cport number and the data in order to avoid the recopy. */ memcpy(buf, &cportid, 1); memcpy(buf + 1, payload, len); ret = unipro_to_usb(g_usbdev, buf, len + 1); free(buf); return ret; }
int recv_from_unipro(unsigned int cportid, void *buf, size_t len) { /* * FIXME: Remove when UniPro driver provides the actual buffer length. */ len = gb_packet_size(buf); gb_dump(buf, len); if (len < sizeof(struct gb_operation_hdr)) return -EPROTO; return unipro_to_usb(g_usbdev, cportid, buf, len); }