mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-25 15:02:13 +00:00
DM USB: clean up the assert usage
Remove assert in USB mediator code. Tracked-On: #3252 Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com> Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
This commit is contained in:
parent
7e6ff2a176
commit
31e23cd09c
@ -492,9 +492,6 @@ pci_xhci_get_free_vport(struct pci_xhci_vdev *xdev,
|
|||||||
int ports, porte;
|
int ports, porte;
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
assert(di);
|
|
||||||
|
|
||||||
if (di->bcd < 0x300)
|
if (di->bcd < 0x300)
|
||||||
ports = xdev->usb2_port_start;
|
ports = xdev->usb2_port_start;
|
||||||
else
|
else
|
||||||
@ -524,10 +521,6 @@ pci_xhci_set_native_port_assigned(struct pci_xhci_vdev *xdev,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
assert(info);
|
|
||||||
assert(xdev->native_ports);
|
|
||||||
|
|
||||||
for (i = 0; i < XHCI_MAX_VIRT_PORTS; i++)
|
for (i = 0; i < XHCI_MAX_VIRT_PORTS; i++)
|
||||||
if (xdev->native_ports[i].state == VPORT_FREE)
|
if (xdev->native_ports[i].state == VPORT_FREE)
|
||||||
break;
|
break;
|
||||||
@ -547,9 +540,6 @@ pci_xhci_get_native_port_index_by_path(struct pci_xhci_vdev *xdev,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
assert(path);
|
|
||||||
|
|
||||||
for (i = 0; i < XHCI_MAX_VIRT_PORTS; i++)
|
for (i = 0; i < XHCI_MAX_VIRT_PORTS; i++)
|
||||||
if (usb_dev_path_cmp(&xdev->native_ports[i].info.path, path))
|
if (usb_dev_path_cmp(&xdev->native_ports[i].info.path, path))
|
||||||
return i;
|
return i;
|
||||||
@ -562,7 +552,6 @@ pci_xhci_get_native_port_index_by_vport(struct pci_xhci_vdev *xdev,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
for (i = 0; i < XHCI_MAX_VIRT_PORTS; i++)
|
for (i = 0; i < XHCI_MAX_VIRT_PORTS; i++)
|
||||||
if (xdev->native_ports[i].vport == vport)
|
if (xdev->native_ports[i].vport == vport)
|
||||||
return i;
|
return i;
|
||||||
@ -576,10 +565,6 @@ pci_xhci_clr_native_port_assigned(struct pci_xhci_vdev *xdev,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
assert(info);
|
|
||||||
assert(xdev->native_ports);
|
|
||||||
|
|
||||||
i = pci_xhci_get_native_port_index_by_path(xdev, &info->path);
|
i = pci_xhci_get_native_port_index_by_path(xdev, &info->path);
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
xdev->native_ports[i].state = VPORT_FREE;
|
xdev->native_ports[i].state = VPORT_FREE;
|
||||||
@ -687,8 +672,6 @@ xhci_vbdp_thread(void *data)
|
|||||||
struct pci_xhci_native_port *p;
|
struct pci_xhci_native_port *p;
|
||||||
|
|
||||||
xdev = data;
|
xdev = data;
|
||||||
assert(xdev);
|
|
||||||
|
|
||||||
while (xdev->vbdp_polling) {
|
while (xdev->vbdp_polling) {
|
||||||
|
|
||||||
sem_wait(&xdev->vbdp_sem);
|
sem_wait(&xdev->vbdp_sem);
|
||||||
@ -730,12 +713,6 @@ pci_xhci_native_usb_dev_conn_cb(void *hci_data, void *dev_data)
|
|||||||
int s3_conn = 0;
|
int s3_conn = 0;
|
||||||
|
|
||||||
xdev = hci_data;
|
xdev = hci_data;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
assert(dev_data);
|
|
||||||
assert(xdev->devices);
|
|
||||||
assert(xdev->slots);
|
|
||||||
|
|
||||||
di = dev_data;
|
di = dev_data;
|
||||||
|
|
||||||
/* print physical information about new device */
|
/* print physical information about new device */
|
||||||
@ -821,12 +798,7 @@ pci_xhci_native_usb_dev_disconn_cb(void *hci_data, void *dev_data)
|
|||||||
int rc;
|
int rc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
assert(hci_data);
|
|
||||||
assert(dev_data);
|
|
||||||
|
|
||||||
xdev = hci_data;
|
xdev = hci_data;
|
||||||
assert(xdev->devices);
|
|
||||||
|
|
||||||
di = dev_data;
|
di = dev_data;
|
||||||
if (!pci_xhci_is_valid_portnum(ROOTHUB_PORT(di->path))) {
|
if (!pci_xhci_is_valid_portnum(ROOTHUB_PORT(di->path))) {
|
||||||
UPRINTF(LFTL, "invalid physical port %d\r\n",
|
UPRINTF(LFTL, "invalid physical port %d\r\n",
|
||||||
@ -890,7 +862,9 @@ pci_xhci_native_usb_dev_disconn_cb(void *hci_data, void *dev_data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(state == VPORT_EMULATED || state == VPORT_CONNECTED);
|
if (!(state == VPORT_EMULATED || state == VPORT_CONNECTED))
|
||||||
|
UPRINTF(LFTL, "error: unexpected state %d\r\n", state);
|
||||||
|
|
||||||
xdev->native_ports[index].state = VPORT_ASSIGNED;
|
xdev->native_ports[index].state = VPORT_ASSIGNED;
|
||||||
xdev->native_ports[index].vport = 0;
|
xdev->native_ports[index].vport = 0;
|
||||||
|
|
||||||
@ -1003,9 +977,6 @@ pci_xhci_dev_create(struct pci_xhci_vdev *xdev, void *dev_data)
|
|||||||
void *ud = NULL;
|
void *ud = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
assert(dev_data);
|
|
||||||
|
|
||||||
ue = calloc(1, sizeof(struct usb_devemu));
|
ue = calloc(1, sizeof(struct usb_devemu));
|
||||||
if (!ue)
|
if (!ue)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1077,7 +1048,6 @@ pci_xhci_dev_destroy(struct pci_xhci_dev_emu *de)
|
|||||||
ud = de->dev_instance;
|
ud = de->dev_instance;
|
||||||
if (ue) {
|
if (ue) {
|
||||||
if (ue->ue_devtype == USB_DEV_PORT_MAPPER) {
|
if (ue->ue_devtype == USB_DEV_PORT_MAPPER) {
|
||||||
assert(ue->ue_deinit);
|
|
||||||
if (ue->ue_deinit)
|
if (ue->ue_deinit)
|
||||||
ue->ue_deinit(ud);
|
ue->ue_deinit(ud);
|
||||||
}
|
}
|
||||||
@ -1142,8 +1112,6 @@ pci_xhci_change_port(struct pci_xhci_vdev *xdev, int port, int usb_speed,
|
|||||||
struct xhci_trb evtrb;
|
struct xhci_trb evtrb;
|
||||||
struct pci_xhci_portregs *reg;
|
struct pci_xhci_portregs *reg;
|
||||||
|
|
||||||
assert(xdev != NULL);
|
|
||||||
|
|
||||||
reg = XHCI_PORTREG_PTR(xdev, port);
|
reg = XHCI_PORTREG_PTR(xdev, port);
|
||||||
if (conn == 0) {
|
if (conn == 0) {
|
||||||
reg->portsc &= ~(XHCI_PS_CCS | XHCI_PS_PED);
|
reg->portsc &= ~(XHCI_PS_CCS | XHCI_PS_PED);
|
||||||
@ -1295,11 +1263,8 @@ pci_xhci_portregs_write(struct pci_xhci_vdev *xdev,
|
|||||||
UPRINTF(LDBG, "portregs wr offset 0x%lx, port %u: 0x%lx\r\n",
|
UPRINTF(LDBG, "portregs wr offset 0x%lx, port %u: 0x%lx\r\n",
|
||||||
offset, port, value);
|
offset, port, value);
|
||||||
|
|
||||||
assert(port >= 0);
|
if (port > XHCI_MAX_DEVS || port < 0) {
|
||||||
|
UPRINTF(LWRN, "portregs_write to bad port %d\r\n", port);
|
||||||
if (port > XHCI_MAX_DEVS) {
|
|
||||||
UPRINTF(LWRN, "portregs_write port %d > ndevices\r\n",
|
|
||||||
port);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1416,10 +1381,7 @@ pci_xhci_apl_drdregs_write(struct pci_xhci_vdev *xdev, uint64_t offset,
|
|||||||
struct pci_xhci_excap *excap;
|
struct pci_xhci_excap *excap;
|
||||||
struct pci_xhci_excap_drd_apl *excap_drd;
|
struct pci_xhci_excap_drd_apl *excap_drd;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
|
|
||||||
excap = xdev->excap_ptr;
|
excap = xdev->excap_ptr;
|
||||||
|
|
||||||
while (excap && excap->start != XHCI_APL_DRDCAP_BASE)
|
while (excap && excap->start != XHCI_APL_DRDCAP_BASE)
|
||||||
excap++;
|
excap++;
|
||||||
|
|
||||||
@ -1485,8 +1447,6 @@ pci_xhci_excap_write(struct pci_xhci_vdev *xdev, uint64_t offset,
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
|
|
||||||
if (xdev->excap_ptr && xdev->excap_write)
|
if (xdev->excap_ptr && xdev->excap_write)
|
||||||
rc = xdev->excap_write(xdev, offset, value);
|
rc = xdev->excap_write(xdev, offset, value);
|
||||||
else
|
else
|
||||||
@ -1503,9 +1463,13 @@ pci_xhci_get_dev_ctx(struct pci_xhci_vdev *xdev, uint32_t slot)
|
|||||||
uint64_t devctx_addr;
|
uint64_t devctx_addr;
|
||||||
struct xhci_dev_ctx *devctx;
|
struct xhci_dev_ctx *devctx;
|
||||||
|
|
||||||
assert(slot > 0 && slot <= XHCI_MAX_SLOTS &&
|
if (slot <= 0 || slot > XHCI_MAX_SLOTS || !xdev->slot_allocated[slot] ||
|
||||||
xdev->slot_allocated[slot]);
|
!xdev->opregs.dcbaa_p) {
|
||||||
assert(xdev->opregs.dcbaa_p != NULL);
|
UPRINTF(LFTL, "invalid ctx: slot %d, alloc %d dcbaa %p\r\n",
|
||||||
|
slot, xdev->slot_allocated[slot],
|
||||||
|
xdev->opregs.dcbaa_p);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
devctx_addr = xdev->opregs.dcbaa_p->dcba[slot];
|
devctx_addr = xdev->opregs.dcbaa_p->dcba[slot];
|
||||||
|
|
||||||
@ -1528,8 +1492,6 @@ pci_xhci_trb_next(struct pci_xhci_vdev *xdev,
|
|||||||
{
|
{
|
||||||
struct xhci_trb *next;
|
struct xhci_trb *next;
|
||||||
|
|
||||||
assert(curtrb != NULL);
|
|
||||||
|
|
||||||
if (XHCI_TRB_3_TYPE_GET(curtrb->dwTrb3) == XHCI_TRB_TYPE_LINK) {
|
if (XHCI_TRB_3_TYPE_GET(curtrb->dwTrb3) == XHCI_TRB_TYPE_LINK) {
|
||||||
if (guestaddr)
|
if (guestaddr)
|
||||||
*guestaddr = curtrb->qwTrb0 & ~0xFUL;
|
*guestaddr = curtrb->qwTrb0 & ~0xFUL;
|
||||||
@ -1606,7 +1568,6 @@ pci_xhci_init_ep(struct pci_xhci_dev_emu *dev, int epid)
|
|||||||
if (pstreams > 0) {
|
if (pstreams > 0) {
|
||||||
UPRINTF(LDBG, "init_ep %d with pstreams %d\r\n",
|
UPRINTF(LDBG, "init_ep %d with pstreams %d\r\n",
|
||||||
epid, pstreams);
|
epid, pstreams);
|
||||||
assert(devep->ep_sctx_trbs == NULL);
|
|
||||||
|
|
||||||
devep->ep_sctx = XHCI_GADDR(dev->xdev, ep_ctx->qwEpCtx2 &
|
devep->ep_sctx = XHCI_GADDR(dev->xdev, ep_ctx->qwEpCtx2 &
|
||||||
XHCI_EPCTX_2_TR_DQ_PTR_MASK);
|
XHCI_EPCTX_2_TR_DQ_PTR_MASK);
|
||||||
@ -1839,7 +1800,6 @@ pci_xhci_cmd_disable_slot(struct pci_xhci_vdev *xdev, uint32_t slot)
|
|||||||
XHCI_PS_CCS | XHCI_PS_PED | XHCI_PS_PP);
|
XHCI_PS_CCS | XHCI_PS_PED | XHCI_PS_PP);
|
||||||
|
|
||||||
udev = dev->dev_instance;
|
udev = dev->dev_instance;
|
||||||
assert(udev);
|
|
||||||
|
|
||||||
xdev->devices[i] = NULL;
|
xdev->devices[i] = NULL;
|
||||||
xdev->slots[slot] = NULL;
|
xdev->slots[slot] = NULL;
|
||||||
@ -2024,7 +1984,6 @@ pci_xhci_cmd_address_device(struct pci_xhci_vdev *xdev,
|
|||||||
dev_ctx->ctx_slot.dwSctx2, dev_ctx->ctx_slot.dwSctx3);
|
dev_ctx->ctx_slot.dwSctx2, dev_ctx->ctx_slot.dwSctx3);
|
||||||
|
|
||||||
dev = XHCI_SLOTDEV_PTR(xdev, slot);
|
dev = XHCI_SLOTDEV_PTR(xdev, slot);
|
||||||
assert(dev != NULL);
|
|
||||||
|
|
||||||
dev->hci.hci_address = slot;
|
dev->hci.hci_address = slot;
|
||||||
dev->dev_ctx = dev_ctx;
|
dev->dev_ctx = dev_ctx;
|
||||||
@ -2225,7 +2184,6 @@ pci_xhci_cmd_reset_ep(struct pci_xhci_vdev *xdev,
|
|||||||
type = XHCI_TRB_3_TYPE_GET(trb->dwTrb3);
|
type = XHCI_TRB_3_TYPE_GET(trb->dwTrb3);
|
||||||
|
|
||||||
dev = XHCI_SLOTDEV_PTR(xdev, slot);
|
dev = XHCI_SLOTDEV_PTR(xdev, slot);
|
||||||
assert(dev != NULL);
|
|
||||||
|
|
||||||
if (type == XHCI_TRB_TYPE_STOP_EP &&
|
if (type == XHCI_TRB_TYPE_STOP_EP &&
|
||||||
(trb->dwTrb3 & XHCI_TRB_3_SUSP_EP_BIT) != 0) {
|
(trb->dwTrb3 & XHCI_TRB_3_SUSP_EP_BIT) != 0) {
|
||||||
@ -2239,7 +2197,6 @@ pci_xhci_cmd_reset_ep(struct pci_xhci_vdev *xdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
dev_ctx = dev->dev_ctx;
|
dev_ctx = dev->dev_ctx;
|
||||||
assert(dev_ctx != NULL);
|
|
||||||
ep_ctx = &dev_ctx->ctx_ep[epid];
|
ep_ctx = &dev_ctx->ctx_ep[epid];
|
||||||
|
|
||||||
if (type == XHCI_TRB_TYPE_RESET_EP &&
|
if (type == XHCI_TRB_TYPE_RESET_EP &&
|
||||||
@ -2326,8 +2283,6 @@ pci_xhci_cmd_set_tr(struct pci_xhci_vdev *xdev,
|
|||||||
cmderr = XHCI_TRB_ERROR_SUCCESS;
|
cmderr = XHCI_TRB_ERROR_SUCCESS;
|
||||||
|
|
||||||
dev = XHCI_SLOTDEV_PTR(xdev, slot);
|
dev = XHCI_SLOTDEV_PTR(xdev, slot);
|
||||||
assert(dev != NULL);
|
|
||||||
|
|
||||||
UPRINTF(LDBG, "set_tr: new-tr x%016lx, SCT %u DCS %u\r\n"
|
UPRINTF(LDBG, "set_tr: new-tr x%016lx, SCT %u DCS %u\r\n"
|
||||||
" stream-id %u, slot %u, epid %u, C %u\r\n",
|
" stream-id %u, slot %u, epid %u, C %u\r\n",
|
||||||
(trb->qwTrb0 & ~0xF), (uint32_t)((trb->qwTrb0 >> 1) & 0x7),
|
(trb->qwTrb0 & ~0xF), (uint32_t)((trb->qwTrb0 >> 1) & 0x7),
|
||||||
@ -2343,8 +2298,6 @@ pci_xhci_cmd_set_tr(struct pci_xhci_vdev *xdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
dev_ctx = dev->dev_ctx;
|
dev_ctx = dev->dev_ctx;
|
||||||
assert(dev_ctx != NULL);
|
|
||||||
|
|
||||||
ep_ctx = &dev_ctx->ctx_ep[epid];
|
ep_ctx = &dev_ctx->ctx_ep[epid];
|
||||||
devep = &dev->eps[epid];
|
devep = &dev->eps[epid];
|
||||||
|
|
||||||
@ -2366,7 +2319,6 @@ pci_xhci_cmd_set_tr(struct pci_xhci_vdev *xdev,
|
|||||||
sctx = NULL;
|
sctx = NULL;
|
||||||
cmderr = pci_xhci_find_stream(xdev, ep_ctx, streamid, &sctx);
|
cmderr = pci_xhci_find_stream(xdev, ep_ctx, streamid, &sctx);
|
||||||
if (sctx != NULL) {
|
if (sctx != NULL) {
|
||||||
assert(devep->ep_sctx != NULL);
|
|
||||||
|
|
||||||
devep->ep_sctx[streamid].qwSctx0 = trb->qwTrb0;
|
devep->ep_sctx[streamid].qwSctx0 = trb->qwTrb0;
|
||||||
devep->ep_sctx_trbs[streamid].ringaddr =
|
devep->ep_sctx_trbs[streamid].ringaddr =
|
||||||
@ -2661,7 +2613,6 @@ pci_xhci_xfer_complete(struct pci_xhci_vdev *xdev,
|
|||||||
int rem_len = 0;
|
int rem_len = 0;
|
||||||
|
|
||||||
dev_ctx = pci_xhci_get_dev_ctx(xdev, slot);
|
dev_ctx = pci_xhci_get_dev_ctx(xdev, slot);
|
||||||
assert(dev_ctx != NULL);
|
|
||||||
|
|
||||||
ep_ctx = &dev_ctx->ctx_ep[epid];
|
ep_ctx = &dev_ctx->ctx_ep[epid];
|
||||||
|
|
||||||
@ -3425,8 +3376,6 @@ pci_xhci_write(struct vmctx *ctx,
|
|||||||
|
|
||||||
xdev = dev->arg;
|
xdev = dev->arg;
|
||||||
|
|
||||||
assert(baridx == 0);
|
|
||||||
|
|
||||||
pthread_mutex_lock(&xdev->mtx);
|
pthread_mutex_lock(&xdev->mtx);
|
||||||
if (offset < XHCI_CAPLEN) /* read only registers */
|
if (offset < XHCI_CAPLEN) /* read only registers */
|
||||||
UPRINTF(LWRN, "write RO-CAPs offset %ld\r\n", offset);
|
UPRINTF(LWRN, "write RO-CAPs offset %ld\r\n", offset);
|
||||||
@ -3614,8 +3563,6 @@ pci_xhci_rtsregs_read(struct pci_xhci_vdev *xdev, uint64_t offset)
|
|||||||
offset -= XHCI_RT_IR_BASE;
|
offset -= XHCI_RT_IR_BASE;
|
||||||
item = offset % 32;
|
item = offset % 32;
|
||||||
|
|
||||||
assert(offset < sizeof(xdev->rtsregs.intrreg));
|
|
||||||
|
|
||||||
p = &xdev->rtsregs.intrreg.iman;
|
p = &xdev->rtsregs.intrreg.iman;
|
||||||
p += item / sizeof(uint32_t);
|
p += item / sizeof(uint32_t);
|
||||||
value = *p;
|
value = *p;
|
||||||
@ -3634,8 +3581,6 @@ pci_xhci_excap_read(struct pci_xhci_vdev *xdev, uint64_t offset)
|
|||||||
uint32_t off = offset;
|
uint32_t off = offset;
|
||||||
struct pci_xhci_excap *excap;
|
struct pci_xhci_excap *excap;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
|
|
||||||
excap = xdev->excap_ptr;
|
excap = xdev->excap_ptr;
|
||||||
|
|
||||||
while (excap && excap->start != EXCAP_GROUP_END) {
|
while (excap && excap->start != EXCAP_GROUP_END) {
|
||||||
@ -3672,8 +3617,6 @@ pci_xhci_read(struct vmctx *ctx,
|
|||||||
|
|
||||||
xdev = dev->arg;
|
xdev = dev->arg;
|
||||||
|
|
||||||
assert(baridx == 0);
|
|
||||||
|
|
||||||
pthread_mutex_lock(&xdev->mtx);
|
pthread_mutex_lock(&xdev->mtx);
|
||||||
if (offset < XHCI_CAPLEN)
|
if (offset < XHCI_CAPLEN)
|
||||||
value = pci_xhci_hostcap_read(xdev, offset);
|
value = pci_xhci_hostcap_read(xdev, offset);
|
||||||
@ -3716,8 +3659,6 @@ pci_xhci_reset_port(struct pci_xhci_vdev *xdev, int portn, int warm)
|
|||||||
int speed, error;
|
int speed, error;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
assert(portn <= XHCI_MAX_DEVS);
|
|
||||||
|
|
||||||
UPRINTF(LINF, "reset port %d\r\n", portn);
|
UPRINTF(LINF, "reset port %d\r\n", portn);
|
||||||
|
|
||||||
port = XHCI_PORTREG_PTR(xdev, portn);
|
port = XHCI_PORTREG_PTR(xdev, portn);
|
||||||
@ -3774,8 +3715,6 @@ pci_xhci_dev_intr(struct usb_hci *hci, int epctx)
|
|||||||
/* HW endpoint contexts are 0-15; convert to epid based on dir */
|
/* HW endpoint contexts are 0-15; convert to epid based on dir */
|
||||||
epid = (epid * 2) + (dir_in ? 1 : 0);
|
epid = (epid * 2) + (dir_in ? 1 : 0);
|
||||||
|
|
||||||
assert(epid >= 1 && epid <= 31);
|
|
||||||
|
|
||||||
dev = hci->dev;
|
dev = hci->dev;
|
||||||
xdev = dev->xdev;
|
xdev = dev->xdev;
|
||||||
|
|
||||||
@ -3850,8 +3789,6 @@ pci_xhci_parse_log_level(struct pci_xhci_vdev *xdev, char *opts)
|
|||||||
char *s, *o;
|
char *s, *o;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
assert(opts);
|
|
||||||
|
|
||||||
o = s = strdup(opts);
|
o = s = strdup(opts);
|
||||||
if (!(s && s[0] == 'l' && s[1] == 'o' && s[2] == 'g')) {
|
if (!(s && s[0] == 'l' && s[1] == 'o' && s[2] == 'g')) {
|
||||||
rc = -1;
|
rc = -1;
|
||||||
@ -3883,9 +3820,6 @@ pci_xhci_parse_bus_port(struct pci_xhci_vdev *xdev, char *opts)
|
|||||||
struct usb_devpath path;
|
struct usb_devpath path;
|
||||||
struct usb_native_devinfo di;
|
struct usb_native_devinfo di;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
assert(opts);
|
|
||||||
|
|
||||||
tstr = opts;
|
tstr = opts;
|
||||||
/* 'bus-port' format */
|
/* 'bus-port' format */
|
||||||
if (!tstr || dm_strtoi(tstr, &tstr, 10, &bus) || *tstr != '-' ||
|
if (!tstr || dm_strtoi(tstr, &tstr, 10, &bus) || *tstr != '-' ||
|
||||||
@ -3933,9 +3867,6 @@ pci_xhci_parse_tablet(struct pci_xhci_vdev *xdev, char *opts)
|
|||||||
uint8_t port_u2, port_u3;
|
uint8_t port_u2, port_u3;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
assert(opts);
|
|
||||||
|
|
||||||
if (strncmp(opts, "tablet", sizeof("tablet") - 1)) {
|
if (strncmp(opts, "tablet", sizeof("tablet") - 1)) {
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto errout;
|
goto errout;
|
||||||
@ -4013,8 +3944,6 @@ pci_xhci_parse_extcap(struct pci_xhci_vdev *xdev, char *opts)
|
|||||||
char *s, *o;
|
char *s, *o;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
assert(opts);
|
|
||||||
|
|
||||||
cap = o = s = strdup(opts);
|
cap = o = s = strdup(opts);
|
||||||
|
|
||||||
s = strchr(opts, '=');
|
s = strchr(opts, '=');
|
||||||
@ -4057,7 +3986,6 @@ pci_xhci_parse_opts(struct pci_xhci_vdev *xdev, char *opts)
|
|||||||
int (*f)(struct pci_xhci_vdev *, char *);
|
int (*f)(struct pci_xhci_vdev *, char *);
|
||||||
int elem_cnt;
|
int elem_cnt;
|
||||||
|
|
||||||
assert(xdev);
|
|
||||||
if (!opts) {
|
if (!opts) {
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto errout;
|
goto errout;
|
||||||
@ -4301,12 +4229,9 @@ pci_xhci_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
struct pci_xhci_vdev *xdev;
|
struct pci_xhci_vdev *xdev;
|
||||||
struct pci_xhci_dev_emu *de;
|
struct pci_xhci_dev_emu *de;
|
||||||
|
|
||||||
assert(dev);
|
|
||||||
xdev = dev->arg;
|
xdev = dev->arg;
|
||||||
|
|
||||||
UPRINTF(LINF, "de-initialization\r\n");
|
UPRINTF(LINF, "de-initialization\r\n");
|
||||||
assert(xdev);
|
|
||||||
assert(xdev->devices);
|
|
||||||
|
|
||||||
for (i = 1; i <= XHCI_MAX_DEVS; ++i) {
|
for (i = 1; i <= XHCI_MAX_DEVS; ++i) {
|
||||||
de = xdev->devices[i];
|
de = xdev->devices[i];
|
||||||
|
@ -328,8 +328,6 @@ umouse_request(void *scarg, struct usb_data_xfer *xfer)
|
|||||||
data = NULL;
|
data = NULL;
|
||||||
udata = NULL;
|
udata = NULL;
|
||||||
|
|
||||||
assert(xfer != NULL && xfer->head >= 0);
|
|
||||||
|
|
||||||
idx = xfer->head;
|
idx = xfer->head;
|
||||||
for (i = 0; i < xfer->ndata; i++) {
|
for (i = 0; i < xfer->ndata; i++) {
|
||||||
xfer->data[idx].bdone = 0;
|
xfer->data[idx].bdone = 0;
|
||||||
@ -702,8 +700,6 @@ umouse_data_handler(void *scarg, struct usb_data_xfer *xfer, int dir,
|
|||||||
int len, i, idx;
|
int len, i, idx;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
assert(xfer != NULL && xfer->head >= 0);
|
|
||||||
|
|
||||||
UPRINTF(LDBG, "handle data - DIR=%s|EP=%d, blen %d\r\n",
|
UPRINTF(LDBG, "handle data - DIR=%s|EP=%d, blen %d\r\n",
|
||||||
dir ? "IN" : "OUT", epctx, xfer->data[0].blen);
|
dir ? "IN" : "OUT", epctx, xfer->data[0].blen);
|
||||||
|
|
||||||
|
@ -83,11 +83,7 @@ internal_scan(struct libusb_device ***list, int list_sz, int depth,
|
|||||||
struct libusb_device **devlist;
|
struct libusb_device **devlist;
|
||||||
struct usb_native_devinfo di;
|
struct usb_native_devinfo di;
|
||||||
|
|
||||||
assert(visit);
|
|
||||||
assert(list);
|
|
||||||
assert(visit_sz >= list_sz);
|
|
||||||
devlist = *list;
|
devlist = *list;
|
||||||
|
|
||||||
if (depth >= USB_MAX_TIERS) {
|
if (depth >= USB_MAX_TIERS) {
|
||||||
UPRINTF(LFTL, "max hub layers(7) reached, stop scan\r\n");
|
UPRINTF(LFTL, "max hub layers(7) reached, stop scan\r\n");
|
||||||
return;
|
return;
|
||||||
@ -183,16 +179,11 @@ usb_dev_comp_cb(struct libusb_transfer *trn)
|
|||||||
uint16_t maxp;
|
uint16_t maxp;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
||||||
assert(trn);
|
|
||||||
|
|
||||||
/* async request */
|
/* async request */
|
||||||
r = trn->user_data;
|
r = trn->user_data;
|
||||||
assert(r);
|
|
||||||
assert(r->udev);
|
|
||||||
|
|
||||||
/* async transfer */
|
/* async transfer */
|
||||||
xfer = r->xfer;
|
xfer = r->xfer;
|
||||||
assert(xfer);
|
|
||||||
|
|
||||||
maxp = usb_dev_get_ep_maxp(r->udev, r->in, xfer->epid / 2);
|
maxp = usb_dev_get_ep_maxp(r->udev, r->in, xfer->epid / 2);
|
||||||
if (trn->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) {
|
if (trn->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) {
|
||||||
@ -268,7 +259,8 @@ usb_dev_comp_cb(struct libusb_transfer *trn)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
block = &xfer->data[idx % USB_MAX_XFER_BLOCKS];
|
block = &xfer->data[idx % USB_MAX_XFER_BLOCKS];
|
||||||
assert(block->processed);
|
if (block->processed == USB_XFER_BLK_FREE)
|
||||||
|
UPRINTF(LFTL, "error: found free block\r\n");
|
||||||
|
|
||||||
d = done;
|
d = done;
|
||||||
if (d > block->blen)
|
if (d > block->blen)
|
||||||
@ -370,7 +362,6 @@ usb_dev_prepare_xfer(struct usb_data_xfer *xfer, int *count, int *size)
|
|||||||
int found, i, idx, c, s, first;
|
int found, i, idx, c, s, first;
|
||||||
struct usb_data_xfer_block *block = NULL;
|
struct usb_data_xfer_block *block = NULL;
|
||||||
|
|
||||||
assert(xfer);
|
|
||||||
idx = xfer->head;
|
idx = xfer->head;
|
||||||
found = 0;
|
found = 0;
|
||||||
first = -1;
|
first = -1;
|
||||||
@ -433,8 +424,6 @@ usb_dev_err_convert(int err)
|
|||||||
static inline struct usb_dev_ep *
|
static inline struct usb_dev_ep *
|
||||||
usb_dev_get_ep(struct usb_dev *udev, int pid, int ep)
|
usb_dev_get_ep(struct usb_dev *udev, int pid, int ep)
|
||||||
{
|
{
|
||||||
assert(udev);
|
|
||||||
|
|
||||||
if (ep < 0 || ep >= USB_NUM_ENDPOINT) {
|
if (ep < 0 || ep >= USB_NUM_ENDPOINT) {
|
||||||
UPRINTF(LWRN, "invalid ep %d\r\n", ep);
|
UPRINTF(LWRN, "invalid ep %d\r\n", ep);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -516,7 +505,6 @@ usb_dev_update_ep(struct usb_dev *udev)
|
|||||||
const struct libusb_endpoint_descriptor *desc;
|
const struct libusb_endpoint_descriptor *desc;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
assert(udev);
|
|
||||||
if (libusb_get_active_config_descriptor(udev->info.priv_data, &cfg))
|
if (libusb_get_active_config_descriptor(udev->info.priv_data, &cfg))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -546,10 +534,6 @@ usb_dev_native_toggle_if(struct usb_dev *udev, int claim)
|
|||||||
uint8_t c, i;
|
uint8_t c, i;
|
||||||
int rc = 0, r;
|
int rc = 0, r;
|
||||||
|
|
||||||
assert(udev);
|
|
||||||
assert(udev->handle);
|
|
||||||
assert(claim == 1 || claim == 0);
|
|
||||||
|
|
||||||
path = &udev->info.path;
|
path = &udev->info.path;
|
||||||
r = libusb_get_active_config_descriptor(udev->info.priv_data, &config);
|
r = libusb_get_active_config_descriptor(udev->info.priv_data, &config);
|
||||||
if (r) {
|
if (r) {
|
||||||
@ -596,10 +580,6 @@ usb_dev_native_toggle_if_drivers(struct usb_dev *udev, int attach)
|
|||||||
uint8_t c, i;
|
uint8_t c, i;
|
||||||
int rc = 0, r;
|
int rc = 0, r;
|
||||||
|
|
||||||
assert(udev);
|
|
||||||
assert(udev->handle);
|
|
||||||
assert(attach == 1 || attach == 0);
|
|
||||||
|
|
||||||
path = &udev->info.path;
|
path = &udev->info.path;
|
||||||
r = libusb_get_active_config_descriptor(udev->info.priv_data, &config);
|
r = libusb_get_active_config_descriptor(udev->info.priv_data, &config);
|
||||||
if (r) {
|
if (r) {
|
||||||
@ -642,9 +622,6 @@ usb_dev_set_config(struct usb_dev *udev, struct usb_data_xfer *xfer, int config)
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
struct libusb_config_descriptor *cfg;
|
struct libusb_config_descriptor *cfg;
|
||||||
|
|
||||||
assert(udev);
|
|
||||||
assert(udev->handle);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set configuration
|
* set configuration
|
||||||
* according to the libusb doc, the detach and release work
|
* according to the libusb doc, the detach and release work
|
||||||
@ -693,10 +670,6 @@ static void
|
|||||||
usb_dev_set_if(struct usb_dev *udev, int iface, int alt, struct usb_data_xfer
|
usb_dev_set_if(struct usb_dev *udev, int iface, int alt, struct usb_data_xfer
|
||||||
*xfer)
|
*xfer)
|
||||||
{
|
{
|
||||||
assert(udev);
|
|
||||||
assert(xfer);
|
|
||||||
assert(udev->handle);
|
|
||||||
|
|
||||||
if (iface >= USB_NUM_INTERFACE)
|
if (iface >= USB_NUM_INTERFACE)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
@ -757,7 +730,6 @@ usb_dev_reset(void *pdata)
|
|||||||
struct usb_dev *udev;
|
struct usb_dev *udev;
|
||||||
|
|
||||||
udev = pdata;
|
udev = pdata;
|
||||||
assert(udev);
|
|
||||||
|
|
||||||
UPRINTF(LDBG, "reset endpoints\n");
|
UPRINTF(LDBG, "reset endpoints\n");
|
||||||
libusb_reset_device(udev->handle);
|
libusb_reset_device(udev->handle);
|
||||||
@ -782,7 +754,6 @@ usb_dev_data(void *pdata, struct usb_data_xfer *xfer, int dir, int epctx)
|
|||||||
uint16_t maxp;
|
uint16_t maxp;
|
||||||
|
|
||||||
udev = pdata;
|
udev = pdata;
|
||||||
assert(udev);
|
|
||||||
xfer->status = USB_ERR_NORMAL_COMPLETION;
|
xfer->status = USB_ERR_NORMAL_COMPLETION;
|
||||||
|
|
||||||
blk_start = usb_dev_prepare_xfer(xfer, &blk_count, &data_size);
|
blk_start = usb_dev_prepare_xfer(xfer, &blk_count, &data_size);
|
||||||
@ -934,9 +905,6 @@ usb_dev_request(void *pdata, struct usb_data_xfer *xfer)
|
|||||||
|
|
||||||
udev = pdata;
|
udev = pdata;
|
||||||
|
|
||||||
assert(xfer);
|
|
||||||
assert(udev);
|
|
||||||
|
|
||||||
xfer->status = USB_ERR_NORMAL_COMPLETION;
|
xfer->status = USB_ERR_NORMAL_COMPLETION;
|
||||||
if (!udev->info.priv_data || !xfer->ureq) {
|
if (!udev->info.priv_data || !xfer->ureq) {
|
||||||
UPRINTF(LWRN, "invalid request\r\n");
|
UPRINTF(LWRN, "invalid request\r\n");
|
||||||
@ -1030,7 +998,6 @@ usb_dev_init(void *pdata, char *opt)
|
|||||||
struct usb_native_devinfo *di;
|
struct usb_native_devinfo *di;
|
||||||
int ver;
|
int ver;
|
||||||
|
|
||||||
assert(pdata);
|
|
||||||
di = pdata;
|
di = pdata;
|
||||||
|
|
||||||
libusb_get_device_descriptor(di->priv_data, &desc);
|
libusb_get_device_descriptor(di->priv_data, &desc);
|
||||||
@ -1121,8 +1088,6 @@ usb_dev_info(void *pdata, int type, void *value, int size)
|
|||||||
void *pv;
|
void *pv;
|
||||||
|
|
||||||
udev = pdata;
|
udev = pdata;
|
||||||
assert(udev);
|
|
||||||
assert(value);
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case USB_INFO_VERSION:
|
case USB_INFO_VERSION:
|
||||||
@ -1241,8 +1206,6 @@ usb_dev_sys_init(usb_dev_sys_cb conn_cb, usb_dev_sys_cb disconn_cb,
|
|||||||
int native_pid, native_vid, native_cls, rc;
|
int native_pid, native_vid, native_cls, rc;
|
||||||
int num_devs;
|
int num_devs;
|
||||||
|
|
||||||
assert(conn_cb);
|
|
||||||
assert(disconn_cb);
|
|
||||||
usb_set_log_level(log_level);
|
usb_set_log_level(log_level);
|
||||||
|
|
||||||
if (g_ctx.libusb_ctx) {
|
if (g_ctx.libusb_ctx) {
|
||||||
|
Loading…
Reference in New Issue
Block a user