* [PATCH 1/4] media: video: usbvision: remove ctrlUrbLock
[not found] <20071208025608.631609481@mvista.com>
@ 2007-12-07 8:00 ` Daniel Walker
2007-12-07 8:00 ` [PATCH 2/4] docs: kernel-locking: Convert semaphore references Daniel Walker
` (2 subsequent siblings)
3 siblings, 0 replies; 4+ messages in thread
From: Daniel Walker @ 2007-12-07 8:00 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, mingo, linux, jonathan, matthias.kaehlcke,
kjwinchester
[-- Attachment #1: usbvision-video-remove-CtrlUrbLock.patch --]
[-- Type: text/plain, Size: 2081 bytes --]
The ctrlUrbLock has all it's users commented out, and so it's unused.
This patch removes it.
Signed-off-by: Daniel Walker <dwalker@mvista.com>
---
drivers/media/video/usbvision/usbvision-core.c | 3 ---
drivers/media/video/usbvision/usbvision-video.c | 1 -
drivers/media/video/usbvision/usbvision.h | 1 -
3 files changed, 5 deletions(-)
Index: linux-2.6.23/drivers/media/video/usbvision/usbvision-core.c
===================================================================
--- linux-2.6.23.orig/drivers/media/video/usbvision/usbvision-core.c
+++ linux-2.6.23/drivers/media/video/usbvision/usbvision-core.c
@@ -1561,13 +1561,10 @@ static int usbvision_write_reg_irq(struc
if (len > 8) {
return -EFAULT;
}
-// down(&usbvision->ctrlUrbLock);
if (usbvision->ctrlUrbBusy) {
-// up(&usbvision->ctrlUrbLock);
return -EBUSY;
}
usbvision->ctrlUrbBusy = 1;
-// up(&usbvision->ctrlUrbLock);
usbvision->ctrlUrbSetup.bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT;
usbvision->ctrlUrbSetup.bRequest = USBVISION_OP_CODE;
Index: linux-2.6.23/drivers/media/video/usbvision/usbvision-video.c
===================================================================
--- linux-2.6.23.orig/drivers/media/video/usbvision/usbvision-video.c
+++ linux-2.6.23/drivers/media/video/usbvision/usbvision-video.c
@@ -1650,7 +1650,6 @@ static struct usb_usbvision *usbvision_a
goto err_exit;
}
init_waitqueue_head(&usbvision->ctrlUrb_wq);
- init_MUTEX(&usbvision->ctrlUrbLock); /* to 1 == available */
usbvision_init_powerOffTimer(usbvision);
Index: linux-2.6.23/drivers/media/video/usbvision/usbvision.h
===================================================================
--- linux-2.6.23.orig/drivers/media/video/usbvision/usbvision.h
+++ linux-2.6.23/drivers/media/video/usbvision/usbvision.h
@@ -374,7 +374,6 @@ struct usb_usbvision {
int ctrlUrbBusy;
struct usb_ctrlrequest ctrlUrbSetup;
wait_queue_head_t ctrlUrb_wq; // Processes waiting
- struct semaphore ctrlUrbLock;
/* configuration part */
int have_tuner;
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/4] docs: kernel-locking: Convert semaphore references
[not found] <20071208025608.631609481@mvista.com>
2007-12-07 8:00 ` [PATCH 1/4] media: video: usbvision: remove ctrlUrbLock Daniel Walker
@ 2007-12-07 8:00 ` Daniel Walker
2007-12-07 8:00 ` [PATCH 3/4] mcheck mce_64: mce_read_sem to mutex Daniel Walker
2007-12-07 8:00 ` [PATCH 4/4] md: dm driver: suspend_lock semaphore " Daniel Walker
3 siblings, 0 replies; 4+ messages in thread
From: Daniel Walker @ 2007-12-07 8:00 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, mingo, linux, jonathan, matthias.kaehlcke,
kjwinchester
[-- Attachment #1: doc-kernel-locking-convert-semaphore-reference.patch --]
[-- Type: text/plain, Size: 4129 bytes --]
I converted some of the document to reflect mutex usage instead of
semaphore usage. Since we shouldin't be promoting semaphore usage when
it's on it's way out..
Signed-Off-By: Daniel Walker <dwalker@mvista.com>
---
Documentation/DocBook/kernel-locking.tmpl | 32 +++++++++++++++---------------
1 file changed, 16 insertions(+), 16 deletions(-)
Index: linux-2.6.23/Documentation/DocBook/kernel-locking.tmpl
===================================================================
--- linux-2.6.23.orig/Documentation/DocBook/kernel-locking.tmpl
+++ linux-2.6.23/Documentation/DocBook/kernel-locking.tmpl
@@ -717,7 +717,7 @@ used, and when it gets full, throws out
<para>
For our first example, we assume that all operations are in user
context (ie. from system calls), so we can sleep. This means we can
-use a semaphore to protect the cache and all the objects within
+use a mutex to protect the cache and all the objects within
it. Here's the code:
</para>
@@ -725,7 +725,7 @@ it. Here's the code:
#include <linux/list.h>
#include <linux/slab.h>
#include <linux/string.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#include <asm/errno.h>
struct object
@@ -737,7 +737,7 @@ struct object
};
/* Protects the cache, cache_num, and the objects within it */
-static DECLARE_MUTEX(cache_lock);
+static DEFINE_MUTEX(cache_lock);
static LIST_HEAD(cache);
static unsigned int cache_num = 0;
#define MAX_CACHE_SIZE 10
@@ -789,17 +789,17 @@ int cache_add(int id, const char *name)
obj->id = id;
obj->popularity = 0;
- down(&cache_lock);
+ mutex_lock(&cache_lock);
__cache_add(obj);
- up(&cache_lock);
+ mutex_unlock(&cache_lock);
return 0;
}
void cache_delete(int id)
{
- down(&cache_lock);
+ mutex_lock(&cache_lock);
__cache_delete(__cache_find(id));
- up(&cache_lock);
+ mutex_unlock(&cache_lock);
}
int cache_find(int id, char *name)
@@ -807,13 +807,13 @@ int cache_find(int id, char *name)
struct object *obj;
int ret = -ENOENT;
- down(&cache_lock);
+ mutex_lock(&cache_lock);
obj = __cache_find(id);
if (obj) {
ret = 0;
strcpy(name, obj->name);
}
- up(&cache_lock);
+ mutex_unlock(&cache_lock);
return ret;
}
</programlisting>
@@ -853,7 +853,7 @@ The change is shown below, in standard p
int popularity;
};
--static DECLARE_MUTEX(cache_lock);
+-static DEFINE_MUTEX(cache_lock);
+static spinlock_t cache_lock = SPIN_LOCK_UNLOCKED;
static LIST_HEAD(cache);
static unsigned int cache_num = 0;
@@ -870,22 +870,22 @@ The change is shown below, in standard p
obj->id = id;
obj->popularity = 0;
-- down(&cache_lock);
+- mutex_lock(&cache_lock);
+ spin_lock_irqsave(&cache_lock, flags);
__cache_add(obj);
-- up(&cache_lock);
+- mutex_unlock(&cache_lock);
+ spin_unlock_irqrestore(&cache_lock, flags);
return 0;
}
void cache_delete(int id)
{
-- down(&cache_lock);
+- mutex_lock(&cache_lock);
+ unsigned long flags;
+
+ spin_lock_irqsave(&cache_lock, flags);
__cache_delete(__cache_find(id));
-- up(&cache_lock);
+- mutex_unlock(&cache_lock);
+ spin_unlock_irqrestore(&cache_lock, flags);
}
@@ -895,14 +895,14 @@ The change is shown below, in standard p
int ret = -ENOENT;
+ unsigned long flags;
-- down(&cache_lock);
+- mutex_lock(&cache_lock);
+ spin_lock_irqsave(&cache_lock, flags);
obj = __cache_find(id);
if (obj) {
ret = 0;
strcpy(name, obj->name);
}
-- up(&cache_lock);
+- mutex_unlock(&cache_lock);
+ spin_unlock_irqrestore(&cache_lock, flags);
return ret;
}
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/4] mcheck mce_64: mce_read_sem to mutex
[not found] <20071208025608.631609481@mvista.com>
2007-12-07 8:00 ` [PATCH 1/4] media: video: usbvision: remove ctrlUrbLock Daniel Walker
2007-12-07 8:00 ` [PATCH 2/4] docs: kernel-locking: Convert semaphore references Daniel Walker
@ 2007-12-07 8:00 ` Daniel Walker
2007-12-07 8:00 ` [PATCH 4/4] md: dm driver: suspend_lock semaphore " Daniel Walker
3 siblings, 0 replies; 4+ messages in thread
From: Daniel Walker @ 2007-12-07 8:00 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, mingo, linux, jonathan, matthias.kaehlcke,
kjwinchester
[-- Attachment #1: mcheck_semaphore-to-mutex.patch --]
[-- Type: text/plain, Size: 1336 bytes --]
Converted to a mutex, and changed the name to mce_read_mutex.
Signed-off-by: Daniel Walker <dwalker@mvista.com>
---
arch/x86/kernel/cpu/mcheck/mce_64.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Index: linux-2.6.23/arch/x86/kernel/cpu/mcheck/mce_64.c
===================================================================
--- linux-2.6.23.orig/arch/x86/kernel/cpu/mcheck/mce_64.c
+++ linux-2.6.23/arch/x86/kernel/cpu/mcheck/mce_64.c
@@ -564,7 +564,7 @@ static ssize_t mce_read(struct file *fil
loff_t *off)
{
unsigned long *cpu_tsc;
- static DECLARE_MUTEX(mce_read_sem);
+ static DEFINE_MUTEX(mce_read_mutex);
unsigned next;
char __user *buf = ubuf;
int i, err;
@@ -573,12 +573,12 @@ static ssize_t mce_read(struct file *fil
if (!cpu_tsc)
return -ENOMEM;
- down(&mce_read_sem);
+ mutex_lock(&mce_read_mutex);
next = rcu_dereference(mcelog.next);
/* Only supports full reads right now */
if (*off != 0 || usize < MCE_LOG_LEN*sizeof(struct mce)) {
- up(&mce_read_sem);
+ mutex_unlock(&mce_read_mutex);
kfree(cpu_tsc);
return -EINVAL;
}
@@ -621,7 +621,7 @@ static ssize_t mce_read(struct file *fil
memset(&mcelog.entry[i], 0, sizeof(struct mce));
}
}
- up(&mce_read_sem);
+ mutex_unlock(&mce_read_mutex);
kfree(cpu_tsc);
return err ? -EFAULT : buf - ubuf;
}
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 4/4] md: dm driver: suspend_lock semaphore to mutex
[not found] <20071208025608.631609481@mvista.com>
` (2 preceding siblings ...)
2007-12-07 8:00 ` [PATCH 3/4] mcheck mce_64: mce_read_sem to mutex Daniel Walker
@ 2007-12-07 8:00 ` Daniel Walker
3 siblings, 0 replies; 4+ messages in thread
From: Daniel Walker @ 2007-12-07 8:00 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, mingo, linux, jonathan, matthias.kaehlcke,
kjwinchester
[-- Attachment #1: md-suspend_lock-semaphore-to-mutex.patch --]
[-- Type: text/plain, Size: 2063 bytes --]
Signed-off-by: Daniel Walker <dwalker@mvista.com>
---
drivers/md/dm.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
Index: linux-2.6.23/drivers/md/dm.c
===================================================================
--- linux-2.6.23.orig/drivers/md/dm.c
+++ linux-2.6.23/drivers/md/dm.c
@@ -73,7 +73,7 @@ union map_info *dm_get_mapinfo(struct bi
struct mapped_device {
struct rw_semaphore io_lock;
- struct semaphore suspend_lock;
+ struct mutex suspend_lock;
spinlock_t pushback_lock;
rwlock_t map_lock;
atomic_t holders;
@@ -982,7 +982,7 @@ static struct mapped_device *alloc_dev(i
memset(md, 0, sizeof(*md));
init_rwsem(&md->io_lock);
- init_MUTEX(&md->suspend_lock);
+ mutex_init(&md->suspend_lock);
spin_lock_init(&md->pushback_lock);
rwlock_init(&md->map_lock);
atomic_set(&md->holders, 1);
@@ -1270,7 +1270,7 @@ int dm_swap_table(struct mapped_device *
{
int r = -EINVAL;
- down(&md->suspend_lock);
+ mutex_lock(&md->suspend_lock);
/* device must be suspended */
if (!dm_suspended(md))
@@ -1285,7 +1285,7 @@ int dm_swap_table(struct mapped_device *
r = __bind(md, table);
out:
- up(&md->suspend_lock);
+ mutex_unlock(&md->suspend_lock);
return r;
}
@@ -1341,7 +1341,7 @@ int dm_suspend(struct mapped_device *md,
int do_lockfs = suspend_flags & DM_SUSPEND_LOCKFS_FLAG ? 1 : 0;
int noflush = suspend_flags & DM_SUSPEND_NOFLUSH_FLAG ? 1 : 0;
- down(&md->suspend_lock);
+ mutex_lock(&md->suspend_lock);
if (dm_suspended(md))
goto out_unlock;
@@ -1462,7 +1462,7 @@ out:
dm_table_put(map);
out_unlock:
- up(&md->suspend_lock);
+ mutex_unlock(&md->suspend_lock);
return r;
}
@@ -1472,7 +1472,7 @@ int dm_resume(struct mapped_device *md)
struct bio *def;
struct dm_table *map = NULL;
- down(&md->suspend_lock);
+ mutex_lock(&md->suspend_lock);
if (!dm_suspended(md))
goto out;
@@ -1508,7 +1508,7 @@ int dm_resume(struct mapped_device *md)
out:
dm_table_put(map);
- up(&md->suspend_lock);
+ mutex_unlock(&md->suspend_lock);
return r;
}
--
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-12-08 3:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20071208025608.631609481@mvista.com>
2007-12-07 8:00 ` [PATCH 1/4] media: video: usbvision: remove ctrlUrbLock Daniel Walker
2007-12-07 8:00 ` [PATCH 2/4] docs: kernel-locking: Convert semaphore references Daniel Walker
2007-12-07 8:00 ` [PATCH 3/4] mcheck mce_64: mce_read_sem to mutex Daniel Walker
2007-12-07 8:00 ` [PATCH 4/4] md: dm driver: suspend_lock semaphore " Daniel Walker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox