Lines Matching refs:fsg

236 	struct fsg_dev		*fsg;  member
311 if (common->fsg) in __fsg_is_set()
346 static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep) in fsg_set_halt() argument
350 if (ep == fsg->bulk_in) in fsg_set_halt()
352 else if (ep == fsg->bulk_out) in fsg_set_halt()
356 DBG(fsg, "%s set halt\n", name); in fsg_set_halt()
459 struct fsg_dev *fsg = fsg_from_func(f); in fsg_setup() local
460 struct usb_request *req = fsg->common->ep0req; in fsg_setup()
465 if (!fsg_is_set(fsg->common)) in fsg_setup()
468 ++fsg->common->ep0_req_tag; /* Record arrival of a new request */ in fsg_setup()
471 dump_msg(fsg, "ep0-setup", (u8 *) ctrl, sizeof(*ctrl)); in fsg_setup()
479 if (w_index != fsg->interface_number || w_value != 0 || in fsg_setup()
487 DBG(fsg, "bulk reset request\n"); in fsg_setup()
488 raise_exception(fsg->common, FSG_STATE_PROTOCOL_RESET); in fsg_setup()
495 if (w_index != fsg->interface_number || w_value != 0 || in fsg_setup()
498 VDBG(fsg, "get max LUN\n"); in fsg_setup()
499 *(u8 *)req->buf = _fsg_common_get_max_lun(fsg->common); in fsg_setup()
503 return ep0_queue(fsg->common); in fsg_setup()
506 VDBG(fsg, in fsg_setup()
519 static int start_transfer(struct fsg_dev *fsg, struct usb_ep *ep, in start_transfer() argument
524 if (ep == fsg->bulk_in) in start_transfer()
525 dump_msg(fsg, "bulk-in", req->buf, req->length); in start_transfer()
539 WARNING(fsg, "error in submission: %s --> %d\n", in start_transfer()
550 if (start_transfer(common->fsg, common->fsg->bulk_in, bh->inreq)) in start_in_transfer()
560 if (start_transfer(common->fsg, common->fsg->bulk_out, bh->outreq)) in start_out_transfer()
1450 static int halt_bulk_in_endpoint(struct fsg_dev *fsg) in halt_bulk_in_endpoint() argument
1454 rc = fsg_set_halt(fsg, fsg->bulk_in); in halt_bulk_in_endpoint()
1456 VDBG(fsg, "delayed bulk-in endpoint halt\n"); in halt_bulk_in_endpoint()
1459 WARNING(fsg, "usb_ep_set_halt -> %d\n", rc); in halt_bulk_in_endpoint()
1467 rc = usb_ep_set_halt(fsg->bulk_in); in halt_bulk_in_endpoint()
1472 static int wedge_bulk_in_endpoint(struct fsg_dev *fsg) in wedge_bulk_in_endpoint() argument
1476 DBG(fsg, "bulk-in set wedge\n"); in wedge_bulk_in_endpoint()
1477 rc = usb_ep_set_wedge(fsg->bulk_in); in wedge_bulk_in_endpoint()
1479 VDBG(fsg, "delayed bulk-in endpoint wedge\n"); in wedge_bulk_in_endpoint()
1482 WARNING(fsg, "usb_ep_set_wedge -> %d\n", rc); in wedge_bulk_in_endpoint()
1490 rc = usb_ep_set_wedge(fsg->bulk_in); in wedge_bulk_in_endpoint()
1563 fsg_set_halt(common->fsg, common->fsg->bulk_out); in finish_reply()
1564 rc = halt_bulk_in_endpoint(common->fsg); in finish_reply()
1600 rc = halt_bulk_in_endpoint(common->fsg); in finish_reply()
1628 fsg_set_halt(common->fsg, in finish_reply()
1629 common->fsg->bulk_out); in finish_reply()
2165 static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) in received_cbw() argument
2169 struct fsg_common *common = fsg->common; in received_cbw()
2172 if (req->status || test_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags)) in received_cbw()
2179 DBG(fsg, "invalid CBW: len %u sig 0x%x\n", in received_cbw()
2194 wedge_bulk_in_endpoint(fsg); in received_cbw()
2195 set_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); in received_cbw()
2203 DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " in received_cbw()
2212 fsg_set_halt(fsg, fsg->bulk_out); in received_cbw()
2213 halt_bulk_in_endpoint(fsg); in received_cbw()
2265 rc = fsg_is_set(common) ? received_cbw(common->fsg, bh) : -EIO; in get_next_command()
2287 struct fsg_dev *fsg; in do_set_interface() local
2295 if (common->fsg) { in do_set_interface()
2296 fsg = common->fsg; in do_set_interface()
2302 usb_ep_free_request(fsg->bulk_in, bh->inreq); in do_set_interface()
2306 usb_ep_free_request(fsg->bulk_out, bh->outreq); in do_set_interface()
2312 if (fsg->bulk_in_enabled) { in do_set_interface()
2313 usb_ep_disable(fsg->bulk_in); in do_set_interface()
2314 fsg->bulk_in_enabled = 0; in do_set_interface()
2316 if (fsg->bulk_out_enabled) { in do_set_interface()
2317 usb_ep_disable(fsg->bulk_out); in do_set_interface()
2318 fsg->bulk_out_enabled = 0; in do_set_interface()
2321 common->fsg = NULL; in do_set_interface()
2329 common->fsg = new_fsg; in do_set_interface()
2330 fsg = common->fsg; in do_set_interface()
2333 rc = config_ep_by_speed(common->gadget, &(fsg->function), fsg->bulk_in); in do_set_interface()
2336 rc = usb_ep_enable(fsg->bulk_in); in do_set_interface()
2339 fsg->bulk_in->driver_data = common; in do_set_interface()
2340 fsg->bulk_in_enabled = 1; in do_set_interface()
2342 rc = config_ep_by_speed(common->gadget, &(fsg->function), in do_set_interface()
2343 fsg->bulk_out); in do_set_interface()
2346 rc = usb_ep_enable(fsg->bulk_out); in do_set_interface()
2349 fsg->bulk_out->driver_data = common; in do_set_interface()
2350 fsg->bulk_out_enabled = 1; in do_set_interface()
2351 common->bulk_out_maxpacket = usb_endpoint_maxp(fsg->bulk_out->desc); in do_set_interface()
2352 clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); in do_set_interface()
2358 rc = alloc_request(common, fsg->bulk_in, &bh->inreq); in do_set_interface()
2361 rc = alloc_request(common, fsg->bulk_out, &bh->outreq); in do_set_interface()
2383 struct fsg_dev *fsg = fsg_from_func(f); in fsg_set_alt() local
2385 __raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE, fsg); in fsg_set_alt()
2391 struct fsg_dev *fsg = fsg_from_func(f); in fsg_disable() local
2394 if (fsg->bulk_in_enabled) { in fsg_disable()
2395 usb_ep_disable(fsg->bulk_in); in fsg_disable()
2396 fsg->bulk_in_enabled = 0; in fsg_disable()
2398 if (fsg->bulk_out_enabled) { in fsg_disable()
2399 usb_ep_disable(fsg->bulk_out); in fsg_disable()
2400 fsg->bulk_out_enabled = 0; in fsg_disable()
2403 __raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE, NULL); in fsg_disable()
2436 if (likely(common->fsg)) { in handle_exception()
2440 usb_ep_dequeue(common->fsg->bulk_in, bh->inreq); in handle_exception()
2442 usb_ep_dequeue(common->fsg->bulk_out, in handle_exception()
2451 if (common->fsg->bulk_in_enabled) in handle_exception()
2452 usb_ep_fifo_flush(common->fsg->bulk_in); in handle_exception()
2453 if (common->fsg->bulk_out_enabled) in handle_exception()
2454 usb_ep_fifo_flush(common->fsg->bulk_out); in handle_exception()
2506 &common->fsg->atomic_bitflags)) in handle_exception()
2507 usb_ep_clear_halt(common->fsg->bulk_in); in handle_exception()
3012 struct fsg_dev *fsg = fsg_from_func(f); in fsg_bind() local
3013 struct fsg_common *common = fsg->common; in fsg_bind()
3030 ret = fsg_common_set_cdev(fsg->common, c->cdev, in fsg_bind()
3031 fsg->common->can_stall); in fsg_bind()
3034 fsg_common_set_inquiry_string(fsg->common, NULL, NULL); in fsg_bind()
3052 fsg->gadget = gadget; in fsg_bind()
3059 fsg->interface_number = i; in fsg_bind()
3065 fsg->bulk_in = ep; in fsg_bind()
3070 fsg->bulk_out = ep; in fsg_bind()
3097 ERROR(fsg, "unable to autoconfigure all endpoints\n"); in fsg_bind()
3101 if (fsg->common->state != FSG_STATE_TERMINATED) { in fsg_bind()
3102 raise_exception(fsg->common, FSG_STATE_EXIT); in fsg_bind()
3103 wait_for_completion(&fsg->common->thread_notifier); in fsg_bind()
3112 struct fsg_dev *fsg = fsg_from_func(f); in fsg_unbind() local
3113 struct fsg_common *common = fsg->common; in fsg_unbind()
3115 DBG(fsg, "unbind\n"); in fsg_unbind()
3116 if (fsg->common->fsg == fsg) { in fsg_unbind()
3117 __raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE, NULL); in fsg_unbind()
3119 wait_event(common->fsg_wait, common->fsg != fsg); in fsg_unbind()
3122 usb_free_all_descriptors(&fsg->function); in fsg_unbind()
3526 struct fsg_dev *fsg; in fsg_free() local
3529 fsg = container_of(f, struct fsg_dev, function); in fsg_free()
3536 kfree(fsg); in fsg_free()
3543 struct fsg_dev *fsg; in fsg_alloc() local
3545 fsg = kzalloc(sizeof(*fsg), GFP_KERNEL); in fsg_alloc()
3546 if (unlikely(!fsg)) in fsg_alloc()
3553 fsg->function.name = FSG_DRIVER_DESC; in fsg_alloc()
3554 fsg->function.bind = fsg_bind; in fsg_alloc()
3555 fsg->function.unbind = fsg_unbind; in fsg_alloc()
3556 fsg->function.setup = fsg_setup; in fsg_alloc()
3557 fsg->function.set_alt = fsg_set_alt; in fsg_alloc()
3558 fsg->function.disable = fsg_disable; in fsg_alloc()
3559 fsg->function.free_func = fsg_free; in fsg_alloc()
3561 fsg->common = common; in fsg_alloc()
3563 return &fsg->function; in fsg_alloc()