Skip to content

Commit

Permalink
[PATCH] sem2mutex: NCPFS
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Ingo Molnar authored and Linus Torvalds committed Mar 23, 2006
1 parent 9746151 commit 8e3f904
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions fs/ncpfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions fs/ncpfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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; */
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions fs/ncpfs/ncplib_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down
34 changes: 17 additions & 17 deletions fs/ncpfs/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)))) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -846,5 +846,5 @@ void ncp_unlock_server(struct ncp_server *server)
return;
}
server->lock = 0;
up(&server->sem);
mutex_unlock(&server->mutex);
}
2 changes: 1 addition & 1 deletion include/linux/ncp_fs_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions include/linux/ncp_fs_sb.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <linux/types.h>
#include <linux/ncp_mount.h>
#include <linux/net.h>
#include <linux/mutex.h>

#ifdef __KERNEL__

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8e3f904

Please sign in to comment.