Lines Matching refs:bh
366 struct fsg_buffhd *bh, unsigned int length) in set_bulk_out_req_length() argument
370 bh->bulk_out_intended_length = length; in set_bulk_out_req_length()
374 bh->outreq->length = length; in set_bulk_out_req_length()
454 struct fsg_buffhd *bh = req->context; in bulk_in_complete() local
465 bh->inreq_busy = 0; in bulk_in_complete()
466 bh->state = BUF_STATE_EMPTY; in bulk_in_complete()
474 struct fsg_buffhd *bh = req->context; in bulk_out_complete() local
477 if (req->status || req->actual != bh->bulk_out_intended_length) in bulk_out_complete()
479 req->status, req->actual, bh->bulk_out_intended_length); in bulk_out_complete()
486 bh->outreq_busy = 0; in bulk_out_complete()
487 bh->state = BUF_STATE_FULL; in bulk_out_complete()
596 static bool start_in_transfer(struct fsg_common *common, struct fsg_buffhd *bh) in start_in_transfer() argument
601 bh->inreq, &bh->inreq_busy, &bh->state); in start_in_transfer()
605 static bool start_out_transfer(struct fsg_common *common, struct fsg_buffhd *bh) in start_out_transfer() argument
610 bh->outreq, &bh->outreq_busy, &bh->state); in start_out_transfer()
644 struct fsg_buffhd *bh; in do_read() local
693 bh = common->next_buffhd_to_fill; in do_read()
694 while (bh->state != BUF_STATE_EMPTY) { in do_read()
710 bh->inreq->length = 0; in do_read()
711 bh->state = BUF_STATE_FULL; in do_read()
718 (char __user *)bh->buf, in do_read()
742 bh->inreq->length = nread; in do_read()
743 bh->state = BUF_STATE_FULL; in do_read()
758 bh->inreq->zero = 0; in do_read()
759 if (!start_in_transfer(common, bh)) in do_read()
762 common->next_buffhd_to_fill = bh->next; in do_read()
775 struct fsg_buffhd *bh; in do_write() local
830 bh = common->next_buffhd_to_fill; in do_write()
831 if (bh->state == BUF_STATE_EMPTY && get_some_more) { in do_write()
863 set_bulk_out_req_length(common, bh, amount); in do_write()
864 if (!start_out_transfer(common, bh)) in do_write()
867 common->next_buffhd_to_fill = bh->next; in do_write()
872 bh = common->next_buffhd_to_drain; in do_write()
873 if (bh->state == BUF_STATE_EMPTY && !get_some_more) in do_write()
875 if (bh->state == BUF_STATE_FULL) { in do_write()
877 common->next_buffhd_to_drain = bh->next; in do_write()
878 bh->state = BUF_STATE_EMPTY; in do_write()
881 if (bh->outreq->status != 0) { in do_write()
889 amount = bh->outreq->actual; in do_write()
901 amount = min(amount, bh->bulk_out_intended_length); in do_write()
911 (char __user *)bh->buf, in do_write()
942 if (bh->outreq->actual < bh->bulk_out_intended_length) { in do_write()
992 struct fsg_buffhd *bh = common->next_buffhd_to_fill; in do_verify() local
1057 (char __user *) bh->buf, in do_verify()
1089 static int do_inquiry(struct fsg_common *common, struct fsg_buffhd *bh) in do_inquiry() argument
1092 u8 *buf = (u8 *) bh->buf; in do_inquiry()
1114 static int do_request_sense(struct fsg_common *common, struct fsg_buffhd *bh) in do_request_sense() argument
1117 u8 *buf = (u8 *) bh->buf; in do_request_sense()
1167 static int do_read_capacity(struct fsg_common *common, struct fsg_buffhd *bh) in do_read_capacity() argument
1172 u8 *buf = (u8 *)bh->buf; in do_read_capacity()
1186 static int do_read_header(struct fsg_common *common, struct fsg_buffhd *bh) in do_read_header() argument
1191 u8 *buf = (u8 *)bh->buf; in do_read_header()
1208 static int do_read_toc(struct fsg_common *common, struct fsg_buffhd *bh) in do_read_toc() argument
1213 u8 *buf = (u8 *)bh->buf; in do_read_toc()
1235 static int do_mode_sense(struct fsg_common *common, struct fsg_buffhd *bh) in do_mode_sense() argument
1239 u8 *buf = (u8 *) bh->buf; in do_mode_sense()
1396 struct fsg_buffhd *bh) in do_read_format_capacities() argument
1399 u8 *buf = (u8 *) bh->buf; in do_read_format_capacities()
1412 static int do_mode_select(struct fsg_common *common, struct fsg_buffhd *bh) in do_mode_select() argument
1472 struct fsg_buffhd *bh; in throw_away_data() local
1476 for (bh = common->next_buffhd_to_drain; in throw_away_data()
1477 bh->state != BUF_STATE_EMPTY || common->usb_amount_left > 0; in throw_away_data()
1478 bh = common->next_buffhd_to_drain) { in throw_away_data()
1481 if (bh->state == BUF_STATE_FULL) { in throw_away_data()
1483 bh->state = BUF_STATE_EMPTY; in throw_away_data()
1484 common->next_buffhd_to_drain = bh->next; in throw_away_data()
1487 if (bh->outreq->actual < bh->bulk_out_intended_length || in throw_away_data()
1488 bh->outreq->status != 0) { in throw_away_data()
1497 bh = common->next_buffhd_to_fill; in throw_away_data()
1498 if (bh->state == BUF_STATE_EMPTY in throw_away_data()
1507 set_bulk_out_req_length(common, bh, amount); in throw_away_data()
1508 if (!start_out_transfer(common, bh)) in throw_away_data()
1511 common->next_buffhd_to_fill = bh->next; in throw_away_data()
1526 struct fsg_buffhd *bh = common->next_buffhd_to_fill; in finish_reply() local
1562 bh->inreq->zero = 0; in finish_reply()
1563 if (!start_in_transfer(common, bh)) in finish_reply()
1565 common->next_buffhd_to_fill = bh->next; in finish_reply()
1575 bh->inreq->zero = 1; in finish_reply()
1576 if (!start_in_transfer(common, bh)) in finish_reply()
1578 common->next_buffhd_to_fill = bh->next; in finish_reply()
1629 struct fsg_buffhd *bh; in send_status() local
1636 bh = common->next_buffhd_to_fill; in send_status()
1637 while (bh->state != BUF_STATE_EMPTY) { in send_status()
1664 csw = (void *)bh->buf; in send_status()
1671 bh->inreq->length = US_BULK_CS_WRAP_LEN; in send_status()
1672 bh->inreq->zero = 0; in send_status()
1673 if (!start_in_transfer(common, bh)) in send_status()
1677 common->next_buffhd_to_fill = bh->next; in send_status()
1829 struct fsg_buffhd *bh; in do_scsi_command() local
1838 bh = common->next_buffhd_to_fill; in do_scsi_command()
1839 common->next_buffhd_to_drain = bh; in do_scsi_command()
1840 while (bh->state != BUF_STATE_EMPTY) { 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()
2097 bh->inreq->length = reply; in do_scsi_command()
2098 bh->state = BUF_STATE_FULL; in do_scsi_command()
2108 static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) in received_cbw() argument
2110 struct usb_request *req = bh->outreq; in received_cbw()
2182 struct fsg_buffhd *bh; in get_next_command() local
2186 bh = common->next_buffhd_to_fill; in get_next_command()
2187 while (bh->state != BUF_STATE_EMPTY) { in get_next_command()
2194 set_bulk_out_req_length(common, bh, US_BULK_CB_WRAP_LEN); in get_next_command()
2195 if (!start_out_transfer(common, bh)) in get_next_command()
2206 while (bh->state != BUF_STATE_FULL) { in get_next_command()
2212 rc = fsg_is_set(common) ? received_cbw(common->fsg, bh) : -EIO; in get_next_command()
2213 bh->state = BUF_STATE_EMPTY; in get_next_command()
2246 struct fsg_buffhd *bh = &common->buffhds[i]; in do_set_interface() local
2248 if (bh->inreq) { in do_set_interface()
2249 usb_ep_free_request(fsg->bulk_in, bh->inreq); in do_set_interface()
2250 bh->inreq = NULL; in do_set_interface()
2252 if (bh->outreq) { in do_set_interface()
2253 usb_ep_free_request(fsg->bulk_out, bh->outreq); in do_set_interface()
2254 bh->outreq = NULL; in do_set_interface()
2305 struct fsg_buffhd *bh = &common->buffhds[i]; in do_set_interface() local
2307 rc = alloc_request(common, fsg->bulk_in, &bh->inreq); in do_set_interface()
2310 rc = alloc_request(common, fsg->bulk_out, &bh->outreq); in do_set_interface()
2313 bh->inreq->buf = bh->outreq->buf = bh->buf; in do_set_interface()
2314 bh->inreq->context = bh->outreq->context = bh; in do_set_interface()
2315 bh->inreq->complete = bulk_in_complete; in do_set_interface()
2316 bh->outreq->complete = bulk_out_complete; in do_set_interface()
2352 struct fsg_buffhd *bh; in handle_exception() local
2376 bh = &common->buffhds[i]; in handle_exception()
2377 if (bh->inreq_busy) in handle_exception()
2378 usb_ep_dequeue(common->fsg->bulk_in, bh->inreq); in handle_exception()
2379 if (bh->outreq_busy) in handle_exception()
2381 bh->outreq); in handle_exception()
2388 bh = &common->buffhds[i]; in handle_exception()
2389 num_active += bh->inreq_busy + bh->outreq_busy; in handle_exception()
2411 bh = &common->buffhds[i]; in handle_exception()
2412 bh->state = BUF_STATE_EMPTY; in handle_exception()
2702 struct fsg_buffhd *bh = buffhds; in _fsg_common_free_buffers() local
2704 kfree(bh->buf); in _fsg_common_free_buffers()
2705 ++bh; in _fsg_common_free_buffers()
2713 struct fsg_buffhd *bh, *buffhds; in fsg_common_set_num_buffers() local
2725 bh = buffhds; in fsg_common_set_num_buffers()
2729 bh->next = bh + 1; in fsg_common_set_num_buffers()
2730 ++bh; in fsg_common_set_num_buffers()
2732 bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL); in fsg_common_set_num_buffers()
2733 if (unlikely(!bh->buf)) in fsg_common_set_num_buffers()
2736 bh->next = buffhds; in fsg_common_set_num_buffers()