• Home
  • Raw
  • Download

Lines Matching refs:sfp

181 static int sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size);
182 static int sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp,
184 static ssize_t sg_new_read(Sg_fd * sfp, char __user *buf, size_t count,
186 static ssize_t sg_new_write(Sg_fd *sfp, struct file *file,
189 static int sg_common_write(Sg_fd * sfp, Sg_request * srp,
193 static void sg_build_reserve(Sg_fd * sfp, int req_size);
194 static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size);
195 static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp);
197 static int sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp);
198 static void __sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp);
199 static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id);
200 static Sg_request *sg_add_request(Sg_fd * sfp);
201 static int sg_remove_request(Sg_fd * sfp, Sg_request * srp);
202 static int sg_res_in_use(Sg_fd * sfp);
215 struct sg_fd *sfp = (struct sg_fd *)filp->private_data; in sg_allow_access() local
216 struct request_queue *q = sfp->parentdp->device->request_queue; in sg_allow_access()
218 if (sfp->parentdp->device->type == TYPE_SCANNER) in sg_allow_access()
232 Sg_fd *sfp; in sg_open() local
303 if ((sfp = sg_add_sfp(sdp, dev))) in sg_open()
304 filp->private_data = sfp; in sg_open()
325 Sg_fd *sfp; in sg_release() local
327 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) in sg_release()
330 if (0 == sg_remove_sfp(sdp, sfp)) { /* Returns 1 when sdp gone */ in sg_release()
344 Sg_fd *sfp; in sg_read() local
351 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) in sg_read()
358 if (sfp->force_packid && (count >= SZ_SG_HEADER)) { in sg_read()
386 srp = sg_get_rq_mark(sfp, req_pack_id); in sg_read()
398 __wait_event_interruptible(sfp->read_wait, in sg_read()
400 (srp = sg_get_rq_mark(sfp, req_pack_id))), in sg_read()
414 retval = sg_new_read(sfp, buf, count, srp); in sg_read()
493 sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) in sg_new_read() argument
536 Sg_fd *sfp; in sg_write() local
542 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) in sg_write()
560 return sg_new_write(sfp, filp, buf, count, blocking, 0, NULL); in sg_write()
564 if (!(srp = sg_add_request(sfp))) { in sg_write()
570 if (sfp->next_cmd_len > 0) { in sg_write()
571 if (sfp->next_cmd_len > MAX_COMMAND_SIZE) { in sg_write()
573 sfp->next_cmd_len = 0; in sg_write()
574 sg_remove_request(sfp, srp); in sg_write()
577 cmd_size = sfp->next_cmd_len; in sg_write()
578 sfp->next_cmd_len = 0; /* reset so only this write() effected */ in sg_write()
592 sg_remove_request(sfp, srp); in sg_write()
635 k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking); in sg_write()
640 sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf, in sg_new_write() argument
656 sfp->cmd_q = 1; /* when sg_io_hdr seen, set command queuing on */ in sg_new_write()
657 if (!(srp = sg_add_request(sfp))) { in sg_new_write()
663 sg_remove_request(sfp, srp); in sg_new_write()
667 sg_remove_request(sfp, srp); in sg_new_write()
671 if (hp->dxfer_len > sfp->reserve.bufflen) { in sg_new_write()
672 sg_remove_request(sfp, srp); in sg_new_write()
676 sg_remove_request(sfp, srp); in sg_new_write()
679 if (sg_res_in_use(sfp)) { in sg_new_write()
680 sg_remove_request(sfp, srp); in sg_new_write()
687 sg_remove_request(sfp, srp); in sg_new_write()
691 sg_remove_request(sfp, srp); in sg_new_write()
695 sg_remove_request(sfp, srp); in sg_new_write()
699 sg_remove_request(sfp, srp); in sg_new_write()
702 k = sg_common_write(sfp, srp, cmnd, timeout, blocking); in sg_new_write()
711 sg_common_write(Sg_fd * sfp, Sg_request * srp, in sg_common_write() argument
715 Sg_device *sdp = sfp->parentdp; in sg_common_write()
764 sg_srp_done(Sg_request *srp, Sg_fd *sfp) in sg_srp_done() argument
769 read_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_srp_done()
771 read_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_srp_done()
783 Sg_fd *sfp; in sg_ioctl() local
787 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) in sg_ioctl()
806 sg_new_write(sfp, filp, p, SZ_SG_IO_HDR, in sg_ioctl()
813 __wait_event_interruptible(sfp->read_wait, in sg_ioctl()
814 (sdp->detached || sfp->closed || sg_srp_done(srp, sfp)), in sg_ioctl()
818 if (sfp->closed) in sg_ioctl()
825 write_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_ioctl()
827 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_ioctl()
828 result = sg_new_read(sfp, p, SZ_SG_IO_HDR, srp); in sg_ioctl()
839 sfp->timeout_user = val; in sg_ioctl()
840 sfp->timeout = MULDIV (val, HZ, USER_HZ); in sg_ioctl()
845 return sfp->timeout_user; in sg_ioctl()
851 sfp->low_dma = 1; in sg_ioctl()
852 if ((0 == sfp->low_dma) && (0 == sg_res_in_use(sfp))) { in sg_ioctl()
853 val = (int) sfp->reserve.bufflen; in sg_ioctl()
854 sg_remove_scat(&sfp->reserve); in sg_ioctl()
855 sg_build_reserve(sfp, val); in sg_ioctl()
860 sfp->low_dma = sdp->device->host->unchecked_isa_dma; in sg_ioctl()
864 return put_user((int) sfp->low_dma, ip); in sg_ioctl()
892 sfp->force_packid = val ? 1 : 0; in sg_ioctl()
897 read_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_ioctl()
898 for (srp = sfp->headrp; srp; srp = srp->nextrp) { in sg_ioctl()
900 read_unlock_irqrestore(&sfp->rq_list_lock, in sg_ioctl()
906 read_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_ioctl()
910 read_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_ioctl()
911 for (val = 0, srp = sfp->headrp; srp; srp = srp->nextrp) { in sg_ioctl()
915 read_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_ioctl()
927 if (val != sfp->reserve.bufflen) { in sg_ioctl()
928 if (sg_res_in_use(sfp) || sfp->mmap_called) in sg_ioctl()
930 sg_remove_scat(&sfp->reserve); in sg_ioctl()
931 sg_build_reserve(sfp, val); in sg_ioctl()
935 val = min_t(int, sfp->reserve.bufflen, in sg_ioctl()
942 sfp->cmd_q = val ? 1 : 0; in sg_ioctl()
945 return put_user((int) sfp->cmd_q, ip); in sg_ioctl()
950 sfp->keep_orphan = val; in sg_ioctl()
953 return put_user((int) sfp->keep_orphan, ip); in sg_ioctl()
958 sfp->next_cmd_len = (val > 0) ? val : 0; in sg_ioctl()
977 read_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_ioctl()
978 for (srp = sfp->headrp, val = 0; val < SG_MAX_QUEUE; in sg_ioctl()
1005 read_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_ioctl()
1100 Sg_fd *sfp; in sg_compat_ioctl() local
1103 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) in sg_compat_ioctl()
1124 Sg_fd *sfp; in sg_poll() local
1129 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)) in sg_poll()
1130 || sfp->closed) in sg_poll()
1132 poll_wait(filp, &sfp->read_wait, wait); in sg_poll()
1133 read_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_poll()
1134 for (srp = sfp->headrp; srp; srp = srp->nextrp) { in sg_poll()
1140 read_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_poll()
1144 else if (!sfp->cmd_q) { in sg_poll()
1159 Sg_fd *sfp; in sg_fasync() local
1161 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) in sg_fasync()
1166 retval = fasync_helper(fd, filp, mode, &sfp->async_qp); in sg_fasync()
1173 Sg_fd *sfp; in sg_vma_fault() local
1178 if ((NULL == vma) || (!(sfp = (Sg_fd *) vma->vm_private_data))) in sg_vma_fault()
1180 rsv_schp = &sfp->reserve; in sg_vma_fault()
1212 Sg_fd *sfp; in sg_mmap() local
1217 if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data))) in sg_mmap()
1224 rsv_schp = &sfp->reserve; in sg_mmap()
1236 sfp->mmap_called = 1; in sg_mmap()
1238 vma->vm_private_data = sfp; in sg_mmap()
1251 Sg_fd *sfp; in sg_rq_end_io() local
1261 sfp = srp->parentfp; in sg_rq_end_io()
1262 if (sfp) in sg_rq_end_io()
1263 sdp = sfp->parentdp; in sg_rq_end_io()
1306 if (sfp->closed) { /* whoops this fd already released, cleanup */ in sg_rq_end_io()
1310 if (NULL == sfp->headrp) { in sg_rq_end_io()
1312 if (0 == sg_remove_sfp(sdp, sfp)) { /* device still present */ in sg_rq_end_io()
1315 sfp = NULL; in sg_rq_end_io()
1318 if (sfp->keep_orphan) in sg_rq_end_io()
1325 if (sfp && srp) { in sg_rq_end_io()
1327 kill_fasync(&sfp->async_qp, SIGPOLL, POLL_IN); in sg_rq_end_io()
1328 write_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_rq_end_io()
1330 wake_up_interruptible(&sfp->read_wait); in sg_rq_end_io()
1331 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_rq_end_io()
1497 Sg_fd *sfp; in sg_remove() local
1510 for (sfp = sdp->headfp; sfp; sfp = tsfp) { in sg_remove()
1511 tsfp = sfp->nextfp; in sg_remove()
1512 for (srp = sfp->headrp; srp; srp = tsrp) { in sg_remove()
1514 if (sfp->closed || (0 == sg_srp_done(srp, sfp))) in sg_remove()
1517 if (sfp->closed) { in sg_remove()
1519 __sg_remove_sfp(sdp, sfp); in sg_remove()
1522 wake_up_interruptible(&sfp->read_wait); in sg_remove()
1523 kill_fasync(&sfp->async_qp, SIGPOLL, in sg_remove()
1621 Sg_fd *sfp = srp->parentfp; in sg_start_req() local
1627 Sg_scatter_hold *rsv_schp = &sfp->reserve; in sg_start_req()
1628 struct request_queue *q = sfp->parentdp->device->request_queue; in sg_start_req()
1654 !sfp->parentdp->device->host->unchecked_isa_dma && in sg_start_req()
1661 if (!sg_res_in_use(sfp) && dxfer_len <= rsv_schp->bufflen) in sg_start_req()
1662 sg_link_reserve(sfp, srp, dxfer_len); in sg_start_req()
1664 res = sg_build_indirect(req_schp, sfp, dxfer_len); in sg_start_req()
1697 Sg_fd *sfp = srp->parentfp; in sg_finish_rem_req() local
1702 sg_unlink_reserve(sfp, srp); in sg_finish_rem_req()
1713 sg_remove_request(sfp, srp); in sg_finish_rem_req()
1717 sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, int tablesize) in sg_build_sgat() argument
1730 sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) in sg_build_indirect() argument
1733 int sg_tablesize = sfp->parentdp->sg_tablesize; in sg_build_indirect()
1747 mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize); in sg_build_indirect()
1760 if (sfp->low_dma) in sg_build_indirect()
1864 sg_build_reserve(Sg_fd * sfp, int req_size) in sg_build_reserve() argument
1866 Sg_scatter_hold *schp = &sfp->reserve; in sg_build_reserve()
1872 if (0 == sg_build_indirect(schp, sfp, req_size)) in sg_build_reserve()
1881 sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size) in sg_link_reserve() argument
1884 Sg_scatter_hold *rsv_schp = &sfp->reserve; in sg_link_reserve()
1910 sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp) in sg_unlink_reserve() argument
1921 sfp->save_scat_len = 0; in sg_unlink_reserve()
1926 sg_get_rq_mark(Sg_fd * sfp, int pack_id) in sg_get_rq_mark() argument
1931 write_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_get_rq_mark()
1932 for (resp = sfp->headrp; resp; resp = resp->nextrp) { in sg_get_rq_mark()
1940 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_get_rq_mark()
1946 sg_get_nth_request(Sg_fd * sfp, int nth) in sg_get_nth_request() argument
1952 read_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_get_nth_request()
1953 for (k = 0, resp = sfp->headrp; resp && (k < nth); in sg_get_nth_request()
1955 read_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_get_nth_request()
1962 sg_add_request(Sg_fd * sfp) in sg_add_request() argument
1967 Sg_request *rp = sfp->req_arr; in sg_add_request()
1969 write_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_add_request()
1970 resp = sfp->headrp; in sg_add_request()
1973 rp->parentfp = sfp; in sg_add_request()
1975 sfp->headrp = resp; in sg_add_request()
1977 if (0 == sfp->cmd_q) in sg_add_request()
1986 rp->parentfp = sfp; in sg_add_request()
1999 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_add_request()
2005 sg_remove_request(Sg_fd * sfp, Sg_request * srp) in sg_remove_request() argument
2012 if ((!sfp) || (!srp) || (!sfp->headrp)) in sg_remove_request()
2014 write_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_remove_request()
2015 prev_rp = sfp->headrp; in sg_remove_request()
2017 sfp->headrp = prev_rp->nextrp; in sg_remove_request()
2031 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_remove_request()
2054 Sg_fd *sfp; in sg_add_sfp() local
2058 sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN); in sg_add_sfp()
2059 if (!sfp) in sg_add_sfp()
2062 init_waitqueue_head(&sfp->read_wait); in sg_add_sfp()
2063 rwlock_init(&sfp->rq_list_lock); in sg_add_sfp()
2065 sfp->timeout = SG_DEFAULT_TIMEOUT; in sg_add_sfp()
2066 sfp->timeout_user = SG_DEFAULT_TIMEOUT_USER; in sg_add_sfp()
2067 sfp->force_packid = SG_DEF_FORCE_PACK_ID; in sg_add_sfp()
2068 sfp->low_dma = (SG_DEF_FORCE_LOW_DMA == 0) ? in sg_add_sfp()
2070 sfp->cmd_q = SG_DEF_COMMAND_Q; in sg_add_sfp()
2071 sfp->keep_orphan = SG_DEF_KEEP_ORPHAN; in sg_add_sfp()
2072 sfp->parentdp = sdp; in sg_add_sfp()
2075 sdp->headfp = sfp; in sg_add_sfp()
2080 pfp->nextfp = sfp; in sg_add_sfp()
2083 SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: sfp=0x%p\n", sfp)); in sg_add_sfp()
2089 sg_build_reserve(sfp, bufflen); in sg_add_sfp()
2091 sfp->reserve.bufflen, sfp->reserve.k_use_sg)); in sg_add_sfp()
2092 return sfp; in sg_add_sfp()
2096 __sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp) in __sg_remove_sfp() argument
2102 if (sfp == prev_fp) in __sg_remove_sfp()
2106 if (sfp == fp) { in __sg_remove_sfp()
2113 if (sfp->reserve.bufflen > 0) { in __sg_remove_sfp()
2116 (int) sfp->reserve.bufflen, (int) sfp->reserve.k_use_sg)); in __sg_remove_sfp()
2117 sg_remove_scat(&sfp->reserve); in __sg_remove_sfp()
2119 sfp->parentdp = NULL; in __sg_remove_sfp()
2120 SCSI_LOG_TIMEOUT(6, printk("__sg_remove_sfp: sfp=0x%p\n", sfp)); in __sg_remove_sfp()
2121 kfree(sfp); in __sg_remove_sfp()
2126 sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp) in sg_remove_sfp() argument
2133 for (srp = sfp->headrp; srp; srp = tsrp) { in sg_remove_sfp()
2135 if (sg_srp_done(srp, sfp)) in sg_remove_sfp()
2144 __sg_remove_sfp(sdp, sfp); in sg_remove_sfp()
2156 sfp->closed = 1; /* flag dirty state on this fd */ in sg_remove_sfp()
2164 sg_res_in_use(Sg_fd * sfp) in sg_res_in_use() argument
2169 read_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_res_in_use()
2170 for (srp = sfp->headrp; srp; srp = srp->nextrp) in sg_res_in_use()
2173 read_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_res_in_use()