Lines Matching refs:bh
331 struct fsg_buffhd *bh, unsigned int length) in set_bulk_out_req_length() argument
335 bh->bulk_out_intended_length = length; in set_bulk_out_req_length()
339 bh->outreq->length = length; in set_bulk_out_req_length()
415 struct fsg_buffhd *bh = req->context; in bulk_in_complete() local
424 smp_store_release(&bh->state, BUF_STATE_EMPTY); in bulk_in_complete()
431 struct fsg_buffhd *bh = req->context; in bulk_out_complete() local
434 if (req->status || req->actual != bh->bulk_out_intended_length) in bulk_out_complete()
436 req->status, req->actual, bh->bulk_out_intended_length); in bulk_out_complete()
441 smp_store_release(&bh->state, BUF_STATE_FULL); in bulk_out_complete()
544 static bool start_in_transfer(struct fsg_common *common, struct fsg_buffhd *bh) in start_in_transfer() argument
550 bh->state = BUF_STATE_SENDING; in start_in_transfer()
551 rc = start_transfer(common->fsg, common->fsg->bulk_in, bh->inreq); in start_in_transfer()
553 bh->state = BUF_STATE_EMPTY; in start_in_transfer()
562 static bool start_out_transfer(struct fsg_common *common, struct fsg_buffhd *bh) in start_out_transfer() argument
568 bh->state = BUF_STATE_RECEIVING; in start_out_transfer()
569 rc = start_transfer(common->fsg, common->fsg->bulk_out, bh->outreq); in start_out_transfer()
571 bh->state = BUF_STATE_FULL; in start_out_transfer()
581 struct fsg_buffhd *bh) in sleep_thread() argument
592 bh && smp_load_acquire(&bh->state) >= in sleep_thread()
596 bh && smp_load_acquire(&bh->state) >= in sleep_thread()
608 struct fsg_buffhd *bh; in do_read() local
657 bh = common->next_buffhd_to_fill; in do_read()
658 rc = sleep_thread(common, false, bh); in do_read()
672 bh->inreq->length = 0; in do_read()
673 bh->state = BUF_STATE_FULL; in do_read()
679 nread = kernel_read(curlun->filp, bh->buf, amount, in do_read()
703 bh->inreq->length = nread; in do_read()
704 bh->state = BUF_STATE_FULL; in do_read()
719 bh->inreq->zero = 0; in do_read()
720 if (!start_in_transfer(common, bh)) in do_read()
723 common->next_buffhd_to_fill = bh->next; in do_read()
736 struct fsg_buffhd *bh; in do_write() local
791 bh = common->next_buffhd_to_fill; in do_write()
792 if (bh->state == BUF_STATE_EMPTY && get_some_more) { in do_write()
824 set_bulk_out_req_length(common, bh, amount); in do_write()
825 if (!start_out_transfer(common, bh)) in do_write()
828 common->next_buffhd_to_fill = bh->next; in do_write()
833 bh = common->next_buffhd_to_drain; in do_write()
834 if (bh->state == BUF_STATE_EMPTY && !get_some_more) in do_write()
838 rc = sleep_thread(common, false, bh); in do_write()
842 common->next_buffhd_to_drain = bh->next; in do_write()
843 bh->state = BUF_STATE_EMPTY; in do_write()
846 if (bh->outreq->status != 0) { in do_write()
854 amount = bh->outreq->actual; in do_write()
866 amount = min(amount, bh->bulk_out_intended_length); in do_write()
875 nwritten = kernel_write(curlun->filp, bh->buf, amount, in do_write()
906 if (bh->outreq->actual < bh->bulk_out_intended_length) { in do_write()
949 struct fsg_buffhd *bh = common->next_buffhd_to_fill; in do_verify() local
1013 nread = kernel_read(curlun->filp, bh->buf, amount, in do_verify()
1045 static int do_inquiry(struct fsg_common *common, struct fsg_buffhd *bh) in do_inquiry() argument
1048 u8 *buf = (u8 *) bh->buf; in do_inquiry()
1075 static int do_request_sense(struct fsg_common *common, struct fsg_buffhd *bh) in do_request_sense() argument
1078 u8 *buf = (u8 *) bh->buf; in do_request_sense()
1128 static int do_read_capacity(struct fsg_common *common, struct fsg_buffhd *bh) in do_read_capacity() argument
1133 u8 *buf = (u8 *)bh->buf; in do_read_capacity()
1147 static int do_read_header(struct fsg_common *common, struct fsg_buffhd *bh) in do_read_header() argument
1152 u8 *buf = (u8 *)bh->buf; in do_read_header()
1169 static int do_read_toc(struct fsg_common *common, struct fsg_buffhd *bh) in do_read_toc() argument
1174 u8 *buf = (u8 *)bh->buf; in do_read_toc()
1243 static int do_mode_sense(struct fsg_common *common, struct fsg_buffhd *bh) in do_mode_sense() argument
1247 u8 *buf = (u8 *) bh->buf; in do_mode_sense()
1404 struct fsg_buffhd *bh) in do_read_format_capacities() argument
1407 u8 *buf = (u8 *) bh->buf; in do_read_format_capacities()
1420 static int do_mode_select(struct fsg_common *common, struct fsg_buffhd *bh) in do_mode_select() argument
1480 struct fsg_buffhd *bh, *bh2; in throw_away_data() local
1484 for (bh = common->next_buffhd_to_drain; in throw_away_data()
1485 bh->state != BUF_STATE_EMPTY || common->usb_amount_left > 0; in throw_away_data()
1486 bh = common->next_buffhd_to_drain) { in throw_away_data()
1509 rc = sleep_thread(common, false, bh); in throw_away_data()
1514 bh->state = BUF_STATE_EMPTY; in throw_away_data()
1515 common->next_buffhd_to_drain = bh->next; in throw_away_data()
1518 if (bh->outreq->actual < bh->bulk_out_intended_length || in throw_away_data()
1519 bh->outreq->status != 0) { in throw_away_data()
1529 struct fsg_buffhd *bh = common->next_buffhd_to_fill; in finish_reply() local
1565 bh->inreq->zero = 0; in finish_reply()
1566 if (!start_in_transfer(common, bh)) in finish_reply()
1568 common->next_buffhd_to_fill = bh->next; in finish_reply()
1578 bh->inreq->zero = 1; in finish_reply()
1579 if (!start_in_transfer(common, bh)) in finish_reply()
1581 common->next_buffhd_to_fill = bh->next; in finish_reply()
1632 struct fsg_buffhd *bh; in send_status() local
1639 bh = common->next_buffhd_to_fill; in send_status()
1640 rc = sleep_thread(common, false, bh); in send_status()
1665 csw = (void *)bh->buf; in send_status()
1672 bh->inreq->length = US_BULK_CS_WRAP_LEN; in send_status()
1673 bh->inreq->zero = 0; in send_status()
1674 if (!start_in_transfer(common, bh)) in send_status()
1678 common->next_buffhd_to_fill = bh->next; in send_status()
1830 struct fsg_buffhd *bh; in do_scsi_command() local
1839 bh = common->next_buffhd_to_fill; in do_scsi_command()
1840 common->next_buffhd_to_drain = bh; in do_scsi_command()
1841 rc = sleep_thread(common, false, bh); in do_scsi_command()
1857 reply = do_inquiry(common, bh); in do_scsi_command()
1866 reply = do_mode_select(common, bh); in do_scsi_command()
1876 reply = do_mode_select(common, bh); in do_scsi_command()
1885 reply = do_mode_sense(common, bh); in do_scsi_command()
1895 reply = do_mode_sense(common, bh); in do_scsi_command()
1946 reply = do_read_capacity(common, bh); in do_scsi_command()
1958 reply = do_read_header(common, bh); in do_scsi_command()
1970 reply = do_read_toc(common, bh); in do_scsi_command()
1980 reply = do_read_format_capacities(common, bh); in do_scsi_command()
1989 reply = do_request_sense(common, bh); in do_scsi_command()
2096 bh->inreq->length = reply; in do_scsi_command()
2097 bh->state = BUF_STATE_FULL; in do_scsi_command()
2107 static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) in received_cbw() argument
2109 struct usb_request *req = bh->outreq; in received_cbw()
2181 struct fsg_buffhd *bh; in get_next_command() local
2185 bh = common->next_buffhd_to_fill; in get_next_command()
2186 rc = sleep_thread(common, true, bh); in get_next_command()
2191 set_bulk_out_req_length(common, bh, US_BULK_CB_WRAP_LEN); in get_next_command()
2192 if (!start_out_transfer(common, bh)) in get_next_command()
2203 rc = sleep_thread(common, true, bh); in get_next_command()
2207 rc = fsg_is_set(common) ? received_cbw(common->fsg, bh) : -EIO; in get_next_command()
2208 bh->state = BUF_STATE_EMPTY; in get_next_command()
2241 struct fsg_buffhd *bh = &common->buffhds[i]; in do_set_interface() local
2243 if (bh->inreq) { in do_set_interface()
2244 usb_ep_free_request(fsg->bulk_in, bh->inreq); in do_set_interface()
2245 bh->inreq = NULL; in do_set_interface()
2247 if (bh->outreq) { in do_set_interface()
2248 usb_ep_free_request(fsg->bulk_out, bh->outreq); in do_set_interface()
2249 bh->outreq = NULL; in do_set_interface()
2298 struct fsg_buffhd *bh = &common->buffhds[i]; in do_set_interface() local
2300 rc = alloc_request(common, fsg->bulk_in, &bh->inreq); in do_set_interface()
2303 rc = alloc_request(common, fsg->bulk_out, &bh->outreq); in do_set_interface()
2306 bh->inreq->buf = bh->outreq->buf = bh->buf; in do_set_interface()
2307 bh->inreq->context = bh->outreq->context = bh; in do_set_interface()
2308 bh->inreq->complete = bulk_in_complete; in do_set_interface()
2309 bh->outreq->complete = bulk_out_complete; in do_set_interface()
2354 struct fsg_buffhd *bh; in handle_exception() local
2380 bh = &common->buffhds[i]; in handle_exception()
2381 if (bh->state == BUF_STATE_SENDING) in handle_exception()
2382 usb_ep_dequeue(common->fsg->bulk_in, bh->inreq); in handle_exception()
2383 if (bh->state == BUF_STATE_RECEIVING) in handle_exception()
2385 bh->outreq); in handle_exception()
2388 if (sleep_thread(common, false, bh)) in handle_exception()
2406 bh = &common->buffhds[i]; in handle_exception()
2407 bh->state = BUF_STATE_EMPTY; in handle_exception()
2638 struct fsg_buffhd *bh = buffhds; in _fsg_common_free_buffers() local
2640 kfree(bh->buf); in _fsg_common_free_buffers()
2641 ++bh; in _fsg_common_free_buffers()
2649 struct fsg_buffhd *bh, *buffhds; in fsg_common_set_num_buffers() local
2657 bh = buffhds; in fsg_common_set_num_buffers()
2661 bh->next = bh + 1; in fsg_common_set_num_buffers()
2662 ++bh; in fsg_common_set_num_buffers()
2664 bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL); in fsg_common_set_num_buffers()
2665 if (unlikely(!bh->buf)) in fsg_common_set_num_buffers()
2668 bh->next = buffhds; in fsg_common_set_num_buffers()