aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/sg.c33
1 files changed, 5 insertions, 28 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 07bd68331303..df8bf67b171a 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -188,7 +188,6 @@ static ssize_t sg_new_write(Sg_fd *sfp, struct file *file,
188 int read_only, Sg_request **o_srp); 188 int read_only, Sg_request **o_srp);
189static int sg_common_write(Sg_fd * sfp, Sg_request * srp, 189static int sg_common_write(Sg_fd * sfp, Sg_request * srp,
190 unsigned char *cmnd, int timeout, int blocking); 190 unsigned char *cmnd, int timeout, int blocking);
191static int sg_read_xfer(Sg_request * srp);
192static int sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer); 191static int sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer);
193static void sg_remove_scat(Sg_scatter_hold * schp); 192static void sg_remove_scat(Sg_scatter_hold * schp);
194static void sg_build_reserve(Sg_fd * sfp, int req_size); 193static void sg_build_reserve(Sg_fd * sfp, int req_size);
@@ -523,8 +522,11 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp)
523 err = -EFAULT; 522 err = -EFAULT;
524 goto err_out; 523 goto err_out;
525 } 524 }
526 err = sg_read_xfer(srp); 525 if (srp->bio) {
527 err_out: 526 err = blk_rq_unmap_user(srp->bio);
527 srp->bio = NULL;
528 }
529err_out:
528 sg_finish_rem_req(srp); 530 sg_finish_rem_req(srp);
529 return (0 == err) ? count : err; 531 return (0 == err) ? count : err;
530} 532}
@@ -1832,31 +1834,6 @@ sg_remove_scat(Sg_scatter_hold * schp)
1832} 1834}
1833 1835
1834static int 1836static int
1835sg_read_xfer(Sg_request * srp)
1836{
1837 sg_io_hdr_t *hp = &srp->header;
1838 Sg_scatter_hold *schp = &srp->data;
1839 int num_xfer = 0;
1840 int dxfer_dir = hp->dxfer_direction;
1841 int new_interface = ('\0' == hp->interface_id) ? 0 : 1;
1842
1843 if ((SG_DXFER_UNKNOWN == dxfer_dir) || (SG_DXFER_FROM_DEV == dxfer_dir)
1844 || (SG_DXFER_TO_FROM_DEV == dxfer_dir)) {
1845 num_xfer = hp->dxfer_len;
1846 if (schp->bufflen < num_xfer)
1847 num_xfer = schp->bufflen;
1848 }
1849 if ((num_xfer <= 0) || (schp->dio_in_use) ||
1850 (new_interface
1851 && ((SG_FLAG_NO_DXFER | SG_FLAG_MMAP_IO) & hp->flags)))
1852 return 0;
1853
1854 SCSI_LOG_TIMEOUT(4, printk("sg_read_xfer: num_xfer=%d, iovec_count=%d, k_use_sg=%d\n",
1855 num_xfer, (int)hp->iovec_count, schp->k_use_sg));
1856 return 0;
1857}
1858
1859static int
1860sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer) 1837sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer)
1861{ 1838{
1862 Sg_scatter_hold *schp = &srp->data; 1839 Sg_scatter_hold *schp = &srp->data;