* [PATCH] sysfs_buffer: use mutex
@ 2007-06-22 9:14 Johannes Berg
2007-06-25 21:24 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Johannes Berg @ 2007-06-22 9:14 UTC (permalink / raw)
To: Greg KH; +Cc: Linux Kernel list
I don't see any reason why this is a semaphore, convert.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
fs/sysfs/file.c | 13 +++++++------
fs/sysfs/inode.c | 4 ++--
fs/sysfs/sysfs.h | 2 +-
3 files changed, 10 insertions(+), 9 deletions(-)
--- wireless-dev.orig/fs/sysfs/file.c 2007-06-13 23:33:29.878817885 +0200
+++ wireless-dev/fs/sysfs/file.c 2007-06-13 23:34:22.908817885 +0200
@@ -8,8 +8,8 @@
#include <linux/namei.h>
#include <linux/poll.h>
#include <linux/list.h>
+#include <linux/mutex.h>
#include <asm/uaccess.h>
-#include <asm/semaphore.h>
#include "sysfs.h"
@@ -136,7 +136,7 @@ sysfs_read_file(struct file *file, char
struct sysfs_buffer * buffer = file->private_data;
ssize_t retval = 0;
- down(&buffer->sem);
+ mutex_lock(&buffer->mutex);
if (buffer->needs_read_fill) {
if (buffer->orphaned)
retval = -ENODEV;
@@ -150,7 +150,7 @@ sysfs_read_file(struct file *file, char
retval = simple_read_from_buffer(buf, count, ppos, buffer->page,
buffer->count);
out:
- up(&buffer->sem);
+ mutex_unlock(&buffer->mutex);
return retval;
}
@@ -230,7 +230,7 @@ sysfs_write_file(struct file *file, cons
struct sysfs_buffer * buffer = file->private_data;
ssize_t len;
- down(&buffer->sem);
+ mutex_lock(&buffer->mutex);
if (buffer->orphaned) {
len = -ENODEV;
goto out;
@@ -241,7 +241,7 @@ sysfs_write_file(struct file *file, cons
if (len > 0)
*ppos += len;
out:
- up(&buffer->sem);
+ mutex_unlock(&buffer->mutex);
return len;
}
@@ -317,7 +317,7 @@ static int sysfs_open_file(struct inode
buffer = kzalloc(sizeof(struct sysfs_buffer), GFP_KERNEL);
if (buffer) {
INIT_LIST_HEAD(&buffer->associates);
- init_MUTEX(&buffer->sem);
+ mutex_init(&buffer->mutex);
buffer->needs_read_fill = 1;
buffer->ops = ops;
add_to_collection(buffer, inode);
@@ -354,6 +354,7 @@ static int sysfs_release(struct inode *
if (buffer) {
if (buffer->page)
free_page((unsigned long)buffer->page);
+ mutex_destroy(&buffer->mutex);
kfree(buffer);
}
return 0;
--- wireless-dev.orig/fs/sysfs/sysfs.h 2007-06-13 23:34:32.868817885 +0200
+++ wireless-dev/fs/sysfs/sysfs.h 2007-06-13 23:34:58.338817885 +0200
@@ -51,7 +51,7 @@ struct sysfs_buffer {
loff_t pos;
char * page;
struct sysfs_ops * ops;
- struct semaphore sem;
+ struct mutex mutex;
int orphaned;
int needs_read_fill;
int event;
--- wireless-dev.orig/fs/sysfs/inode.c 2007-06-13 23:35:14.248817885 +0200
+++ wireless-dev/fs/sysfs/inode.c 2007-06-13 23:35:25.788817885 +0200
@@ -230,9 +230,9 @@ static inline void orphan_all_buffers(st
set = node->i_private;
if (set) {
list_for_each_entry(buf, &set->associates, associates) {
- down(&buf->sem);
+ mutex_lock(&buf->mutex);
buf->orphaned = 1;
- up(&buf->sem);
+ mutex_unlock(&buf->mutex);
}
}
mutex_unlock(&node->i_mutex);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] sysfs_buffer: use mutex
2007-06-22 9:14 [PATCH] sysfs_buffer: use mutex Johannes Berg
@ 2007-06-25 21:24 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2007-06-25 21:24 UTC (permalink / raw)
To: Johannes Berg; +Cc: Linux Kernel list
On Fri, Jun 22, 2007 at 11:14:44AM +0200, Johannes Berg wrote:
> I don't see any reason why this is a semaphore, convert.
>
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
There has been a _lot_ of work in this area and this patch doesn't apply
at all to my tree. Can you respin it agains the next -mm release that
comes out?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-06-25 21:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-22 9:14 [PATCH] sysfs_buffer: use mutex Johannes Berg
2007-06-25 21:24 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox