Lines Matching refs:fsg

295 	struct fsg_dev		*fsg, *new_fsg;  member
393 if (common->fsg) in __fsg_is_set()
435 static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep) in fsg_set_halt() argument
439 if (ep == fsg->bulk_in) in fsg_set_halt()
441 else if (ep == fsg->bulk_out) in fsg_set_halt()
445 DBG(fsg, "%s set halt\n", name); in fsg_set_halt()
535 struct fsg_dev *fsg = fsg_from_func(f); in fsg_setup() local
536 struct usb_request *req = fsg->common->ep0req; in fsg_setup()
541 if (!fsg_is_set(fsg->common)) in fsg_setup()
550 if (w_index != fsg->interface_number || w_value != 0) in fsg_setup()
555 DBG(fsg, "bulk reset request\n"); in fsg_setup()
556 raise_exception(fsg->common, FSG_STATE_RESET); in fsg_setup()
563 if (w_index != fsg->interface_number || w_value != 0) in fsg_setup()
565 VDBG(fsg, "get max LUN\n"); in fsg_setup()
566 *(u8 *) req->buf = fsg->common->nluns - 1; in fsg_setup()
570 return ep0_queue(fsg->common); in fsg_setup()
573 VDBG(fsg, in fsg_setup()
586 static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep, in start_transfer() argument
592 if (ep == fsg->bulk_in) in start_transfer()
593 dump_msg(fsg, "bulk-in", req->buf, req->length); in start_transfer()
608 WARNING(fsg, "error in submission: %s --> %d\n", in start_transfer()
615 start_transfer((common)->fsg, (common)->fsg->ep_name, \
990 cdev_name = common->fsg->function.config->cdev->driver->name; in do_write()
1392 static int halt_bulk_in_endpoint(struct fsg_dev *fsg) in halt_bulk_in_endpoint() argument
1396 rc = fsg_set_halt(fsg, fsg->bulk_in); in halt_bulk_in_endpoint()
1398 VDBG(fsg, "delayed bulk-in endpoint halt\n"); in halt_bulk_in_endpoint()
1401 WARNING(fsg, "usb_ep_set_halt -> %d\n", rc); in halt_bulk_in_endpoint()
1406 rc = usb_ep_set_halt(fsg->bulk_in); in halt_bulk_in_endpoint()
1411 static int wedge_bulk_in_endpoint(struct fsg_dev *fsg) in wedge_bulk_in_endpoint() argument
1415 DBG(fsg, "bulk-in set wedge\n"); in wedge_bulk_in_endpoint()
1418 VDBG(fsg, "delayed bulk-in endpoint wedge\n"); in wedge_bulk_in_endpoint()
1421 WARNING(fsg, "usb_ep_set_wedge -> %d\n", rc); in wedge_bulk_in_endpoint()
1429 static int pad_with_zeros(struct fsg_dev *fsg) in pad_with_zeros() argument
1431 struct fsg_buffhd *bh = fsg->common->next_buffhd_to_fill; in pad_with_zeros()
1437 fsg->common->usb_amount_left = nkeep + fsg->common->residue; in pad_with_zeros()
1438 while (fsg->common->usb_amount_left > 0) { in pad_with_zeros()
1442 rc = sleep_thread(fsg->common); in pad_with_zeros()
1447 nsend = min(fsg->common->usb_amount_left, in pad_with_zeros()
1448 fsg->common->usb_trb_size); in pad_with_zeros()
1452 start_transfer(fsg, fsg->bulk_in, bh->inreq, in pad_with_zeros()
1454 bh = fsg->common->next_buffhd_to_fill = bh->next; in pad_with_zeros()
1455 fsg->common->usb_amount_left -= nsend; in pad_with_zeros()
1534 fsg_set_halt(common->fsg, common->fsg->bulk_out); in finish_reply()
1535 rc = halt_bulk_in_endpoint(common->fsg); in finish_reply()
1566 if (common->fsg) in finish_reply()
1567 rc = halt_bulk_in_endpoint(common->fsg); in finish_reply()
1569 rc = pad_with_zeros(common->fsg); in finish_reply()
1596 fsg_set_halt(common->fsg, in finish_reply()
1597 common->fsg->bulk_out); in finish_reply()
1815 cdev_name = common->fsg->function.config->cdev->driver->name; in do_scsi_command()
2082 static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) in received_cbw() argument
2086 struct fsg_common *common = fsg->common; in received_cbw()
2089 if (req->status || test_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags)) in received_cbw()
2096 DBG(fsg, "invalid CBW: len %u sig 0x%x\n", in received_cbw()
2109 wedge_bulk_in_endpoint(fsg); in received_cbw()
2110 generic_set_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); in received_cbw()
2117 DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " in received_cbw()
2124 fsg_set_halt(fsg, fsg->bulk_out); in received_cbw()
2125 halt_bulk_in_endpoint(fsg); in received_cbw()
2178 rc = fsg_is_set(common) ? received_cbw(common->fsg, bh) : -EIO; in get_next_command()
2213 struct fsg_dev *fsg; in do_set_interface() local
2221 if (common->fsg) { in do_set_interface()
2222 fsg = common->fsg; in do_set_interface()
2228 usb_ep_free_request(fsg->bulk_in, bh->inreq); in do_set_interface()
2232 usb_ep_free_request(fsg->bulk_out, bh->outreq); in do_set_interface()
2238 if (fsg->bulk_in_enabled) { in do_set_interface()
2239 usb_ep_disable(fsg->bulk_in); in do_set_interface()
2240 fsg->bulk_in_enabled = 0; in do_set_interface()
2242 if (fsg->bulk_out_enabled) { in do_set_interface()
2243 usb_ep_disable(fsg->bulk_out); in do_set_interface()
2244 fsg->bulk_out_enabled = 0; in do_set_interface()
2247 common->fsg = NULL; in do_set_interface()
2255 common->fsg = new_fsg; in do_set_interface()
2256 fsg = common->fsg; in do_set_interface()
2262 fsg->bulk_in); in do_set_interface()
2263 rc = enable_endpoint(common, fsg->bulk_in, d); in do_set_interface()
2266 fsg->bulk_in_enabled = 1; in do_set_interface()
2271 fsg->bulk_out); in do_set_interface()
2272 rc = enable_endpoint(common, fsg->bulk_out, d); in do_set_interface()
2275 fsg->bulk_out_enabled = 1; in do_set_interface()
2278 generic_clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); in do_set_interface()
2284 rc = alloc_request(common, fsg->bulk_in, &bh->inreq); in do_set_interface()
2287 rc = alloc_request(common, fsg->bulk_out, &bh->outreq); in do_set_interface()
2307 struct fsg_dev *fsg = fsg_from_func(f); in fsg_set_alt() local
2308 fsg->common->new_fsg = fsg; in fsg_set_alt()
2309 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); in fsg_set_alt()
2315 struct fsg_dev *fsg = fsg_from_func(f); in fsg_disable() local
2316 fsg->common->new_fsg = NULL; in fsg_disable()
2317 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); in fsg_disable()
2331 if (common->fsg) { in handle_exception()
2335 usb_ep_dequeue(common->fsg->bulk_in, bh->inreq); in handle_exception()
2337 usb_ep_dequeue(common->fsg->bulk_out, in handle_exception()
2355 if (common->fsg->bulk_in_enabled) in handle_exception()
2356 usb_ep_fifo_flush(common->fsg->bulk_in); in handle_exception()
2357 if (common->fsg->bulk_out_enabled) in handle_exception()
2358 usb_ep_fifo_flush(common->fsg->bulk_out); in handle_exception()
2400 &common->fsg->atomic_bitflags)) in handle_exception()
2401 usb_ep_clear_halt(common->fsg->bulk_in); in handle_exception()
2680 struct fsg_dev *fsg = fsg_from_func(f); in fsg_unbind() local
2682 DBG(fsg, "unbind\n"); in fsg_unbind()
2683 if (fsg->common->fsg == fsg) { in fsg_unbind()
2684 fsg->common->new_fsg = NULL; in fsg_unbind()
2685 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); in fsg_unbind()
2688 free(fsg->function.descriptors); in fsg_unbind()
2689 free(fsg->function.hs_descriptors); in fsg_unbind()
2690 kfree(fsg); in fsg_unbind()
2695 struct fsg_dev *fsg = fsg_from_func(f); in fsg_bind() local
2699 fsg->gadget = gadget; in fsg_bind()
2706 fsg->interface_number = i; in fsg_bind()
2712 ep->driver_data = fsg->common; /* claim the endpoint */ in fsg_bind()
2713 fsg->bulk_in = ep; in fsg_bind()
2718 ep->driver_data = fsg->common; /* claim the endpoint */ in fsg_bind()
2719 fsg->bulk_out = ep; in fsg_bind()
2769 ERROR(fsg, "unable to autoconfigure all endpoints\n"); in fsg_bind()
2785 struct fsg_dev *fsg; in fsg_bind_config() local
2788 fsg = calloc(1, sizeof *fsg); in fsg_bind_config()
2789 if (!fsg) in fsg_bind_config()
2791 fsg->function.name = FSG_DRIVER_DESC; in fsg_bind_config()
2792 fsg->function.strings = fsg_strings_array; in fsg_bind_config()
2793 fsg->function.bind = fsg_bind; in fsg_bind_config()
2794 fsg->function.unbind = fsg_unbind; in fsg_bind_config()
2795 fsg->function.setup = fsg_setup; in fsg_bind_config()
2796 fsg->function.set_alt = fsg_set_alt; in fsg_bind_config()
2797 fsg->function.disable = fsg_disable; in fsg_bind_config()
2799 fsg->common = common; in fsg_bind_config()
2800 common->fsg = fsg; in fsg_bind_config()
2807 rc = usb_add_function(c, &fsg->function); in fsg_bind_config()
2810 kfree(fsg); in fsg_bind_config()