Commit 8e3f9045 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds
Browse files

[PATCH] sem2mutex: NCPFS



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 avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 97461518
......@@ -46,7 +46,7 @@ int ncp_make_open(struct inode *inode, int right)
NCP_FINFO(inode)->volNumber,
NCP_FINFO(inode)->dirEntNum);
error = -EACCES;
down(&NCP_FINFO(inode)->open_sem);
mutex_lock(&NCP_FINFO(inode)->open_mutex);
if (!atomic_read(&NCP_FINFO(inode)->opened)) {
struct ncp_entry_info finfo;
int result;
......@@ -93,7 +93,7 @@ int ncp_make_open(struct inode *inode, int right)
}
out_unlock:
up(&NCP_FINFO(inode)->open_sem);
mutex_unlock(&NCP_FINFO(inode)->open_mutex);
out:
return error;
}
......
......@@ -63,7 +63,7 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
SLAB_CTOR_CONSTRUCTOR) {
init_MUTEX(&ei->open_sem);
mutex_init(&ei->open_mutex);
inode_init_once(&ei->vfs_inode);
}
}
......@@ -520,7 +520,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
}
/* server->lock = 0; */
init_MUTEX(&server->sem);
mutex_init(&server->mutex);
server->packet = NULL;
/* server->buffer_size = 0; */
/* server->conn_status = 0; */
......@@ -557,7 +557,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
server->dentry_ttl = 0; /* no caching */
INIT_LIST_HEAD(&server->tx.requests);
init_MUTEX(&server->rcv.creq_sem);
mutex_init(&server->rcv.creq_mutex);
server->tx.creq = NULL;
server->rcv.creq = NULL;
server->data_ready = sock->sk->sk_data_ready;
......
......@@ -291,7 +291,7 @@ ncp_make_closed(struct inode *inode)
int err;
err = 0;
down(&NCP_FINFO(inode)->open_sem);
mutex_lock(&NCP_FINFO(inode)->open_mutex);
if (atomic_read(&NCP_FINFO(inode)->opened) == 1) {
atomic_set(&NCP_FINFO(inode)->opened, 0);
err = ncp_close_file(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle);
......@@ -301,7 +301,7 @@ ncp_make_closed(struct inode *inode)
NCP_FINFO(inode)->volNumber,
NCP_FINFO(inode)->dirEntNum, err);
}
up(&NCP_FINFO(inode)->open_sem);
mutex_unlock(&NCP_FINFO(inode)->open_mutex);
return err;
}
......
......@@ -171,9 +171,9 @@ static inline void __ncp_abort_request(struct ncp_server *server, struct ncp_req
static inline void ncp_abort_request(struct ncp_server *server, struct ncp_request_reply *req, int err)
{
down(&server->rcv.creq_sem);
mutex_lock(&server->rcv.creq_mutex);
__ncp_abort_request(server, req, err);
up(&server->rcv.creq_sem);
mutex_unlock(&server->rcv.creq_mutex);
}
static inline void __ncptcp_abort(struct ncp_server *server)
......@@ -303,20 +303,20 @@ static inline void __ncp_start_request(struct ncp_server *server, struct ncp_req
static int ncp_add_request(struct ncp_server *server, struct ncp_request_reply *req)
{
down(&server->rcv.creq_sem);
mutex_lock(&server->rcv.creq_mutex);
if (!ncp_conn_valid(server)) {
up(&server->rcv.creq_sem);
mutex_unlock(&server->rcv.creq_mutex);
printk(KERN_ERR "ncpfs: tcp: Server died\n");
return -EIO;
}
if (server->tx.creq || server->rcv.creq) {
req->status = RQ_QUEUED;
list_add_tail(&req->req, &server->tx.requests);
up(&server->rcv.creq_sem);
mutex_unlock(&server->rcv.creq_mutex);
return 0;
}
__ncp_start_request(server, req);
up(&server->rcv.creq_sem);
mutex_unlock(&server->rcv.creq_mutex);
return 0;
}
......@@ -400,7 +400,7 @@ void ncpdgram_rcv_proc(void *s)
info_server(server, 0, server->unexpected_packet.data, result);
continue;
}
down(&server->rcv.creq_sem);
mutex_lock(&server->rcv.creq_mutex);
req = server->rcv.creq;
if (req && (req->tx_type == NCP_ALLOC_SLOT_REQUEST || (server->sequence == reply.sequence &&
server->connection == get_conn_number(&reply)))) {
......@@ -430,11 +430,11 @@ void ncpdgram_rcv_proc(void *s)
server->rcv.creq = NULL;
ncp_finish_request(req, result);
__ncp_next_request(server);
up(&server->rcv.creq_sem);
mutex_unlock(&server->rcv.creq_mutex);
continue;
}
}
up(&server->rcv.creq_sem);
mutex_unlock(&server->rcv.creq_mutex);
}
drop:;
_recv(sock, &reply, sizeof(reply), MSG_DONTWAIT);
......@@ -472,9 +472,9 @@ static void __ncpdgram_timeout_proc(struct ncp_server *server)
void ncpdgram_timeout_proc(void *s)
{
struct ncp_server *server = s;
down(&server->rcv.creq_sem);
mutex_lock(&server->rcv.creq_mutex);
__ncpdgram_timeout_proc(server);
up(&server->rcv.creq_sem);
mutex_unlock(&server->rcv.creq_mutex);
}
static inline void ncp_init_req(struct ncp_request_reply* req)
......@@ -657,18 +657,18 @@ void ncp_tcp_rcv_proc(void *s)
{
struct ncp_server *server = s;
down(&server->rcv.creq_sem);
mutex_lock(&server->rcv.creq_mutex);
__ncptcp_rcv_proc(server);
up(&server->rcv.creq_sem);
mutex_unlock(&server->rcv.creq_mutex);
}
void ncp_tcp_tx_proc(void *s)
{
struct ncp_server *server = s;
down(&server->rcv.creq_sem);
mutex_lock(&server->rcv.creq_mutex);
__ncptcp_try_send(server);
up(&server->rcv.creq_sem);
mutex_unlock(&server->rcv.creq_mutex);
}
static int do_ncp_rpc_call(struct ncp_server *server, int size,
......@@ -833,7 +833,7 @@ int ncp_disconnect(struct ncp_server *server)
void ncp_lock_server(struct ncp_server *server)
{
down(&server->sem);
mutex_lock(&server->mutex);
if (server->lock)
printk(KERN_WARNING "ncp_lock_server: was locked!\n");
server->lock = 1;
......@@ -846,5 +846,5 @@ void ncp_unlock_server(struct ncp_server *server)
return;
}
server->lock = 0;
up(&server->sem);
mutex_unlock(&server->mutex);
}
......@@ -19,7 +19,7 @@ struct ncp_inode_info {
__le32 DosDirNum;
__u8 volNumber;
__le32 nwattr;
struct semaphore open_sem;
struct mutex open_mutex;
atomic_t opened;
int access;
int flags;
......
......@@ -11,6 +11,7 @@
#include <linux/types.h>
#include <linux/ncp_mount.h>
#include <linux/net.h>
#include <linux/mutex.h>
#ifdef __KERNEL__
......@@ -51,7 +52,7 @@ struct ncp_server {
receive replies */
int lock; /* To prevent mismatch in protocols. */
struct semaphore sem;
struct mutex mutex;
int current_size; /* for packet preparation */
int has_subfunction;
......@@ -96,7 +97,7 @@ struct ncp_server {
struct {
struct work_struct tq; /* STREAM/DGRAM: data/error ready */
struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */
struct semaphore creq_sem; /* DGRAM only: lock accesses to rcv.creq */
struct mutex creq_mutex; /* DGRAM only: lock accesses to rcv.creq */
unsigned int state; /* STREAM only: receiver state */
struct {
......
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