H A D | f_mass_storage.c | 154 * (fsg->next_buffhd_to_fill) that points to the next buffer head to use. 261 struct fsg_dev *fsg, *new_fsg; member in struct:fsg_common 343 if (common->fsg) __fsg_is_set() 345 ERROR(common, "common->fsg is NULL in %s at %u\n", func, line); __fsg_is_set() 380 static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep) fsg_set_halt() argument 384 if (ep == fsg->bulk_in) fsg_set_halt() 386 else if (ep == fsg->bulk_out) fsg_set_halt() 390 DBG(fsg, "%s set halt\n", name); fsg_set_halt() 399 /* Caller must hold fsg->lock */ wakeup_thread() 505 struct fsg_dev *fsg = fsg_from_func(f); fsg_setup() local 506 struct usb_request *req = fsg->common->ep0req; fsg_setup() 511 if (!fsg_is_set(fsg->common)) fsg_setup() 514 ++fsg->common->ep0_req_tag; /* Record arrival of a new request */ fsg_setup() 517 dump_msg(fsg, "ep0-setup", (u8 *) ctrl, sizeof(*ctrl)); fsg_setup() 525 if (w_index != fsg->interface_number || w_value != 0 || fsg_setup() 533 DBG(fsg, "bulk reset request\n"); fsg_setup() 534 raise_exception(fsg->common, FSG_STATE_RESET); fsg_setup() 541 if (w_index != fsg->interface_number || w_value != 0 || fsg_setup() 544 VDBG(fsg, "get max LUN\n"); fsg_setup() 545 *(u8 *)req->buf = _fsg_common_get_max_lun(fsg->common); fsg_setup() 549 return ep0_queue(fsg->common); fsg_setup() 552 VDBG(fsg, fsg_setup() 565 static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep, start_transfer() argument 571 if (ep == fsg->bulk_in) start_transfer() 572 dump_msg(fsg, "bulk-in", req->buf, req->length); start_transfer() 574 spin_lock_irq(&fsg->common->lock); start_transfer() 577 spin_unlock_irq(&fsg->common->lock); start_transfer() 593 WARNING(fsg, "error in submission: %s --> %d\n", ep->name, rc); start_transfer() 600 start_transfer(common->fsg, common->fsg->bulk_in, start_in_transfer() 609 start_transfer(common->fsg, common->fsg->bulk_out, start_out_transfer() 760 /* Don't know what to do if common->fsg is NULL */ do_read() 865 /* Dunno what to do if common->fsg is NULL */ do_write() 1425 static int halt_bulk_in_endpoint(struct fsg_dev *fsg) halt_bulk_in_endpoint() argument 1429 rc = fsg_set_halt(fsg, fsg->bulk_in); halt_bulk_in_endpoint() 1431 VDBG(fsg, "delayed bulk-in endpoint halt\n"); halt_bulk_in_endpoint() 1434 WARNING(fsg, "usb_ep_set_halt -> %d\n", rc); halt_bulk_in_endpoint() 1442 rc = usb_ep_set_halt(fsg->bulk_in); halt_bulk_in_endpoint() 1447 static int wedge_bulk_in_endpoint(struct fsg_dev *fsg) wedge_bulk_in_endpoint() argument 1451 DBG(fsg, "bulk-in set wedge\n"); wedge_bulk_in_endpoint() 1452 rc = usb_ep_set_wedge(fsg->bulk_in); wedge_bulk_in_endpoint() 1454 VDBG(fsg, "delayed bulk-in endpoint wedge\n"); wedge_bulk_in_endpoint() 1457 WARNING(fsg, "usb_ep_set_wedge -> %d\n", rc); wedge_bulk_in_endpoint() 1465 rc = usb_ep_set_wedge(fsg->bulk_in); wedge_bulk_in_endpoint() 1509 /* Dunno what to do if common->fsg is NULL */ throw_away_data() 1543 fsg_set_halt(common->fsg, common->fsg->bulk_out); finish_reply() 1544 rc = halt_bulk_in_endpoint(common->fsg); finish_reply() 1546 /* Don't know what to do if common->fsg is NULL */ finish_reply() 1556 /* Don't know what to do if common->fsg is NULL */ finish_reply() 1580 rc = halt_bulk_in_endpoint(common->fsg); finish_reply() 1608 fsg_set_halt(common->fsg, finish_reply() 1609 common->fsg->bulk_out); finish_reply() 1674 /* Don't know what to do if common->fsg is NULL */ send_status() 2108 static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) received_cbw() argument 2112 struct fsg_common *common = fsg->common; received_cbw() 2115 if (req->status || test_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags)) received_cbw() 2122 DBG(fsg, "invalid CBW: len %u sig 0x%x\n", received_cbw() 2137 wedge_bulk_in_endpoint(fsg); received_cbw() 2138 set_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); received_cbw() 2146 DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " received_cbw() 2155 fsg_set_halt(fsg, fsg->bulk_out); received_cbw() 2156 halt_bulk_in_endpoint(fsg); received_cbw() 2196 /* Don't know what to do if common->fsg is NULL */ get_next_command() 2212 rc = fsg_is_set(common) ? received_cbw(common->fsg, bh) : -EIO; get_next_command() 2234 struct fsg_dev *fsg; do_set_interface() local 2242 if (common->fsg) { do_set_interface() 2243 fsg = common->fsg; do_set_interface() 2249 usb_ep_free_request(fsg->bulk_in, bh->inreq); do_set_interface() 2253 usb_ep_free_request(fsg->bulk_out, bh->outreq); do_set_interface() 2259 if (fsg->bulk_in_enabled) { do_set_interface() 2260 usb_ep_disable(fsg->bulk_in); do_set_interface() 2261 fsg->bulk_in->driver_data = NULL; do_set_interface() 2262 fsg->bulk_in_enabled = 0; do_set_interface() 2264 if (fsg->bulk_out_enabled) { do_set_interface() 2265 usb_ep_disable(fsg->bulk_out); do_set_interface() 2266 fsg->bulk_out->driver_data = NULL; do_set_interface() 2267 fsg->bulk_out_enabled = 0; do_set_interface() 2270 common->fsg = NULL; do_set_interface() 2278 common->fsg = new_fsg; do_set_interface() 2279 fsg = common->fsg; do_set_interface() 2282 rc = config_ep_by_speed(common->gadget, &(fsg->function), fsg->bulk_in); do_set_interface() 2285 rc = usb_ep_enable(fsg->bulk_in); do_set_interface() 2288 fsg->bulk_in->driver_data = common; do_set_interface() 2289 fsg->bulk_in_enabled = 1; do_set_interface() 2291 rc = config_ep_by_speed(common->gadget, &(fsg->function), do_set_interface() 2292 fsg->bulk_out); do_set_interface() 2295 rc = usb_ep_enable(fsg->bulk_out); do_set_interface() 2298 fsg->bulk_out->driver_data = common; do_set_interface() 2299 fsg->bulk_out_enabled = 1; do_set_interface() 2300 common->bulk_out_maxpacket = usb_endpoint_maxp(fsg->bulk_out->desc); do_set_interface() 2301 clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); do_set_interface() 2307 rc = alloc_request(common, fsg->bulk_in, &bh->inreq); do_set_interface() 2310 rc = alloc_request(common, fsg->bulk_out, &bh->outreq); do_set_interface() 2332 struct fsg_dev *fsg = fsg_from_func(f); fsg_set_alt() local 2333 fsg->common->new_fsg = fsg; fsg_set_alt() 2334 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); fsg_set_alt() 2340 struct fsg_dev *fsg = fsg_from_func(f); fsg_disable() local 2341 fsg->common->new_fsg = NULL; fsg_disable() 2342 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); fsg_disable() 2374 if (likely(common->fsg)) { handle_exception() 2378 usb_ep_dequeue(common->fsg->bulk_in, bh->inreq); handle_exception() 2380 usb_ep_dequeue(common->fsg->bulk_out, handle_exception() 2398 if (common->fsg->bulk_in_enabled) handle_exception() 2399 usb_ep_fifo_flush(common->fsg->bulk_in); handle_exception() 2400 if (common->fsg->bulk_out_enabled) handle_exception() 2401 usb_ep_fifo_flush(common->fsg->bulk_out); handle_exception() 2455 &common->fsg->atomic_bitflags)) handle_exception() 2456 usb_ep_clear_halt(common->fsg->bulk_in); handle_exception() 3013 struct fsg_dev *fsg = fsg_from_func(f); fsg_bind() local 3014 struct fsg_common *common = fsg->common; fsg_bind() 3031 ret = fsg_common_set_cdev(fsg->common, c->cdev, fsg_bind() 3032 fsg->common->can_stall); fsg_bind() 3035 fsg_common_set_inquiry_string(fsg->common, NULL, NULL); fsg_bind() 3053 fsg->gadget = gadget; fsg_bind() 3060 fsg->interface_number = i; fsg_bind() 3066 ep->driver_data = fsg->common; /* claim the endpoint */ fsg_bind() 3067 fsg->bulk_in = ep; fsg_bind() 3072 ep->driver_data = fsg->common; /* claim the endpoint */ fsg_bind() 3073 fsg->bulk_out = ep; fsg_bind() 3100 ERROR(fsg, "unable to autoconfigure all endpoints\n"); fsg_bind() 3108 struct fsg_dev *fsg = fsg_from_func(f); fsg_unbind() local 3109 struct fsg_common *common = fsg->common; fsg_unbind() 3111 DBG(fsg, "unbind\n"); fsg_unbind() 3112 if (fsg->common->fsg == fsg) { fsg_unbind() 3113 fsg->common->new_fsg = NULL; fsg_unbind() 3114 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); fsg_unbind() 3116 wait_event(common->fsg_wait, common->fsg != fsg); fsg_unbind() 3119 usb_free_all_descriptors(&fsg->function); fsg_unbind() 3521 struct fsg_dev *fsg; fsg_free() local 3524 fsg = container_of(f, struct fsg_dev, function); fsg_free() 3531 kfree(fsg); fsg_free() 3538 struct fsg_dev *fsg; fsg_alloc() local 3540 fsg = kzalloc(sizeof(*fsg), GFP_KERNEL); fsg_alloc() 3541 if (unlikely(!fsg)) fsg_alloc() 3548 fsg->function.name = FSG_DRIVER_DESC; fsg_alloc() 3549 fsg->function.bind = fsg_bind; fsg_alloc() 3550 fsg->function.unbind = fsg_unbind; fsg_alloc() 3551 fsg->function.setup = fsg_setup; fsg_alloc() 3552 fsg->function.set_alt = fsg_set_alt; fsg_alloc() 3553 fsg->function.disable = fsg_disable; fsg_alloc() 3554 fsg->function.free_func = fsg_free; fsg_alloc() 3556 fsg->common = common; fsg_alloc() 3558 return &fsg->function; fsg_alloc()
|