#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/fcntl.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#include <asm/string.h>
#include <asm/atomic.h>
#include <net/sock.h>
struct tipc_sock {
struct sock sk;
struct tipc_port *p;
- struct semaphore sem;
+ struct mutex lock;
};
#define tipc_sk(sk) ((struct tipc_sock*)sk)
tsock->p = port;
port->usr_handle = tsock;
- init_MUTEX(&tsock->sem);
+ mutex_init(&tsock->lock);
dbg("sock_create: %x\n",tsock);
dbg("sock_delete: %x\n",tsock);
if (!tsock)
return 0;
- down(&tsock->sem);
+ mutex_lock(&tsock->lock);
if (!sock->sk) {
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
return 0;
}
atomic_dec(&tipc_queue_size);
}
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
sock_put(sk);
struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr;
int res;
- if (down_interruptible(&tsock->sem))
+ if (mutex_lock_interruptible(&tsock->lock))
return -ERESTARTSYS;
if (unlikely(!uaddr_len)) {
res = tipc_withdraw(tsock->p->ref, -addr->scope,
&addr->addr.nameseq);
exit:
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
return res;
}
struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr;
u32 res;
- if (down_interruptible(&tsock->sem))
+ if (mutex_lock_interruptible(&tsock->lock))
return -ERESTARTSYS;
*uaddr_len = sizeof(*addr);
res = tipc_ownidentity(tsock->p->ref, &addr->addr.id);
addr->addr.name.domain = 0;
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
return res;
}
}
}
- if (down_interruptible(&tsock->sem))
+ if (mutex_lock_interruptible(&tsock->lock))
return -ERESTARTSYS;
if (needs_conn) {
}
if (likely(res != -ELINKCONG)) {
exit:
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
return res;
}
if (m->msg_flags & MSG_DONTWAIT) {
if (unlikely(dest))
return send_msg(iocb, sock, m, total_len);
- if (down_interruptible(&tsock->sem)) {
+ if (mutex_lock_interruptible(&tsock->lock)) {
return -ERESTARTSYS;
}
res = tipc_send(tsock->p->ref, m->msg_iovlen, m->msg_iov);
if (likely(res != -ELINKCONG)) {
exit:
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
return res;
}
if (m->msg_flags & MSG_DONTWAIT) {
/* Look for a message in receive queue; wait if necessary */
- if (unlikely(down_interruptible(&tsock->sem)))
+ if (unlikely(mutex_lock_interruptible(&tsock->lock)))
return -ERESTARTSYS;
restart:
advance_queue(tsock);
}
exit:
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
return res;
}
/* Look for a message in receive queue; wait if necessary */
- if (unlikely(down_interruptible(&tsock->sem)))
+ if (unlikely(mutex_lock_interruptible(&tsock->lock)))
return -ERESTARTSYS;
restart:
goto restart;
exit:
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
return sz_copied ? sz_copied : res;
}
return res;
}
- if (down_interruptible(&tsock->sem))
+ if (mutex_lock_interruptible(&tsock->lock))
return -ERESTARTSYS;
/* Wait for destination's 'ACK' response */
sock->state = SS_DISCONNECTING;
}
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
return res;
}
(flags & O_NONBLOCK)))
return -EWOULDBLOCK;
- if (down_interruptible(&tsock->sem))
+ if (mutex_lock_interruptible(&tsock->lock))
return -ERESTARTSYS;
if (wait_event_interruptible(*sock->sk->sk_sleep,
}
}
exit:
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
return res;
}
/* Could return -EINVAL for an invalid "how", but why bother? */
- if (down_interruptible(&tsock->sem))
+ if (mutex_lock_interruptible(&tsock->lock))
return -ERESTARTSYS;
sock_lock(tsock);
sock_unlock(tsock);
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
return res;
}
if ((res = get_user(value, (u32 __user *)ov)))
return res;
- if (down_interruptible(&tsock->sem))
+ if (mutex_lock_interruptible(&tsock->lock))
return -ERESTARTSYS;
switch (opt) {
res = -EINVAL;
}
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
return res;
}
if ((res = get_user(len, ol)))
return res;
- if (down_interruptible(&tsock->sem))
+ if (mutex_lock_interruptible(&tsock->lock))
return -ERESTARTSYS;
switch (opt) {
res = put_user(sizeof(value), ol);
}
- up(&tsock->sem);
+ mutex_unlock(&tsock->lock);
return res;
}