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,
208 ret = flexcop_usb_v8_memory_req(fc_usb, req,
234 struct flexcop_usb *fc_usb = i2c->fc->bus_specific;
239 if (buflen > sizeof(fc_usb->data)) {
272 mutex_lock(&fc_usb->data_mutex);
275 memcpy(fc_usb->data, buf, buflen);
277 ret = usb_control_msg(fc_usb->udev, pipe,
282 fc_usb->data,
292 memcpy(buf, fc_usb->data, buflen);
295 mutex_unlock(&fc_usb->data_mutex);
328 static void flexcop_usb_process_frame(struct flexcop_usb *fc_usb,
335 fc_usb->tmp_buffer_length, buffer_length);
337 if (fc_usb->tmp_buffer_length > 0) {
338 memcpy(fc_usb->tmp_buffer+fc_usb->tmp_buffer_length, buffer,
340 fc_usb->tmp_buffer_length += buffer_length;
341 b = fc_usb->tmp_buffer;
342 l = fc_usb->tmp_buffer_length;
354 fc_usb->fc_dev, b+2, 1);
372 memcpy(fc_usb->tmp_buffer, b, l);
373 fc_usb->tmp_buffer_length = l;
378 struct flexcop_usb *fc_usb = urb->context;
394 flexcop_usb_process_frame(fc_usb,
411 static void flexcop_usb_transfer_exit(struct flexcop_usb *fc_usb)
415 if (fc_usb->iso_urb[i] != NULL) {
417 usb_kill_urb(fc_usb->iso_urb[i]);
418 usb_free_urb(fc_usb->iso_urb[i]);
421 usb_free_coherent(fc_usb->udev, fc_usb->buffer_size,
422 fc_usb->iso_buffer, fc_usb->dma_addr);
426 static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb)
428 struct usb_host_interface *alt = fc_usb->uintf->cur_altsetting;
440 fc_usb->iso_buffer = usb_alloc_coherent(fc_usb->udev,
441 bufsize, GFP_KERNEL, &fc_usb->dma_addr);
442 if (fc_usb->iso_buffer == NULL)
445 memset(fc_usb->iso_buffer, 0, bufsize);
446 fc_usb->buffer_size = bufsize;
450 fc_usb->iso_urb[i] = usb_alloc_urb(B2C2_USB_FRAMES_PER_ISO,
452 if (fc_usb->iso_urb[i] == NULL) {
461 struct urb *urb = fc_usb->iso_urb[i];
465 urb->dev = fc_usb->udev;
466 urb->context = fc_usb;
473 urb->transfer_buffer = fc_usb->iso_buffer + buffer_offset;
484 if ((ret = usb_submit_urb(fc_usb->iso_urb[i],GFP_ATOMIC))) {
492 flexcop_sram_set_dest(fc_usb->fc_dev, FC_SRAM_DEST_MEDIA |
495 flexcop_wan_set_speed(fc_usb->fc_dev, FC_WAN_SPEED_8MBITS);
496 flexcop_sram_ctrl(fc_usb->fc_dev, 1, 1, 1);
500 flexcop_usb_transfer_exit(fc_usb);
504 static int flexcop_usb_init(struct flexcop_usb *fc_usb)
510 ret = usb_set_interface(fc_usb->udev, 0, 1);
516 alt = fc_usb->uintf->cur_altsetting;
523 switch (fc_usb->udev->speed) {
539 usb_set_intfdata(fc_usb->uintf, fc_usb);
543 static void flexcop_usb_exit(struct flexcop_usb *fc_usb)
545 usb_set_intfdata(fc_usb->uintf, NULL);
552 struct flexcop_usb *fc_usb = NULL;
562 fc_usb = fc->bus_specific;
563 fc_usb->fc_dev = fc;
564 mutex_init(&fc_usb->data_mutex);
580 fc_usb->udev = udev;
581 fc_usb->uintf = intf;
582 if ((ret = flexcop_usb_init(fc_usb)) != 0)
590 if ((ret = flexcop_usb_transfer_init(fc_usb)) != 0)
599 flexcop_usb_exit(fc_usb);
607 struct flexcop_usb *fc_usb = usb_get_intfdata(intf);
608 flexcop_usb_transfer_exit(fc_usb);
609 flexcop_device_exit(fc_usb->fc_dev);
610 flexcop_usb_exit(fc_usb);
611 flexcop_device_kfree(fc_usb->fc_dev);