[PATCH] sem2mutex: fs/seq_file.c
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
7cf34c761d
commit
0ac1759abc
2 changed files with 7 additions and 7 deletions
|
@ -37,7 +37,7 @@ int seq_open(struct file *file, struct seq_operations *op)
|
||||||
file->private_data = p;
|
file->private_data = p;
|
||||||
}
|
}
|
||||||
memset(p, 0, sizeof(*p));
|
memset(p, 0, sizeof(*p));
|
||||||
sema_init(&p->sem, 1);
|
mutex_init(&p->lock);
|
||||||
p->op = op;
|
p->op = op;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -71,7 +71,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
|
||||||
void *p;
|
void *p;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
down(&m->sem);
|
mutex_lock(&m->lock);
|
||||||
/*
|
/*
|
||||||
* seq_file->op->..m_start/m_stop/m_next may do special actions
|
* seq_file->op->..m_start/m_stop/m_next may do special actions
|
||||||
* or optimisations based on the file->f_version, so we want to
|
* or optimisations based on the file->f_version, so we want to
|
||||||
|
@ -164,7 +164,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
|
||||||
else
|
else
|
||||||
*ppos += copied;
|
*ppos += copied;
|
||||||
file->f_version = m->version;
|
file->f_version = m->version;
|
||||||
up(&m->sem);
|
mutex_unlock(&m->lock);
|
||||||
return copied;
|
return copied;
|
||||||
Enomem:
|
Enomem:
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
|
@ -237,7 +237,7 @@ loff_t seq_lseek(struct file *file, loff_t offset, int origin)
|
||||||
struct seq_file *m = (struct seq_file *)file->private_data;
|
struct seq_file *m = (struct seq_file *)file->private_data;
|
||||||
long long retval = -EINVAL;
|
long long retval = -EINVAL;
|
||||||
|
|
||||||
down(&m->sem);
|
mutex_lock(&m->lock);
|
||||||
m->version = file->f_version;
|
m->version = file->f_version;
|
||||||
switch (origin) {
|
switch (origin) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -260,7 +260,7 @@ loff_t seq_lseek(struct file *file, loff_t offset, int origin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
up(&m->sem);
|
mutex_unlock(&m->lock);
|
||||||
file->f_version = m->version;
|
file->f_version = m->version;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
#include <asm/semaphore.h>
|
#include <linux/mutex.h>
|
||||||
|
|
||||||
struct seq_operations;
|
struct seq_operations;
|
||||||
struct file;
|
struct file;
|
||||||
|
@ -19,7 +19,7 @@ struct seq_file {
|
||||||
size_t count;
|
size_t count;
|
||||||
loff_t index;
|
loff_t index;
|
||||||
loff_t version;
|
loff_t version;
|
||||||
struct semaphore sem;
|
struct mutex lock;
|
||||||
struct seq_operations *op;
|
struct seq_operations *op;
|
||||||
void *private;
|
void *private;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue