Commit 48c9c27b authored by Arjan van de Ven's avatar Arjan van de Ven Committed by Linus Torvalds

[PATCH] sem2mutex: drivers/md

Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.
Signed-off-by: default avatarArjan van de Ven <arjan@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Cc: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2f889129
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/mutex.h>
#include <asm/atomic.h> #include <asm/atomic.h>
#define MAX_DEPTH 16 #define MAX_DEPTH 16
...@@ -770,14 +771,14 @@ int dm_table_complete(struct dm_table *t) ...@@ -770,14 +771,14 @@ int dm_table_complete(struct dm_table *t)
return r; return r;
} }
static DECLARE_MUTEX(_event_lock); static DEFINE_MUTEX(_event_lock);
void dm_table_event_callback(struct dm_table *t, void dm_table_event_callback(struct dm_table *t,
void (*fn)(void *), void *context) void (*fn)(void *), void *context)
{ {
down(&_event_lock); mutex_lock(&_event_lock);
t->event_fn = fn; t->event_fn = fn;
t->event_context = context; t->event_context = context;
up(&_event_lock); mutex_unlock(&_event_lock);
} }
void dm_table_event(struct dm_table *t) void dm_table_event(struct dm_table *t)
...@@ -788,10 +789,10 @@ void dm_table_event(struct dm_table *t) ...@@ -788,10 +789,10 @@ void dm_table_event(struct dm_table *t)
*/ */
BUG_ON(in_interrupt()); BUG_ON(in_interrupt());
down(&_event_lock); mutex_lock(&_event_lock);
if (t->event_fn) if (t->event_fn)
t->event_fn(t->event_context); t->event_fn(t->event_context);
up(&_event_lock); mutex_unlock(&_event_lock);
} }
sector_t dm_table_get_size(struct dm_table *t) sector_t dm_table_get_size(struct dm_table *t)
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/blkpg.h> #include <linux/blkpg.h>
#include <linux/bio.h> #include <linux/bio.h>
...@@ -743,14 +744,14 @@ static int dm_any_congested(void *congested_data, int bdi_bits) ...@@ -743,14 +744,14 @@ static int dm_any_congested(void *congested_data, int bdi_bits)
/*----------------------------------------------------------------- /*-----------------------------------------------------------------
* An IDR is used to keep track of allocated minor numbers. * 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 DEFINE_IDR(_minor_idr);
static void free_minor(unsigned int minor) static void free_minor(unsigned int minor)
{ {
down(&_minor_lock); mutex_lock(&_minor_lock);
idr_remove(&_minor_idr, minor); idr_remove(&_minor_idr, minor);
up(&_minor_lock); mutex_unlock(&_minor_lock);
} }
/* /*
...@@ -763,7 +764,7 @@ static int specific_minor(struct mapped_device *md, unsigned int minor) ...@@ -763,7 +764,7 @@ static int specific_minor(struct mapped_device *md, unsigned int minor)
if (minor >= (1 << MINORBITS)) if (minor >= (1 << MINORBITS))
return -EINVAL; return -EINVAL;
down(&_minor_lock); mutex_lock(&_minor_lock);
if (idr_find(&_minor_idr, minor)) { if (idr_find(&_minor_idr, minor)) {
r = -EBUSY; r = -EBUSY;
...@@ -788,7 +789,7 @@ static int specific_minor(struct mapped_device *md, unsigned int minor) ...@@ -788,7 +789,7 @@ static int specific_minor(struct mapped_device *md, unsigned int minor)
} }
out: out:
up(&_minor_lock); mutex_unlock(&_minor_lock);
return r; return r;
} }
...@@ -797,7 +798,7 @@ static int next_free_minor(struct mapped_device *md, unsigned int *minor) ...@@ -797,7 +798,7 @@ static int next_free_minor(struct mapped_device *md, unsigned int *minor)
int r; int r;
unsigned int m; unsigned int m;
down(&_minor_lock); mutex_lock(&_minor_lock);
r = idr_pre_get(&_minor_idr, GFP_KERNEL); r = idr_pre_get(&_minor_idr, GFP_KERNEL);
if (!r) { if (!r) {
...@@ -819,7 +820,7 @@ static int next_free_minor(struct mapped_device *md, unsigned int *minor) ...@@ -819,7 +820,7 @@ static int next_free_minor(struct mapped_device *md, unsigned int *minor)
*minor = m; *minor = m;
out: out:
up(&_minor_lock); mutex_unlock(&_minor_lock);
return r; return r;
} }
...@@ -1014,13 +1015,13 @@ static struct mapped_device *dm_find_md(dev_t dev) ...@@ -1014,13 +1015,13 @@ static struct mapped_device *dm_find_md(dev_t dev)
if (MAJOR(dev) != _major || minor >= (1 << MINORBITS)) if (MAJOR(dev) != _major || minor >= (1 << MINORBITS))
return NULL; return NULL;
down(&_minor_lock); mutex_lock(&_minor_lock);
md = idr_find(&_minor_idr, minor); md = idr_find(&_minor_idr, minor);
if (!md || (dm_disk(md)->first_minor != minor)) if (!md || (dm_disk(md)->first_minor != minor))
md = NULL; md = NULL;
up(&_minor_lock); mutex_unlock(&_minor_lock);
return md; return md;
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/mutex.h>
#include "kcopyd.h" #include "kcopyd.h"
...@@ -581,21 +582,21 @@ int kcopyd_cancel(struct kcopyd_job *job, int block) ...@@ -581,21 +582,21 @@ int kcopyd_cancel(struct kcopyd_job *job, int block)
/*----------------------------------------------------------------- /*-----------------------------------------------------------------
* Unit setup * Unit setup
*---------------------------------------------------------------*/ *---------------------------------------------------------------*/
static DECLARE_MUTEX(_client_lock); static DEFINE_MUTEX(_client_lock);
static LIST_HEAD(_clients); static LIST_HEAD(_clients);
static void client_add(struct kcopyd_client *kc) static void client_add(struct kcopyd_client *kc)
{ {
down(&_client_lock); mutex_lock(&_client_lock);
list_add(&kc->list, &_clients); list_add(&kc->list, &_clients);
up(&_client_lock); mutex_unlock(&_client_lock);
} }
static void client_del(struct kcopyd_client *kc) static void client_del(struct kcopyd_client *kc)
{ {
down(&_client_lock); mutex_lock(&_client_lock);
list_del(&kc->list); list_del(&kc->list);
up(&_client_lock); mutex_unlock(&_client_lock);
} }
static DEFINE_MUTEX(kcopyd_init_lock); static DEFINE_MUTEX(kcopyd_init_lock);
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <linux/buffer_head.h> /* for invalidate_bdev */ #include <linux/buffer_head.h> /* for invalidate_bdev */
#include <linux/suspend.h> #include <linux/suspend.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/mutex.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -2500,7 +2501,7 @@ int mdp_major = 0; ...@@ -2500,7 +2501,7 @@ int mdp_major = 0;
static struct kobject *md_probe(dev_t dev, int *part, void *data) 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); mddev_t *mddev = mddev_find(dev);
struct gendisk *disk; struct gendisk *disk;
int partitioned = (MAJOR(dev) != MD_MAJOR); int partitioned = (MAJOR(dev) != MD_MAJOR);
...@@ -2510,15 +2511,15 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data) ...@@ -2510,15 +2511,15 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
if (!mddev) if (!mddev)
return NULL; return NULL;
down(&disks_sem); mutex_lock(&disks_mutex);
if (mddev->gendisk) { if (mddev->gendisk) {
up(&disks_sem); mutex_unlock(&disks_mutex);
mddev_put(mddev); mddev_put(mddev);
return NULL; return NULL;
} }
disk = alloc_disk(1 << shift); disk = alloc_disk(1 << shift);
if (!disk) { if (!disk) {
up(&disks_sem); mutex_unlock(&disks_mutex);
mddev_put(mddev); mddev_put(mddev);
return NULL; return NULL;
} }
...@@ -2536,7 +2537,7 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data) ...@@ -2536,7 +2537,7 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
disk->queue = mddev->queue; disk->queue = mddev->queue;
add_disk(disk); add_disk(disk);
mddev->gendisk = disk; mddev->gendisk = disk;
up(&disks_sem); mutex_unlock(&disks_mutex);
mddev->kobj.parent = &disk->kobj; mddev->kobj.parent = &disk->kobj;
mddev->kobj.k_name = NULL; mddev->kobj.k_name = NULL;
snprintf(mddev->kobj.name, KOBJ_NAME_LEN, "%s", "md"); snprintf(mddev->kobj.name, KOBJ_NAME_LEN, "%s", "md");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment