[PATCH] mutex subsystem, semaphore to completion: IDE ->gendev_rel_sem

The patch changes semaphores that are initialized as
locked to complete().

Source: MontaVista Software, Inc.

Modified-by: Steven Rostedt <rostedt@goodmis.org>

The following patch is from Montavista. I modified it slightly.
Semaphores are currently being used where it makes more sense for
completions. This patch corrects that.

Signed-off-by: Aleksey Makarov <amakarov@ru.mvista.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

Aleksey Makarov and committed by
Ingo Molnar
f36d4024 3fe0c277

+9 -8
+2 -2
drivers/ide/ide-probe.c
··· 655 655 { 656 656 ide_hwif_t *hwif = container_of(dev, ide_hwif_t, gendev); 657 657 658 - up(&hwif->gendev_rel_sem); 658 + complete(&hwif->gendev_rel_comp); 659 659 } 660 660 661 661 static void hwif_register (ide_hwif_t *hwif) ··· 1327 1327 drive->queue = NULL; 1328 1328 spin_unlock_irq(&ide_lock); 1329 1329 1330 - up(&drive->gendev_rel_sem); 1330 + complete(&drive->gendev_rel_comp); 1331 1331 } 1332 1332 1333 1333 /*
+4 -4
drivers/ide/ide.c
··· 222 222 hwif->mwdma_mask = 0x80; /* disable all mwdma */ 223 223 hwif->swdma_mask = 0x80; /* disable all swdma */ 224 224 225 - sema_init(&hwif->gendev_rel_sem, 0); 225 + init_completion(&hwif->gendev_rel_comp); 226 226 227 227 default_hwif_iops(hwif); 228 228 default_hwif_transport(hwif); ··· 245 245 drive->is_flash = 0; 246 246 drive->vdma = 0; 247 247 INIT_LIST_HEAD(&drive->list); 248 - sema_init(&drive->gendev_rel_sem, 0); 248 + init_completion(&drive->gendev_rel_comp); 249 249 } 250 250 } 251 251 ··· 602 602 } 603 603 spin_unlock_irq(&ide_lock); 604 604 device_unregister(&drive->gendev); 605 - down(&drive->gendev_rel_sem); 605 + wait_for_completion(&drive->gendev_rel_comp); 606 606 spin_lock_irq(&ide_lock); 607 607 } 608 608 hwif->present = 0; ··· 662 662 /* More messed up locking ... */ 663 663 spin_unlock_irq(&ide_lock); 664 664 device_unregister(&hwif->gendev); 665 - down(&hwif->gendev_rel_sem); 665 + wait_for_completion(&hwif->gendev_rel_comp); 666 666 667 667 /* 668 668 * Remove us from the kernel's knowledge
+3 -2
include/linux/ide.h
··· 18 18 #include <linux/bio.h> 19 19 #include <linux/device.h> 20 20 #include <linux/pci.h> 21 + #include <linux/completion.h> 21 22 #include <asm/byteorder.h> 22 23 #include <asm/system.h> 23 24 #include <asm/io.h> ··· 639 638 int crc_count; /* crc counter to reduce drive speed */ 640 639 struct list_head list; 641 640 struct device gendev; 642 - struct semaphore gendev_rel_sem; /* to deal with device release() */ 641 + struct completion gendev_rel_comp; /* to deal with device release() */ 643 642 } ide_drive_t; 644 643 645 644 #define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) ··· 795 794 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 796 795 797 796 struct device gendev; 798 - struct semaphore gendev_rel_sem; /* To deal with device release() */ 797 + struct completion gendev_rel_comp; /* To deal with device release() */ 799 798 800 799 void *hwif_data; /* extra hwif data */ 801 800