aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/loop.c31
-rw-r--r--drivers/block/sx8.c12
2 files changed, 20 insertions, 23 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index a452b13620a2..864729046e22 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -215,7 +215,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
215 unsigned offset, bv_offs; 215 unsigned offset, bv_offs;
216 int len, ret; 216 int len, ret;
217 217
218 down(&mapping->host->i_sem); 218 mutex_lock(&mapping->host->i_mutex);
219 index = pos >> PAGE_CACHE_SHIFT; 219 index = pos >> PAGE_CACHE_SHIFT;
220 offset = pos & ((pgoff_t)PAGE_CACHE_SIZE - 1); 220 offset = pos & ((pgoff_t)PAGE_CACHE_SIZE - 1);
221 bv_offs = bvec->bv_offset; 221 bv_offs = bvec->bv_offset;
@@ -278,7 +278,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
278 } 278 }
279 ret = 0; 279 ret = 0;
280out: 280out:
281 up(&mapping->host->i_sem); 281 mutex_unlock(&mapping->host->i_mutex);
282 return ret; 282 return ret;
283unlock: 283unlock:
284 unlock_page(page); 284 unlock_page(page);
@@ -527,12 +527,12 @@ static int loop_make_request(request_queue_t *q, struct bio *old_bio)
527 lo->lo_pending++; 527 lo->lo_pending++;
528 loop_add_bio(lo, old_bio); 528 loop_add_bio(lo, old_bio);
529 spin_unlock_irq(&lo->lo_lock); 529 spin_unlock_irq(&lo->lo_lock);
530 up(&lo->lo_bh_mutex); 530 complete(&lo->lo_bh_done);
531 return 0; 531 return 0;
532 532
533out: 533out:
534 if (lo->lo_pending == 0) 534 if (lo->lo_pending == 0)
535 up(&lo->lo_bh_mutex); 535 complete(&lo->lo_bh_done);
536 spin_unlock_irq(&lo->lo_lock); 536 spin_unlock_irq(&lo->lo_lock);
537 bio_io_error(old_bio, old_bio->bi_size); 537 bio_io_error(old_bio, old_bio->bi_size);
538 return 0; 538 return 0;
@@ -593,23 +593,20 @@ static int loop_thread(void *data)
593 lo->lo_pending = 1; 593 lo->lo_pending = 1;
594 594
595 /* 595 /*
596 * up sem, we are running 596 * complete it, we are running
597 */ 597 */
598 up(&lo->lo_sem); 598 complete(&lo->lo_done);
599 599
600 for (;;) { 600 for (;;) {
601 int pending; 601 int pending;
602 602
603 /* 603 if (wait_for_completion_interruptible(&lo->lo_bh_done))
604 * interruptible just to not contribute to load avg
605 */
606 if (down_interruptible(&lo->lo_bh_mutex))
607 continue; 604 continue;
608 605
609 spin_lock_irq(&lo->lo_lock); 606 spin_lock_irq(&lo->lo_lock);
610 607
611 /* 608 /*
612 * could be upped because of tear-down, not pending work 609 * could be completed because of tear-down, not pending work
613 */ 610 */
614 if (unlikely(!lo->lo_pending)) { 611 if (unlikely(!lo->lo_pending)) {
615 spin_unlock_irq(&lo->lo_lock); 612 spin_unlock_irq(&lo->lo_lock);
@@ -632,7 +629,7 @@ static int loop_thread(void *data)
632 break; 629 break;
633 } 630 }
634 631
635 up(&lo->lo_sem); 632 complete(&lo->lo_done);
636 return 0; 633 return 0;
637} 634}
638 635
@@ -843,7 +840,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
843 set_blocksize(bdev, lo_blocksize); 840 set_blocksize(bdev, lo_blocksize);
844 841
845 kernel_thread(loop_thread, lo, CLONE_KERNEL); 842 kernel_thread(loop_thread, lo, CLONE_KERNEL);
846 down(&lo->lo_sem); 843 wait_for_completion(&lo->lo_done);
847 return 0; 844 return 0;
848 845
849 out_putf: 846 out_putf:
@@ -909,10 +906,10 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
909 lo->lo_state = Lo_rundown; 906 lo->lo_state = Lo_rundown;
910 lo->lo_pending--; 907 lo->lo_pending--;
911 if (!lo->lo_pending) 908 if (!lo->lo_pending)
912 up(&lo->lo_bh_mutex); 909 complete(&lo->lo_bh_done);
913 spin_unlock_irq(&lo->lo_lock); 910 spin_unlock_irq(&lo->lo_lock);
914 911
915 down(&lo->lo_sem); 912 wait_for_completion(&lo->lo_done);
916 913
917 lo->lo_backing_file = NULL; 914 lo->lo_backing_file = NULL;
918 915
@@ -1289,8 +1286,8 @@ static int __init loop_init(void)
1289 if (!lo->lo_queue) 1286 if (!lo->lo_queue)
1290 goto out_mem4; 1287 goto out_mem4;
1291 init_MUTEX(&lo->lo_ctl_mutex); 1288 init_MUTEX(&lo->lo_ctl_mutex);
1292 init_MUTEX_LOCKED(&lo->lo_sem); 1289 init_completion(&lo->lo_done);
1293 init_MUTEX_LOCKED(&lo->lo_bh_mutex); 1290 init_completion(&lo->lo_bh_done);
1294 lo->lo_number = i; 1291 lo->lo_number = i;
1295 spin_lock_init(&lo->lo_lock); 1292 spin_lock_init(&lo->lo_lock);
1296 disk->major = LOOP_MAJOR; 1293 disk->major = LOOP_MAJOR;
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index a7e0975c8c9f..2ae08b343b93 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -27,8 +27,8 @@
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/hdreg.h> 28#include <linux/hdreg.h>
29#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
30#include <linux/completion.h>
30#include <asm/io.h> 31#include <asm/io.h>
31#include <asm/semaphore.h>
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33 33
34#if 0 34#if 0
@@ -303,7 +303,7 @@ struct carm_host {
303 303
304 struct work_struct fsm_task; 304 struct work_struct fsm_task;
305 305
306 struct semaphore probe_sem; 306 struct completion probe_comp;
307}; 307};
308 308
309struct carm_response { 309struct carm_response {
@@ -1346,7 +1346,7 @@ static void carm_fsm_task (void *_data)
1346 } 1346 }
1347 1347
1348 case HST_PROBE_FINISHED: 1348 case HST_PROBE_FINISHED:
1349 up(&host->probe_sem); 1349 complete(&host->probe_comp);
1350 break; 1350 break;
1351 1351
1352 case HST_ERROR: 1352 case HST_ERROR:
@@ -1622,7 +1622,7 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1622 host->flags = pci_dac ? FL_DAC : 0; 1622 host->flags = pci_dac ? FL_DAC : 0;
1623 spin_lock_init(&host->lock); 1623 spin_lock_init(&host->lock);
1624 INIT_WORK(&host->fsm_task, carm_fsm_task, host); 1624 INIT_WORK(&host->fsm_task, carm_fsm_task, host);
1625 init_MUTEX_LOCKED(&host->probe_sem); 1625 init_completion(&host->probe_comp);
1626 1626
1627 for (i = 0; i < ARRAY_SIZE(host->req); i++) 1627 for (i = 0; i < ARRAY_SIZE(host->req); i++)
1628 host->req[i].tag = i; 1628 host->req[i].tag = i;
@@ -1691,8 +1691,8 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1691 if (rc) 1691 if (rc)
1692 goto err_out_free_irq; 1692 goto err_out_free_irq;
1693 1693
1694 DPRINTK("waiting for probe_sem\n"); 1694 DPRINTK("waiting for probe_comp\n");
1695 down(&host->probe_sem); 1695 wait_for_completion(&host->probe_comp);
1696 1696
1697 printk(KERN_INFO "%s: pci %s, ports %d, io %lx, irq %u, major %d\n", 1697 printk(KERN_INFO "%s: pci %s, ports %d, io %lx, irq %u, major %d\n",
1698 host->name, pci_name(pdev), (int) CARM_MAX_PORTS, 1698 host->name, pci_name(pdev), (int) CARM_MAX_PORTS,