aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sg.c
diff options
context:
space:
mode:
authorJörn Engel <joern@logfs.org>2012-04-12 17:33:25 -0400
committerJames Bottomley <JBottomley@Parallels.com>2012-05-17 05:08:53 -0400
commit3f0c6aba0b65a68013c1e0db1b015f02e6ec24be (patch)
tree9af2cdcfa608b794d783674f1e68129cf6d2d31d /drivers/scsi/sg.c
parent794c10fa0fa4d1781c5651c31e3d4d0b71629128 (diff)
[SCSI] sg: use wait_event_interruptible()
Afaics the use of __wait_event_interruptible() as opposed to wait_event_interruptible() is purely historic. So let's follow the rest of the kernel and check the condition before prepare_to_wait() - and also make the code a bit nicer. Signed-off-by: Joern Engel <joern@logfs.org> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r--drivers/scsi/sg.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index be812e09058d..1a0be4f1d1fa 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -268,9 +268,8 @@ sg_open(struct inode *inode, struct file *filp)
268 retval = -EBUSY; 268 retval = -EBUSY;
269 goto error_out; 269 goto error_out;
270 } 270 }
271 res = 0; 271 res = wait_event_interruptible(sdp->o_excl_wait,
272 __wait_event_interruptible(sdp->o_excl_wait, 272 ((!list_empty(&sdp->sfds) || sdp->exclude) ? 0 : (sdp->exclude = 1)));
273 ((!list_empty(&sdp->sfds) || sdp->exclude) ? 0 : (sdp->exclude = 1)), res);
274 if (res) { 273 if (res) {
275 retval = res; /* -ERESTARTSYS because signal hit process */ 274 retval = res; /* -ERESTARTSYS because signal hit process */
276 goto error_out; 275 goto error_out;
@@ -280,9 +279,7 @@ sg_open(struct inode *inode, struct file *filp)
280 retval = -EBUSY; 279 retval = -EBUSY;
281 goto error_out; 280 goto error_out;
282 } 281 }
283 res = 0; 282 res = wait_event_interruptible(sdp->o_excl_wait, !sdp->exclude);
284 __wait_event_interruptible(sdp->o_excl_wait, (!sdp->exclude),
285 res);
286 if (res) { 283 if (res) {
287 retval = res; /* -ERESTARTSYS because signal hit process */ 284 retval = res; /* -ERESTARTSYS because signal hit process */
288 goto error_out; 285 goto error_out;
@@ -398,10 +395,9 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
398 retval = -EAGAIN; 395 retval = -EAGAIN;
399 goto free_old_hdr; 396 goto free_old_hdr;
400 } 397 }
401 retval = 0; /* following macro beats race condition */ 398 retval = wait_event_interruptible(sfp->read_wait,
402 __wait_event_interruptible(sfp->read_wait,
403 (sdp->detached || 399 (sdp->detached ||
404 (srp = sg_get_rq_mark(sfp, req_pack_id))), retval); 400 (srp = sg_get_rq_mark(sfp, req_pack_id))));
405 if (sdp->detached) { 401 if (sdp->detached) {
406 retval = -ENODEV; 402 retval = -ENODEV;
407 goto free_old_hdr; 403 goto free_old_hdr;
@@ -797,9 +793,8 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
797 1, read_only, 1, &srp); 793 1, read_only, 1, &srp);
798 if (result < 0) 794 if (result < 0)
799 return result; 795 return result;
800 result = 0; /* following macro to beat race condition */ 796 result = wait_event_interruptible(sfp->read_wait,
801 __wait_event_interruptible(sfp->read_wait, 797 (srp->done || sdp->detached));
802 (srp->done || sdp->detached), result);
803 if (sdp->detached) 798 if (sdp->detached)
804 return -ENODEV; 799 return -ENODEV;
805 write_lock_irq(&sfp->rq_list_lock); 800 write_lock_irq(&sfp->rq_list_lock);