• Home
  • Raw
  • Download

Lines Matching refs:sfp

194 static int sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size);
195 static ssize_t sg_new_read(Sg_fd * sfp, char __user *buf, size_t count,
197 static ssize_t sg_new_write(Sg_fd *sfp, struct file *file,
200 static int sg_common_write(Sg_fd * sfp, Sg_request * srp,
203 static void sg_remove_scat(Sg_fd * sfp, Sg_scatter_hold * schp);
204 static void sg_build_reserve(Sg_fd * sfp, int req_size);
205 static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size);
206 static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp);
209 static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id);
210 static Sg_request *sg_add_request(Sg_fd * sfp);
211 static int sg_remove_request(Sg_fd * sfp, Sg_request * srp);
226 struct sg_fd *sfp = filp->private_data; in sg_allow_access() local
228 if (sfp->parentdp->device->type == TYPE_SCANNER) in sg_allow_access()
278 Sg_fd *sfp; in sg_open() local
339 sfp = sg_add_sfp(sdp); in sg_open()
340 if (IS_ERR(sfp)) { in sg_open()
341 retval = PTR_ERR(sfp); in sg_open()
345 filp->private_data = sfp; in sg_open()
374 Sg_fd *sfp; in sg_release() local
376 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) in sg_release()
382 kref_put(&sfp->f_ref, sg_remove_sfp); in sg_release()
401 Sg_fd *sfp; in sg_read() local
408 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) in sg_read()
415 if (sfp->force_packid && (count >= SZ_SG_HEADER)) { in sg_read()
443 srp = sg_get_rq_mark(sfp, req_pack_id); in sg_read()
453 retval = wait_event_interruptible(sfp->read_wait, in sg_read()
455 (srp = sg_get_rq_mark(sfp, req_pack_id)))); in sg_read()
466 retval = sg_new_read(sfp, buf, count, srp); in sg_read()
545 sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) in sg_new_read() argument
588 Sg_fd *sfp; in sg_write() local
597 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) in sg_write()
615 return sg_new_write(sfp, filp, buf, count, in sg_write()
620 if (!(srp = sg_add_request(sfp))) { in sg_write()
627 mutex_lock(&sfp->f_mutex); in sg_write()
628 if (sfp->next_cmd_len > 0) { in sg_write()
629 cmd_size = sfp->next_cmd_len; in sg_write()
630 sfp->next_cmd_len = 0; /* reset so only this write() effected */ in sg_write()
636 mutex_unlock(&sfp->f_mutex); in sg_write()
645 sg_remove_request(sfp, srp); in sg_write()
690 k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking); in sg_write()
695 sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf, in sg_new_write() argument
711 sfp->cmd_q = 1; /* when sg_io_hdr seen, set command queuing on */ in sg_new_write()
712 if (!(srp = sg_add_request(sfp))) { in sg_new_write()
713 SCSI_LOG_TIMEOUT(1, sg_printk(KERN_INFO, sfp->parentdp, in sg_new_write()
720 sg_remove_request(sfp, srp); in sg_new_write()
724 sg_remove_request(sfp, srp); in sg_new_write()
728 if (hp->dxfer_len > sfp->reserve.bufflen) { in sg_new_write()
729 sg_remove_request(sfp, srp); in sg_new_write()
733 sg_remove_request(sfp, srp); in sg_new_write()
736 if (sfp->res_in_use) { in sg_new_write()
737 sg_remove_request(sfp, srp); in sg_new_write()
744 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()
759 k = sg_common_write(sfp, srp, cmnd, timeout, blocking); in sg_new_write()
768 sg_common_write(Sg_fd * sfp, Sg_request * srp, in sg_common_write() argument
772 Sg_device *sdp = sfp->parentdp; in sg_common_write()
783 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp, in sg_common_write()
789 SCSI_LOG_TIMEOUT(1, sg_printk(KERN_INFO, sfp->parentdp, in sg_common_write()
830 kref_get(&sfp->f_ref); /* sg_rq_end_io() does kref_put(). */ in sg_common_write()
836 static int srp_done(Sg_fd *sfp, Sg_request *srp) in srp_done() argument
841 read_lock_irqsave(&sfp->rq_list_lock, flags); in srp_done()
843 read_unlock_irqrestore(&sfp->rq_list_lock, flags); in srp_done()
857 sg_fill_request_table(Sg_fd *sfp, sg_req_info_t *rinfo) in sg_fill_request_table() argument
864 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_fill_request_table()
896 Sg_fd *sfp; in sg_ioctl() local
900 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) in sg_ioctl()
915 result = sg_new_write(sfp, filp, p, SZ_SG_IO_HDR, in sg_ioctl()
919 result = wait_event_interruptible(sfp->read_wait, in sg_ioctl()
920 (srp_done(sfp, srp) || atomic_read(&sdp->detaching))); in sg_ioctl()
923 write_lock_irq(&sfp->rq_list_lock); in sg_ioctl()
926 write_unlock_irq(&sfp->rq_list_lock); in sg_ioctl()
927 result = sg_new_read(sfp, p, SZ_SG_IO_HDR, srp); in sg_ioctl()
931 write_unlock_irq(&sfp->rq_list_lock); in sg_ioctl()
941 sfp->timeout_user = val; in sg_ioctl()
942 sfp->timeout = MULDIV (val, HZ, USER_HZ); in sg_ioctl()
947 return sfp->timeout_user; in sg_ioctl()
984 sfp->force_packid = val ? 1 : 0; in sg_ioctl()
989 read_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_ioctl()
990 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_ioctl()
992 read_unlock_irqrestore(&sfp->rq_list_lock, in sg_ioctl()
998 read_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_ioctl()
1002 read_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_ioctl()
1004 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_ioctl()
1008 read_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_ioctl()
1020 mutex_lock(&sfp->f_mutex); in sg_ioctl()
1021 if (val != sfp->reserve.bufflen) { in sg_ioctl()
1022 if (sfp->mmap_called || in sg_ioctl()
1023 sfp->res_in_use) { in sg_ioctl()
1024 mutex_unlock(&sfp->f_mutex); in sg_ioctl()
1028 sg_remove_scat(sfp, &sfp->reserve); in sg_ioctl()
1029 sg_build_reserve(sfp, val); in sg_ioctl()
1031 mutex_unlock(&sfp->f_mutex); in sg_ioctl()
1034 val = min_t(int, sfp->reserve.bufflen, in sg_ioctl()
1041 sfp->cmd_q = val ? 1 : 0; in sg_ioctl()
1044 return put_user((int) sfp->cmd_q, ip); in sg_ioctl()
1049 sfp->keep_orphan = val; in sg_ioctl()
1052 return put_user((int) sfp->keep_orphan, ip); in sg_ioctl()
1059 sfp->next_cmd_len = (val > 0) ? val : 0; in sg_ioctl()
1077 read_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_ioctl()
1078 sg_fill_request_table(sfp, rinfo); in sg_ioctl()
1079 read_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_ioctl()
1175 Sg_fd *sfp; in sg_compat_ioctl() local
1178 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) in sg_compat_ioctl()
1199 Sg_fd *sfp; in sg_poll() local
1204 sfp = filp->private_data; in sg_poll()
1205 if (!sfp) in sg_poll()
1207 sdp = sfp->parentdp; in sg_poll()
1210 poll_wait(filp, &sfp->read_wait, wait); in sg_poll()
1211 read_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_poll()
1212 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_poll()
1218 read_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_poll()
1222 else if (!sfp->cmd_q) { in sg_poll()
1236 Sg_fd *sfp; in sg_fasync() local
1238 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) in sg_fasync()
1243 return fasync_helper(fd, filp, mode, &sfp->async_qp); in sg_fasync()
1249 Sg_fd *sfp; in sg_vma_fault() local
1254 if ((NULL == vma) || (!(sfp = (Sg_fd *) vma->vm_private_data))) in sg_vma_fault()
1256 rsv_schp = &sfp->reserve; in sg_vma_fault()
1260 SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sfp->parentdp, in sg_vma_fault()
1289 Sg_fd *sfp; in sg_mmap() local
1295 if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data))) in sg_mmap()
1298 SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sfp->parentdp, in sg_mmap()
1303 rsv_schp = &sfp->reserve; in sg_mmap()
1304 mutex_lock(&sfp->f_mutex); in sg_mmap()
1318 sfp->mmap_called = 1; in sg_mmap()
1320 vma->vm_private_data = sfp; in sg_mmap()
1323 mutex_unlock(&sfp->f_mutex); in sg_mmap()
1331 struct sg_fd *sfp = srp->parentfp; in sg_rq_end_io_usercontext() local
1334 kref_put(&sfp->f_ref, sg_remove_sfp); in sg_rq_end_io_usercontext()
1346 Sg_fd *sfp; in sg_rq_end_io() local
1355 sfp = srp->parentfp; in sg_rq_end_io()
1356 if (WARN_ON(sfp == NULL)) in sg_rq_end_io()
1359 sdp = sfp->parentdp; in sg_rq_end_io()
1412 write_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_rq_end_io()
1414 if (sfp->keep_orphan) in sg_rq_end_io()
1420 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_rq_end_io()
1426 wake_up_interruptible(&sfp->read_wait); in sg_rq_end_io()
1427 kill_fasync(&sfp->async_qp, SIGPOLL, POLL_IN); in sg_rq_end_io()
1428 kref_put(&sfp->f_ref, sg_remove_sfp); in sg_rq_end_io()
1623 Sg_fd *sfp; in sg_remove_device() local
1637 list_for_each_entry(sfp, &sdp->sfds, sfd_siblings) { in sg_remove_device()
1638 wake_up_interruptible_all(&sfp->read_wait); in sg_remove_device()
1639 kill_fasync(&sfp->async_qp, SIGPOLL, POLL_HUP); in sg_remove_device()
1724 Sg_fd *sfp = srp->parentfp; in sg_start_req() local
1730 Sg_scatter_hold *rsv_schp = &sfp->reserve; in sg_start_req()
1731 struct request_queue *q = sfp->parentdp->device->request_queue; in sg_start_req()
1736 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp, in sg_start_req()
1784 !sfp->parentdp->device->host->unchecked_isa_dma && in sg_start_req()
1791 mutex_lock(&sfp->f_mutex); in sg_start_req()
1793 !sfp->res_in_use) { in sg_start_req()
1794 sfp->res_in_use = 1; in sg_start_req()
1795 sg_link_reserve(sfp, srp, dxfer_len); in sg_start_req()
1800 mutex_unlock(&sfp->f_mutex); in sg_start_req()
1803 res = sg_build_indirect(req_schp, sfp, dxfer_len); in sg_start_req()
1805 mutex_unlock(&sfp->f_mutex); in sg_start_req()
1809 mutex_unlock(&sfp->f_mutex); in sg_start_req()
1863 Sg_fd *sfp = srp->parentfp; in sg_finish_rem_req() local
1866 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp, in sg_finish_rem_req()
1879 sg_unlink_reserve(sfp, srp); in sg_finish_rem_req()
1881 sg_remove_scat(sfp, req_schp); in sg_finish_rem_req()
1883 sg_remove_request(sfp, srp); in sg_finish_rem_req()
1889 sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, int tablesize) in sg_build_sgat() argument
1902 sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) in sg_build_indirect() argument
1905 int sg_tablesize = sfp->parentdp->sg_tablesize; in sg_build_indirect()
1908 struct sg_device *sdp = sfp->parentdp; in sg_build_indirect()
1916 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp, in sg_build_indirect()
1921 mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize); in sg_build_indirect()
1961 SCSI_LOG_TIMEOUT(5, sg_printk(KERN_INFO, sfp->parentdp, in sg_build_indirect()
1968 SCSI_LOG_TIMEOUT(5, sg_printk(KERN_INFO, sfp->parentdp, in sg_build_indirect()
1987 sg_remove_scat(Sg_fd * sfp, Sg_scatter_hold * schp) in sg_remove_scat() argument
1989 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp, in sg_remove_scat()
1997 sg_printk(KERN_INFO, sfp->parentdp, in sg_remove_scat()
2043 sg_build_reserve(Sg_fd * sfp, int req_size) in sg_build_reserve() argument
2045 Sg_scatter_hold *schp = &sfp->reserve; in sg_build_reserve()
2047 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp, in sg_build_reserve()
2052 if (0 == sg_build_indirect(schp, sfp, req_size)) in sg_build_reserve()
2055 sg_remove_scat(sfp, schp); in sg_build_reserve()
2061 sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size) in sg_link_reserve() argument
2064 Sg_scatter_hold *rsv_schp = &sfp->reserve; in sg_link_reserve()
2068 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp, in sg_link_reserve()
2087 SCSI_LOG_TIMEOUT(1, sg_printk(KERN_INFO, sfp->parentdp, in sg_link_reserve()
2092 sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp) in sg_unlink_reserve() argument
2106 sfp->res_in_use = 0; in sg_unlink_reserve()
2110 sg_get_rq_mark(Sg_fd * sfp, int pack_id) in sg_get_rq_mark() argument
2115 write_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_get_rq_mark()
2116 list_for_each_entry(resp, &sfp->rq_list, entry) { in sg_get_rq_mark()
2124 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_get_rq_mark()
2130 sg_add_request(Sg_fd * sfp) in sg_add_request() argument
2134 Sg_request *rp = sfp->req_arr; in sg_add_request()
2136 write_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_add_request()
2137 if (!list_empty(&sfp->rq_list)) { in sg_add_request()
2138 if (!sfp->cmd_q) in sg_add_request()
2149 rp->parentfp = sfp; in sg_add_request()
2151 list_add_tail(&rp->entry, &sfp->rq_list); in sg_add_request()
2152 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_add_request()
2155 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_add_request()
2161 sg_remove_request(Sg_fd * sfp, Sg_request * srp) in sg_remove_request() argument
2166 if (!sfp || !srp || list_empty(&sfp->rq_list)) in sg_remove_request()
2168 write_lock_irqsave(&sfp->rq_list_lock, iflags); in sg_remove_request()
2174 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); in sg_remove_request()
2181 Sg_fd *sfp; in sg_add_sfp() local
2185 sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN); in sg_add_sfp()
2186 if (!sfp) in sg_add_sfp()
2189 init_waitqueue_head(&sfp->read_wait); in sg_add_sfp()
2190 rwlock_init(&sfp->rq_list_lock); in sg_add_sfp()
2191 INIT_LIST_HEAD(&sfp->rq_list); in sg_add_sfp()
2192 kref_init(&sfp->f_ref); in sg_add_sfp()
2193 mutex_init(&sfp->f_mutex); in sg_add_sfp()
2194 sfp->timeout = SG_DEFAULT_TIMEOUT; in sg_add_sfp()
2195 sfp->timeout_user = SG_DEFAULT_TIMEOUT_USER; in sg_add_sfp()
2196 sfp->force_packid = SG_DEF_FORCE_PACK_ID; in sg_add_sfp()
2197 sfp->cmd_q = SG_DEF_COMMAND_Q; in sg_add_sfp()
2198 sfp->keep_orphan = SG_DEF_KEEP_ORPHAN; in sg_add_sfp()
2199 sfp->parentdp = sdp; in sg_add_sfp()
2205 list_add_tail(&sfp->sfd_siblings, &sdp->sfds); in sg_add_sfp()
2208 "sg_add_sfp: sfp=0x%p\n", sfp)); in sg_add_sfp()
2214 sg_build_reserve(sfp, bufflen); in sg_add_sfp()
2217 sfp->reserve.bufflen, in sg_add_sfp()
2218 sfp->reserve.k_use_sg)); in sg_add_sfp()
2222 return sfp; in sg_add_sfp()
2228 struct sg_fd *sfp = container_of(work, struct sg_fd, ew.work); in sg_remove_sfp_usercontext() local
2229 struct sg_device *sdp = sfp->parentdp; in sg_remove_sfp_usercontext()
2233 while (!list_empty(&sfp->rq_list)) { in sg_remove_sfp_usercontext()
2234 srp = list_first_entry(&sfp->rq_list, Sg_request, entry); in sg_remove_sfp_usercontext()
2238 if (sfp->reserve.bufflen > 0) { in sg_remove_sfp_usercontext()
2241 (int) sfp->reserve.bufflen, in sg_remove_sfp_usercontext()
2242 (int) sfp->reserve.k_use_sg)); in sg_remove_sfp_usercontext()
2243 sg_remove_scat(sfp, &sfp->reserve); in sg_remove_sfp_usercontext()
2247 "sg_remove_sfp: sfp=0x%p\n", sfp)); in sg_remove_sfp_usercontext()
2248 kfree(sfp); in sg_remove_sfp_usercontext()
2258 struct sg_fd *sfp = container_of(kref, struct sg_fd, f_ref); in sg_remove_sfp() local
2259 struct sg_device *sdp = sfp->parentdp; in sg_remove_sfp()
2263 list_del(&sfp->sfd_siblings); in sg_remove_sfp()
2266 INIT_WORK(&sfp->ew.work, sg_remove_sfp_usercontext); in sg_remove_sfp()
2267 schedule_work(&sfp->ew.work); in sg_remove_sfp()