Lines Matching defs:fc_usb
71 struct flexcop_usb *fc_usb = fc->bus_specific;
78 mutex_lock(&fc_usb->data_mutex);
80 memcpy(fc_usb->data, val, sizeof(*val));
82 ret = usb_control_msg(fc_usb->udev,
88 fc_usb->data,
100 memcpy(val, fc_usb->data, sizeof(*val));
101 mutex_unlock(&fc_usb->data_mutex);
108 static int flexcop_usb_v8_memory_req(struct flexcop_usb *fc_usb,
117 if (buflen > sizeof(fc_usb->data)) {
146 mutex_lock(&fc_usb->data_mutex);
149 memcpy(fc_usb->data, pbBuffer, buflen);
151 ret = usb_control_msg(fc_usb->udev, pipe,
156 fc_usb->data,
165 memcpy(pbBuffer, fc_usb->data, buflen);
168 mutex_unlock(&fc_usb->data_mutex);
178 static int flexcop_usb_memory_req(struct flexcop_usb *fc_usb,
209 ret = flexcop_usb_v8_memory_req(fc_usb, req,
235 struct flexcop_usb *fc_usb = i2c->fc->bus_specific;
240 if (buflen > sizeof(fc_usb->data)) {
273 mutex_lock(&fc_usb->data_mutex);
276 memcpy(fc_usb->data, buf, buflen);
278 ret = usb_control_msg(fc_usb->udev, pipe,
283 fc_usb->data,
293 memcpy(buf, fc_usb->data, buflen);
296 mutex_unlock(&fc_usb->data_mutex);
329 static void flexcop_usb_process_frame(struct flexcop_usb *fc_usb,
336 fc_usb->tmp_buffer_length, buffer_length);
338 if (fc_usb->tmp_buffer_length > 0) {
339 memcpy(fc_usb->tmp_buffer+fc_usb->tmp_buffer_length, buffer,
341 fc_usb->tmp_buffer_length += buffer_length;
342 b = fc_usb->tmp_buffer;
343 l = fc_usb->tmp_buffer_length;
355 fc_usb->fc_dev, b+2, 1);
373 memcpy(fc_usb->tmp_buffer, b, l);
374 fc_usb->tmp_buffer_length = l;
379 struct flexcop_usb *fc_usb = urb->context;
395 flexcop_usb_process_frame(fc_usb,
412 static void flexcop_usb_transfer_exit(struct flexcop_usb *fc_usb)
416 if (fc_usb->iso_urb[i] != NULL) {
418 usb_kill_urb(fc_usb->iso_urb[i]);
419 usb_free_urb(fc_usb->iso_urb[i]);
422 usb_free_coherent(fc_usb->udev, fc_usb->buffer_size,
423 fc_usb->iso_buffer, fc_usb->dma_addr);
427 static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb)
430 fc_usb->uintf->cur_altsetting->endpoint[0].desc.wMaxPacketSize);
439 fc_usb->iso_buffer = usb_alloc_coherent(fc_usb->udev,
440 bufsize, GFP_KERNEL, &fc_usb->dma_addr);
441 if (fc_usb->iso_buffer == NULL)
444 memset(fc_usb->iso_buffer, 0, bufsize);
445 fc_usb->buffer_size = bufsize;
449 fc_usb->iso_urb[i] = usb_alloc_urb(B2C2_USB_FRAMES_PER_ISO,
451 if (fc_usb->iso_urb[i] == NULL) {
460 struct urb *urb = fc_usb->iso_urb[i];
464 urb->dev = fc_usb->udev;
465 urb->context = fc_usb;
472 urb->transfer_buffer = fc_usb->iso_buffer + buffer_offset;
483 if ((ret = usb_submit_urb(fc_usb->iso_urb[i],GFP_ATOMIC))) {
491 flexcop_sram_set_dest(fc_usb->fc_dev, FC_SRAM_DEST_MEDIA |
494 flexcop_wan_set_speed(fc_usb->fc_dev, FC_WAN_SPEED_8MBITS);
495 flexcop_sram_ctrl(fc_usb->fc_dev, 1, 1, 1);
499 flexcop_usb_transfer_exit(fc_usb);
503 static int flexcop_usb_init(struct flexcop_usb *fc_usb)
506 int ret = usb_set_interface(fc_usb->udev, 0, 1);
513 if (fc_usb->uintf->cur_altsetting->desc.bNumEndpoints < 1)
515 if (!usb_endpoint_is_isoc_in(&fc_usb->uintf->cur_altsetting->endpoint[0].desc))
518 switch (fc_usb->udev->speed) {
534 usb_set_intfdata(fc_usb->uintf, fc_usb);
538 static void flexcop_usb_exit(struct flexcop_usb *fc_usb)
540 usb_set_intfdata(fc_usb->uintf, NULL);
547 struct flexcop_usb *fc_usb = NULL;
557 fc_usb = fc->bus_specific;
558 fc_usb->fc_dev = fc;
559 mutex_init(&fc_usb->data_mutex);
575 fc_usb->udev = udev;
576 fc_usb->uintf = intf;
577 if ((ret = flexcop_usb_init(fc_usb)) != 0)
585 if ((ret = flexcop_usb_transfer_init(fc_usb)) != 0)
594 flexcop_usb_exit(fc_usb);
602 struct flexcop_usb *fc_usb = usb_get_intfdata(intf);
603 flexcop_usb_transfer_exit(fc_usb);
604 flexcop_device_exit(fc_usb->fc_dev);
605 flexcop_usb_exit(fc_usb);
606 flexcop_device_kfree(fc_usb->fc_dev);