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

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