Skip to content

Commit f36d402

Browse files
Aleksey MakarovIngo Molnar
authored andcommitted
[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 <[email protected]> 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 <[email protected]> Signed-off-by: Steven Rostedt <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 3fe0c27 commit f36d402

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

drivers/ide/ide-probe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ static void hwif_release_dev (struct device *dev)
655655
{
656656
ide_hwif_t *hwif = container_of(dev, ide_hwif_t, gendev);
657657

658-
up(&hwif->gendev_rel_sem);
658+
complete(&hwif->gendev_rel_comp);
659659
}
660660

661661
static void hwif_register (ide_hwif_t *hwif)
@@ -1327,7 +1327,7 @@ static void drive_release_dev (struct device *dev)
13271327
drive->queue = NULL;
13281328
spin_unlock_irq(&ide_lock);
13291329

1330-
up(&drive->gendev_rel_sem);
1330+
complete(&drive->gendev_rel_comp);
13311331
}
13321332

13331333
/*

drivers/ide/ide.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index)
222222
hwif->mwdma_mask = 0x80; /* disable all mwdma */
223223
hwif->swdma_mask = 0x80; /* disable all swdma */
224224

225-
sema_init(&hwif->gendev_rel_sem, 0);
225+
init_completion(&hwif->gendev_rel_comp);
226226

227227
default_hwif_iops(hwif);
228228
default_hwif_transport(hwif);
@@ -245,7 +245,7 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index)
245245
drive->is_flash = 0;
246246
drive->vdma = 0;
247247
INIT_LIST_HEAD(&drive->list);
248-
sema_init(&drive->gendev_rel_sem, 0);
248+
init_completion(&drive->gendev_rel_comp);
249249
}
250250
}
251251

@@ -602,7 +602,7 @@ void ide_unregister(unsigned int index)
602602
}
603603
spin_unlock_irq(&ide_lock);
604604
device_unregister(&drive->gendev);
605-
down(&drive->gendev_rel_sem);
605+
wait_for_completion(&drive->gendev_rel_comp);
606606
spin_lock_irq(&ide_lock);
607607
}
608608
hwif->present = 0;
@@ -662,7 +662,7 @@ void ide_unregister(unsigned int index)
662662
/* More messed up locking ... */
663663
spin_unlock_irq(&ide_lock);
664664
device_unregister(&hwif->gendev);
665-
down(&hwif->gendev_rel_sem);
665+
wait_for_completion(&hwif->gendev_rel_comp);
666666

667667
/*
668668
* Remove us from the kernel's knowledge

include/linux/ide.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/bio.h>
1919
#include <linux/device.h>
2020
#include <linux/pci.h>
21+
#include <linux/completion.h>
2122
#include <asm/byteorder.h>
2223
#include <asm/system.h>
2324
#include <asm/io.h>
@@ -638,7 +639,7 @@ typedef struct ide_drive_s {
638639
int crc_count; /* crc counter to reduce drive speed */
639640
struct list_head list;
640641
struct device gendev;
641-
struct semaphore gendev_rel_sem; /* to deal with device release() */
642+
struct completion gendev_rel_comp; /* to deal with device release() */
642643
} ide_drive_t;
643644

644645
#define to_ide_device(dev)container_of(dev, ide_drive_t, gendev)
@@ -794,7 +795,7 @@ typedef struct hwif_s {
794795
unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
795796

796797
struct device gendev;
797-
struct semaphore gendev_rel_sem; /* To deal with device release() */
798+
struct completion gendev_rel_comp; /* To deal with device release() */
798799

799800
void *hwif_data; /* extra hwif data */
800801

0 commit comments

Comments
 (0)