static int config_ep(struct fusb300_ep *ep, const struct usb_endpoint_descriptor *desc) { struct fusb300 *fusb300 = ep->fusb300; struct fusb300_ep_info info; ep->ep.desc = desc; info.interval = 0; info.addrofs = 0; info.bw_num = 0; info.type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; info.dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0; info.maxpacket = usb_endpoint_maxp(desc); info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; if ((info.type == USB_ENDPOINT_XFER_INT) || (info.type == USB_ENDPOINT_XFER_ISOC)) { info.interval = desc->bInterval; if (info.type == USB_ENDPOINT_XFER_ISOC) info.bw_num = usb_endpoint_maxp_mult(desc); } ep_fifo_setting(fusb300, info); set_ep_reg(fusb300, info); fusb300_ep_setting(ep, info); fusb300->ep[info.epnum] = ep; return 0; }
static int usbtv_probe(struct usb_interface *intf, const struct usb_device_id *id) { int ret; int size; struct device *dev = &intf->dev; struct usbtv *usbtv; struct usb_host_endpoint *ep; /* Checks that the device is what we think it is. */ if (intf->num_altsetting != 2) return -ENODEV; if (intf->altsetting[1].desc.bNumEndpoints != 4) return -ENODEV; ep = &intf->altsetting[1].endpoint[0]; /* Packet size is split into 11 bits of base size and count of * extra multiplies of it.*/ size = usb_endpoint_maxp(&ep->desc); size = (size & 0x07ff) * usb_endpoint_maxp_mult(&ep->desc); /* Device structure */ usbtv = kzalloc(sizeof(struct usbtv), GFP_KERNEL); if (usbtv == NULL) return -ENOMEM; usbtv->dev = dev; usbtv->udev = usb_get_dev(interface_to_usbdev(intf)); usbtv->iso_size = size; usb_set_intfdata(intf, usbtv); ret = usbtv_video_init(usbtv); if (ret < 0) goto usbtv_video_fail; ret = usbtv_audio_init(usbtv); if (ret < 0) goto usbtv_audio_fail; /* for simplicity we exploit the v4l2_device reference counting */ v4l2_device_get(&usbtv->v4l2_dev); dev_info(dev, "Fushicai USBTV007 Audio-Video Grabber\n"); return 0; usbtv_audio_fail: usbtv_video_free(usbtv); usbtv_video_fail: usb_set_intfdata(intf, NULL); usb_put_dev(usbtv->udev); kfree(usbtv); return ret; }