/* * Check an aimed rpipe to make sure it points to where we want * * We use bit 19 of the Linux USB pipe bitmap for unauth vs auth * space; when it is like that, we or 0x80 to make an unauth address. */ static int rpipe_check_aim(const struct wa_rpipe *rpipe, const struct wahc *wa, const struct usb_host_endpoint *ep, const struct urb *urb, gfp_t gfp) { int result = 0; struct device *dev = &wa->usb_iface->dev; u8 portnum = wusb_port_no_to_idx(urb->dev->portnum); #define AIM_CHECK(rdf, val, text) \ do { \ if (rpipe->descr.rdf != (val)) { \ dev_err(dev, \ "rpipe aim discrepancy: " #rdf " " text "\n", \ rpipe->descr.rdf, (val)); \ result = -EINVAL; \ WARN_ON(1); \ } \ } while (0) AIM_CHECK(hwa_bDeviceInfoIndex, portnum, "(%u vs %u)"); AIM_CHECK(bSpeed, usb_pipeendpoint(urb->pipe) == 0 ? UWB_PHY_RATE_53 : UWB_PHY_RATE_200, "(%u vs %u)"); AIM_CHECK(bEndpointAddress, ep->desc.bEndpointAddress, "(%u vs %u)"); AIM_CHECK(bInterval, ep->desc.bInterval, "(%u vs %u)"); AIM_CHECK(bmAttribute, ep->desc.bmAttributes & 0x03, "(%u vs %u)"); #undef AIM_CHECK return result; }
/* * Check an aimed rpipe to make sure it points to where we want * * We use bit 19 of the Linux USB pipe bitmap for unauth vs auth * space; when it is like that, we or 0x80 to make an unauth address. */ static int rpipe_check_aim(const struct wa_rpipe *rpipe, const struct wahc *wa, const struct usb_host_endpoint *ep, const struct urb *urb, gfp_t gfp) { int result = 0; /* better code for lack of companion? */ struct device *dev = &wa->usb_iface->dev; struct usb_device *usb_dev = urb->dev; u8 unauth = (usb_dev->wusb && !usb_dev->authenticated) ? 0x80 : 0; u8 portnum = wusb_port_no_to_idx(urb->dev->portnum); #define AIM_CHECK(rdf, val, text) \ do { \ if (rpipe->descr.rdf != (val)) { \ dev_err(dev, \ "rpipe aim discrepancy: " #rdf " " text "\n", \ rpipe->descr.rdf, (val)); \ result = -EINVAL; \ WARN_ON(1); \ } \ } while (0) AIM_CHECK(wMaxPacketSize, cpu_to_le16(ep->desc.wMaxPacketSize), "(%u vs %u)"); AIM_CHECK(bHSHubPort, portnum, "(%u vs %u)"); AIM_CHECK(bSpeed, usb_pipeendpoint(urb->pipe) == 0 ? UWB_PHY_RATE_53 : UWB_PHY_RATE_200, "(%u vs %u)"); AIM_CHECK(bDeviceAddress, urb->dev->devnum | unauth, "(%u vs %u)"); AIM_CHECK(bEndpointAddress, ep->desc.bEndpointAddress, "(%u vs %u)"); AIM_CHECK(bInterval, ep->desc.bInterval, "(%u vs %u)"); AIM_CHECK(bmAttribute, ep->desc.bmAttributes & 0x03, "(%u vs %u)"); #undef AIM_CHECK return result; }