From: Arjan van de Ven Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Arjan van de Ven Signed-off-by: Ingo Molnar Cc: Neil Brown Signed-off-by: Andrew Morton Index: linux-2.6.16-rc5/drivers/md/dm.c =================================================================== --- linux-2.6.16-rc5.orig/drivers/md/dm.c 2006-03-13 11:45:08.000000000 +0000 +++ linux-2.6.16-rc5/drivers/md/dm.c 2006-03-13 11:47:17.000000000 +0000 @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -688,14 +689,14 @@ static int dm_any_congested(void *conges /*----------------------------------------------------------------- * An IDR is used to keep track of allocated minor numbers. *---------------------------------------------------------------*/ -static DECLARE_MUTEX(_minor_lock); +static DEFINE_MUTEX(_minor_lock); static DEFINE_IDR(_minor_idr); static void free_minor(unsigned int minor) { - down(&_minor_lock); + mutex_lock(&_minor_lock); idr_remove(&_minor_idr, minor); - up(&_minor_lock); + mutex_unlock(&_minor_lock); } /* @@ -708,7 +709,7 @@ static int specific_minor(struct mapped_ if (minor >= (1 << MINORBITS)) return -EINVAL; - down(&_minor_lock); + mutex_lock(&_minor_lock); if (idr_find(&_minor_idr, minor)) { r = -EBUSY; @@ -733,7 +734,7 @@ static int specific_minor(struct mapped_ } out: - up(&_minor_lock); + mutex_unlock(&_minor_lock); return r; } @@ -742,7 +743,7 @@ static int next_free_minor(struct mapped int r; unsigned int m; - down(&_minor_lock); + mutex_lock(&_minor_lock); r = idr_pre_get(&_minor_idr, GFP_KERNEL); if (!r) { @@ -764,7 +765,7 @@ static int next_free_minor(struct mapped *minor = m; out: - up(&_minor_lock); + mutex_unlock(&_minor_lock); return r; } @@ -953,13 +954,13 @@ static struct mapped_device *dm_find_md( if (MAJOR(dev) != _major || minor >= (1 << MINORBITS)) return NULL; - down(&_minor_lock); + mutex_lock(&_minor_lock); md = idr_find(&_minor_idr, minor); if (!md || (dm_disk(md)->first_minor != minor)) md = NULL; - up(&_minor_lock); + mutex_unlock(&_minor_lock); return md; } Index: linux-2.6.16-rc5/drivers/md/dm-table.c =================================================================== --- linux-2.6.16-rc5.orig/drivers/md/dm-table.c 2006-03-13 11:45:08.000000000 +0000 +++ linux-2.6.16-rc5/drivers/md/dm-table.c 2006-03-13 11:47:17.000000000 +0000 @@ -14,6 +14,7 @@ #include #include #include +#include #include #define MAX_DEPTH 16 @@ -765,14 +766,14 @@ int dm_table_complete(struct dm_table *t return r; } -static DECLARE_MUTEX(_event_lock); +static DEFINE_MUTEX(_event_lock); void dm_table_event_callback(struct dm_table *t, void (*fn)(void *), void *context) { - down(&_event_lock); + mutex_lock(&_event_lock); t->event_fn = fn; t->event_context = context; - up(&_event_lock); + mutex_unlock(&_event_lock); } void dm_table_event(struct dm_table *t) @@ -783,10 +784,10 @@ void dm_table_event(struct dm_table *t) */ BUG_ON(in_interrupt()); - down(&_event_lock); + mutex_lock(&_event_lock); if (t->event_fn) t->event_fn(t->event_context); - up(&_event_lock); + mutex_unlock(&_event_lock); } sector_t dm_table_get_size(struct dm_table *t) Index: linux-2.6.16-rc5/drivers/md/kcopyd.c =================================================================== --- linux-2.6.16-rc5.orig/drivers/md/kcopyd.c 2006-03-12 21:58:46.000000000 +0000 +++ linux-2.6.16-rc5/drivers/md/kcopyd.c 2006-03-13 11:47:17.000000000 +0000 @@ -22,6 +22,7 @@ #include #include #include +#include #include "kcopyd.h" @@ -582,21 +583,21 @@ int kcopyd_cancel(struct kcopyd_job *job /*----------------------------------------------------------------- * Unit setup *---------------------------------------------------------------*/ -static DECLARE_MUTEX(_client_lock); +static DEFINE_MUTEX(_client_lock); static LIST_HEAD(_clients); static void client_add(struct kcopyd_client *kc) { - down(&_client_lock); + mutex_lock(&_client_lock); list_add(&kc->list, &_clients); - up(&_client_lock); + mutex_unlock(&_client_lock); } static void client_del(struct kcopyd_client *kc) { - down(&_client_lock); + mutex_lock(&_client_lock); list_del(&kc->list); - up(&_client_lock); + mutex_unlock(&_client_lock); } static DEFINE_MUTEX(kcopyd_init_lock); Index: linux-2.6.16-rc5/drivers/md/md.c =================================================================== --- linux-2.6.16-rc5.orig/drivers/md/md.c 2006-02-27 05:09:35.000000000 +0000 +++ linux-2.6.16-rc5/drivers/md/md.c 2006-03-13 11:47:17.000000000 +0000 @@ -43,6 +43,7 @@ #include /* for invalidate_bdev */ #include #include +#include #include @@ -2377,7 +2378,7 @@ int mdp_major = 0; static struct kobject *md_probe(dev_t dev, int *part, void *data) { - static DECLARE_MUTEX(disks_sem); + static DEFINE_MUTEX(disks_mutex); mddev_t *mddev = mddev_find(dev); struct gendisk *disk; int partitioned = (MAJOR(dev) != MD_MAJOR); @@ -2387,15 +2388,15 @@ static struct kobject *md_probe(dev_t de if (!mddev) return NULL; - down(&disks_sem); + mutex_lock(&disks_mutex); if (mddev->gendisk) { - up(&disks_sem); + mutex_unlock(&disks_mutex); mddev_put(mddev); return NULL; } disk = alloc_disk(1 << shift); if (!disk) { - up(&disks_sem); + mutex_unlock(&disks_mutex); mddev_put(mddev); return NULL; } @@ -2413,7 +2414,7 @@ static struct kobject *md_probe(dev_t de disk->queue = mddev->queue; add_disk(disk); mddev->gendisk = disk; - up(&disks_sem); + mutex_unlock(&disks_mutex); mddev->kobj.parent = &disk->kobj; mddev->kobj.k_name = NULL; snprintf(mddev->kobj.name, KOBJ_NAME_LEN, "%s", "md");