Lines Matching refs:srp

176 static int sg_start_req(Sg_request *srp, unsigned char *cmd);
177 static int sg_finish_rem_req(Sg_request * srp);
180 Sg_request * srp);
184 static int sg_common_write(Sg_fd * sfp, Sg_request * srp,
186 static int sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer);
189 static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size);
190 static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp);
195 static int sg_remove_request(Sg_fd * sfp, Sg_request * srp);
413 Sg_request *srp; in sg_read() local
462 srp = sg_get_rq_mark(sfp, req_pack_id); in sg_read()
463 if (!srp) { /* now wait on packet to arrive */ in sg_read()
474 (srp = sg_get_rq_mark(sfp, req_pack_id)))); in sg_read()
484 if (srp->header.interface_id != '\0') { in sg_read()
485 retval = sg_new_read(sfp, buf, count, srp); in sg_read()
489 hp = &srp->header; in sg_read()
502 ((srp->data.cmd_opcode >= 0xc0) && (12 == hp->cmd_len)) ? 1 : 0; in sg_read()
508 memcpy(old_hdr->sense_buffer, srp->sense_b, in sg_read()
531 old_hdr->result = (srp->sense_b[0] == 0 && in sg_read()
549 if (sg_read_oxfer(srp, buf, count - SZ_SG_HEADER)) { in sg_read()
556 sg_finish_rem_req(srp); in sg_read()
557 sg_remove_request(sfp, srp); in sg_read()
565 sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) in sg_new_read() argument
567 sg_io_hdr_t *hp = &srp->header; in sg_new_read()
581 len = 8 + (int) srp->sense_b[7]; /* Additional sense length field */ in sg_new_read()
583 if (copy_to_user(hp->sbp, srp->sense_b, len)) { in sg_new_read()
597 err2 = sg_finish_rem_req(srp); in sg_new_read()
598 sg_remove_request(sfp, srp); in sg_new_read()
610 Sg_request *srp; in sg_write() local
643 if (!(srp = sg_add_request(sfp))) { in sg_write()
668 sg_remove_request(sfp, srp); in sg_write()
671 hp = &srp->header; in sg_write()
709 k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking); in sg_write()
719 Sg_request *srp; in sg_new_write() local
731 if (!(srp = sg_add_request(sfp))) { in sg_new_write()
736 srp->sg_io_owned = sg_io_owned; in sg_new_write()
737 hp = &srp->header; in sg_new_write()
739 sg_remove_request(sfp, srp); in sg_new_write()
743 sg_remove_request(sfp, srp); in sg_new_write()
748 sg_remove_request(sfp, srp); in sg_new_write()
752 sg_remove_request(sfp, srp); in sg_new_write()
756 sg_remove_request(sfp, srp); in sg_new_write()
760 ul_timeout = msecs_to_jiffies(srp->header.timeout); in sg_new_write()
763 sg_remove_request(sfp, srp); in sg_new_write()
767 sg_remove_request(sfp, srp); in sg_new_write()
771 sg_remove_request(sfp, srp); in sg_new_write()
775 sg_remove_request(sfp, srp); in sg_new_write()
778 k = sg_common_write(sfp, srp, cmnd, timeout, blocking); in sg_new_write()
782 *o_srp = srp; in sg_new_write()
787 sg_common_write(Sg_fd * sfp, Sg_request * srp, in sg_common_write() argument
792 sg_io_hdr_t *hp = &srp->header; in sg_common_write()
794 srp->data.cmd_opcode = cmnd[0]; /* hold opcode of command */ in sg_common_write()
809 k = sg_start_req(srp, cmnd); in sg_common_write()
813 sg_finish_rem_req(srp); in sg_common_write()
814 sg_remove_request(sfp, srp); in sg_common_write()
818 if (srp->bio) { in sg_common_write()
819 scsi_req_free_cmd(scsi_req(srp->rq)); in sg_common_write()
820 blk_put_request(srp->rq); in sg_common_write()
821 srp->rq = NULL; in sg_common_write()
824 sg_finish_rem_req(srp); in sg_common_write()
825 sg_remove_request(sfp, srp); in sg_common_write()
836 srp->rq->timeout = timeout; in sg_common_write()
839 srp->rq, at_head, sg_rq_end_io); in sg_common_write()
843 static int srp_done(Sg_fd *sfp, Sg_request *srp) in srp_done() argument
849 ret = srp->done; in srp_done()
866 Sg_request *srp; in sg_fill_request_table() local
871 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_fill_request_table()
874 rinfo[val].req_state = srp->done + 1; in sg_fill_request_table()
876 srp->header.masked_status & in sg_fill_request_table()
877 srp->header.host_status & in sg_fill_request_table()
878 srp->header.driver_status; in sg_fill_request_table()
879 if (srp->done) in sg_fill_request_table()
881 srp->header.duration; in sg_fill_request_table()
885 (ms > srp->header.duration) ? in sg_fill_request_table()
886 (ms - srp->header.duration) : 0; in sg_fill_request_table()
888 rinfo[val].orphan = srp->orphan; in sg_fill_request_table()
889 rinfo[val].sg_io_owned = srp->sg_io_owned; in sg_fill_request_table()
890 rinfo[val].pack_id = srp->header.pack_id; in sg_fill_request_table()
891 rinfo[val].usr_ptr = srp->header.usr_ptr; in sg_fill_request_table()
904 Sg_request *srp; in sg_ioctl() local
923 1, read_only, 1, &srp); in sg_ioctl()
927 (srp_done(sfp, srp) || atomic_read(&sdp->detaching))); in sg_ioctl()
931 if (srp->done) { in sg_ioctl()
932 srp->done = 2; in sg_ioctl()
934 result = sg_new_read(sfp, p, SZ_SG_IO_HDR, srp); in sg_ioctl()
937 srp->orphan = 1; in sg_ioctl()
998 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_ioctl()
999 if ((1 == srp->done) && (!srp->sg_io_owned)) { in sg_ioctl()
1002 __put_user(srp->header.pack_id, ip); in sg_ioctl()
1012 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_ioctl()
1013 if ((1 == srp->done) && (!srp->sg_io_owned)) in sg_ioctl()
1172 Sg_request *srp; in sg_poll() local
1184 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_poll()
1186 if ((0 == res) && (1 == srp->done) && (!srp->sg_io_owned)) in sg_poll()
1303 struct sg_request *srp = container_of(work, struct sg_request, ew.work); in sg_rq_end_io_usercontext() local
1304 struct sg_fd *sfp = srp->parentfp; in sg_rq_end_io_usercontext()
1306 sg_finish_rem_req(srp); in sg_rq_end_io_usercontext()
1307 sg_remove_request(sfp, srp); in sg_rq_end_io_usercontext()
1318 struct sg_request *srp = rq->end_io_data; in sg_rq_end_io() local
1327 if (WARN_ON(srp->done != 0)) in sg_rq_end_io()
1330 sfp = srp->parentfp; in sg_rq_end_io()
1344 srp->header.pack_id, result)); in sg_rq_end_io()
1345 srp->header.resid = resid; in sg_rq_end_io()
1347 srp->header.duration = (ms > srp->header.duration) ? in sg_rq_end_io()
1348 (ms - srp->header.duration) : 0; in sg_rq_end_io()
1352 srp->header.status = 0xff & result; in sg_rq_end_io()
1353 srp->header.masked_status = status_byte(result); in sg_rq_end_io()
1354 srp->header.msg_status = msg_byte(result); in sg_rq_end_io()
1355 srp->header.host_status = host_byte(result); in sg_rq_end_io()
1356 srp->header.driver_status = driver_byte(result); in sg_rq_end_io()
1358 ((CHECK_CONDITION == srp->header.masked_status) || in sg_rq_end_io()
1359 (COMMAND_TERMINATED == srp->header.masked_status))) in sg_rq_end_io()
1376 memcpy(srp->sense_b, req->sense, SCSI_SENSE_BUFFERSIZE); in sg_rq_end_io()
1386 srp->rq = NULL; in sg_rq_end_io()
1391 if (unlikely(srp->orphan)) { in sg_rq_end_io()
1393 srp->sg_io_owned = 0; in sg_rq_end_io()
1397 srp->done = done; in sg_rq_end_io()
1408 INIT_WORK(&srp->ew.work, sg_rq_end_io_usercontext); in sg_rq_end_io()
1409 schedule_work(&srp->ew.work); in sg_rq_end_io()
1698 sg_start_req(Sg_request *srp, unsigned char *cmd) in sg_start_req() argument
1703 Sg_fd *sfp = srp->parentfp; in sg_start_req()
1704 sg_io_hdr_t *hp = &srp->header; in sg_start_req()
1708 Sg_scatter_hold *req_schp = &srp->data; in sg_start_req()
1749 srp->rq = rq; in sg_start_req()
1750 rq->end_io_data = srp; in sg_start_req()
1769 sg_link_reserve(sfp, srp, dxfer_len); in sg_start_req()
1817 srp->bio = rq->bio; in sg_start_req()
1828 sg_finish_rem_req(Sg_request *srp) in sg_finish_rem_req() argument
1832 Sg_fd *sfp = srp->parentfp; in sg_finish_rem_req()
1833 Sg_scatter_hold *req_schp = &srp->data; in sg_finish_rem_req()
1837 (int) srp->res_used)); in sg_finish_rem_req()
1838 if (srp->bio) in sg_finish_rem_req()
1839 ret = blk_rq_unmap_user(srp->bio); in sg_finish_rem_req()
1841 if (srp->rq) { in sg_finish_rem_req()
1842 scsi_req_free_cmd(scsi_req(srp->rq)); in sg_finish_rem_req()
1843 blk_put_request(srp->rq); in sg_finish_rem_req()
1846 if (srp->res_used) in sg_finish_rem_req()
1847 sg_unlink_reserve(sfp, srp); in sg_finish_rem_req()
1973 sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer) in sg_read_oxfer() argument
1975 Sg_scatter_hold *schp = &srp->data; in sg_read_oxfer()
1978 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, srp->parentfp->parentdp, in sg_read_oxfer()
2024 sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size) in sg_link_reserve() argument
2026 Sg_scatter_hold *req_schp = &srp->data; in sg_link_reserve()
2030 srp->res_used = 1; in sg_link_reserve()
2055 sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp) in sg_unlink_reserve() argument
2057 Sg_scatter_hold *req_schp = &srp->data; in sg_unlink_reserve()
2059 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, srp->parentfp->parentdp, in sg_unlink_reserve()
2067 srp->res_used = 0; in sg_unlink_reserve()
2125 sg_remove_request(Sg_fd * sfp, Sg_request * srp) in sg_remove_request() argument
2130 if (!sfp || !srp || list_empty(&sfp->rq_list)) in sg_remove_request()
2133 if (!list_empty(&srp->entry)) { in sg_remove_request()
2134 list_del(&srp->entry); in sg_remove_request()
2135 srp->parentfp = NULL; in sg_remove_request()
2195 Sg_request *srp; in sg_remove_sfp_usercontext() local
2201 srp = list_first_entry(&sfp->rq_list, Sg_request, entry); in sg_remove_sfp_usercontext()
2202 sg_finish_rem_req(srp); in sg_remove_sfp_usercontext()
2203 list_del(&srp->entry); in sg_remove_sfp_usercontext()
2204 srp->parentfp = NULL; in sg_remove_sfp_usercontext()
2516 Sg_request *srp; in sg_proc_debug_helper() local
2535 list_for_each_entry(srp, &fp->rq_list, entry) { in sg_proc_debug_helper()
2536 hp = &srp->header; in sg_proc_debug_helper()
2538 if (srp->res_used) { in sg_proc_debug_helper()
2551 blen = srp->data.bufflen; in sg_proc_debug_helper()
2552 usg = srp->data.k_use_sg; in sg_proc_debug_helper()
2553 seq_puts(s, srp->done ? in sg_proc_debug_helper()
2554 ((1 == srp->done) ? "rcv:" : "fin:") in sg_proc_debug_helper()
2557 srp->header.pack_id, blen); in sg_proc_debug_helper()
2558 if (srp->done) in sg_proc_debug_helper()
2568 (int) srp->data.cmd_opcode); in sg_proc_debug_helper()