aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorMatthias Kaehlcke <matthias@kaehlcke.net>2008-03-04 02:35:53 -0500
committerDavid S. Miller <davem@davemloft.net>2008-03-04 02:35:53 -0500
commit26bad2c05eef400d9af16979bd96e301902ebd13 (patch)
tree2601ee61987790d6ea9f01cf8559751f0cf33413 /net/tipc
parentc572872f89e46e38cdb35a43b81122bfb7ff43fc (diff)
[TIPC]: Convert tsock->sem in a mutex
The semaphore tsock->sem is used as mutex, convert it to the mutex API Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/socket.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 22909036b9bc..9ae8e9f74028 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -43,7 +43,7 @@
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/poll.h> 44#include <linux/poll.h>
45#include <linux/fcntl.h> 45#include <linux/fcntl.h>
46#include <asm/semaphore.h> 46#include <linux/mutex.h>
47#include <asm/string.h> 47#include <asm/string.h>
48#include <asm/atomic.h> 48#include <asm/atomic.h>
49#include <net/sock.h> 49#include <net/sock.h>
@@ -63,7 +63,7 @@
63struct tipc_sock { 63struct tipc_sock {
64 struct sock sk; 64 struct sock sk;
65 struct tipc_port *p; 65 struct tipc_port *p;
66 struct semaphore sem; 66 struct mutex lock;
67}; 67};
68 68
69#define tipc_sk(sk) ((struct tipc_sock*)sk) 69#define tipc_sk(sk) ((struct tipc_sock*)sk)
@@ -217,7 +217,7 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol)
217 tsock->p = port; 217 tsock->p = port;
218 port->usr_handle = tsock; 218 port->usr_handle = tsock;
219 219
220 init_MUTEX(&tsock->sem); 220 mutex_init(&tsock->lock);
221 221
222 dbg("sock_create: %x\n",tsock); 222 dbg("sock_create: %x\n",tsock);
223 223
@@ -253,9 +253,9 @@ static int release(struct socket *sock)
253 dbg("sock_delete: %x\n",tsock); 253 dbg("sock_delete: %x\n",tsock);
254 if (!tsock) 254 if (!tsock)
255 return 0; 255 return 0;
256 down(&tsock->sem); 256 mutex_lock(&tsock->lock);
257 if (!sock->sk) { 257 if (!sock->sk) {
258 up(&tsock->sem); 258 mutex_unlock(&tsock->lock);
259 return 0; 259 return 0;
260 } 260 }
261 261
@@ -288,7 +288,7 @@ static int release(struct socket *sock)
288 atomic_dec(&tipc_queue_size); 288 atomic_dec(&tipc_queue_size);
289 } 289 }
290 290
291 up(&tsock->sem); 291 mutex_unlock(&tsock->lock);
292 292
293 sock_put(sk); 293 sock_put(sk);
294 294
@@ -315,7 +315,7 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len)
315 struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr; 315 struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr;
316 int res; 316 int res;
317 317
318 if (down_interruptible(&tsock->sem)) 318 if (mutex_lock_interruptible(&tsock->lock))
319 return -ERESTARTSYS; 319 return -ERESTARTSYS;
320 320
321 if (unlikely(!uaddr_len)) { 321 if (unlikely(!uaddr_len)) {
@@ -346,7 +346,7 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len)
346 res = tipc_withdraw(tsock->p->ref, -addr->scope, 346 res = tipc_withdraw(tsock->p->ref, -addr->scope,
347 &addr->addr.nameseq); 347 &addr->addr.nameseq);
348exit: 348exit:
349 up(&tsock->sem); 349 mutex_unlock(&tsock->lock);
350 return res; 350 return res;
351} 351}
352 352
@@ -367,7 +367,7 @@ static int get_name(struct socket *sock, struct sockaddr *uaddr,
367 struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr; 367 struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr;
368 u32 res; 368 u32 res;
369 369
370 if (down_interruptible(&tsock->sem)) 370 if (mutex_lock_interruptible(&tsock->lock))
371 return -ERESTARTSYS; 371 return -ERESTARTSYS;
372 372
373 *uaddr_len = sizeof(*addr); 373 *uaddr_len = sizeof(*addr);
@@ -380,7 +380,7 @@ static int get_name(struct socket *sock, struct sockaddr *uaddr,
380 res = tipc_ownidentity(tsock->p->ref, &addr->addr.id); 380 res = tipc_ownidentity(tsock->p->ref, &addr->addr.id);
381 addr->addr.name.domain = 0; 381 addr->addr.name.domain = 0;
382 382
383 up(&tsock->sem); 383 mutex_unlock(&tsock->lock);
384 return res; 384 return res;
385} 385}
386 386
@@ -477,7 +477,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
477 } 477 }
478 } 478 }
479 479
480 if (down_interruptible(&tsock->sem)) 480 if (mutex_lock_interruptible(&tsock->lock))
481 return -ERESTARTSYS; 481 return -ERESTARTSYS;
482 482
483 if (needs_conn) { 483 if (needs_conn) {
@@ -523,7 +523,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
523 } 523 }
524 if (likely(res != -ELINKCONG)) { 524 if (likely(res != -ELINKCONG)) {
525exit: 525exit:
526 up(&tsock->sem); 526 mutex_unlock(&tsock->lock);
527 return res; 527 return res;
528 } 528 }
529 if (m->msg_flags & MSG_DONTWAIT) { 529 if (m->msg_flags & MSG_DONTWAIT) {
@@ -562,7 +562,7 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
562 if (unlikely(dest)) 562 if (unlikely(dest))
563 return send_msg(iocb, sock, m, total_len); 563 return send_msg(iocb, sock, m, total_len);
564 564
565 if (down_interruptible(&tsock->sem)) { 565 if (mutex_lock_interruptible(&tsock->lock)) {
566 return -ERESTARTSYS; 566 return -ERESTARTSYS;
567 } 567 }
568 568
@@ -578,7 +578,7 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
578 res = tipc_send(tsock->p->ref, m->msg_iovlen, m->msg_iov); 578 res = tipc_send(tsock->p->ref, m->msg_iovlen, m->msg_iov);
579 if (likely(res != -ELINKCONG)) { 579 if (likely(res != -ELINKCONG)) {
580exit: 580exit:
581 up(&tsock->sem); 581 mutex_unlock(&tsock->lock);
582 return res; 582 return res;
583 } 583 }
584 if (m->msg_flags & MSG_DONTWAIT) { 584 if (m->msg_flags & MSG_DONTWAIT) {
@@ -846,7 +846,7 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
846 846
847 /* Look for a message in receive queue; wait if necessary */ 847 /* Look for a message in receive queue; wait if necessary */
848 848
849 if (unlikely(down_interruptible(&tsock->sem))) 849 if (unlikely(mutex_lock_interruptible(&tsock->lock)))
850 return -ERESTARTSYS; 850 return -ERESTARTSYS;
851 851
852restart: 852restart:
@@ -930,7 +930,7 @@ restart:
930 advance_queue(tsock); 930 advance_queue(tsock);
931 } 931 }
932exit: 932exit:
933 up(&tsock->sem); 933 mutex_unlock(&tsock->lock);
934 return res; 934 return res;
935} 935}
936 936
@@ -981,7 +981,7 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
981 981
982 /* Look for a message in receive queue; wait if necessary */ 982 /* Look for a message in receive queue; wait if necessary */
983 983
984 if (unlikely(down_interruptible(&tsock->sem))) 984 if (unlikely(mutex_lock_interruptible(&tsock->lock)))
985 return -ERESTARTSYS; 985 return -ERESTARTSYS;
986 986
987restart: 987restart:
@@ -1077,7 +1077,7 @@ restart:
1077 goto restart; 1077 goto restart;
1078 1078
1079exit: 1079exit:
1080 up(&tsock->sem); 1080 mutex_unlock(&tsock->lock);
1081 return sz_copied ? sz_copied : res; 1081 return sz_copied ? sz_copied : res;
1082} 1082}
1083 1083
@@ -1293,7 +1293,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
1293 return res; 1293 return res;
1294 } 1294 }
1295 1295
1296 if (down_interruptible(&tsock->sem)) 1296 if (mutex_lock_interruptible(&tsock->lock))
1297 return -ERESTARTSYS; 1297 return -ERESTARTSYS;
1298 1298
1299 /* Wait for destination's 'ACK' response */ 1299 /* Wait for destination's 'ACK' response */
@@ -1317,7 +1317,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
1317 sock->state = SS_DISCONNECTING; 1317 sock->state = SS_DISCONNECTING;
1318 } 1318 }
1319 1319
1320 up(&tsock->sem); 1320 mutex_unlock(&tsock->lock);
1321 return res; 1321 return res;
1322} 1322}
1323 1323
@@ -1365,7 +1365,7 @@ static int accept(struct socket *sock, struct socket *newsock, int flags)
1365 (flags & O_NONBLOCK))) 1365 (flags & O_NONBLOCK)))
1366 return -EWOULDBLOCK; 1366 return -EWOULDBLOCK;
1367 1367
1368 if (down_interruptible(&tsock->sem)) 1368 if (mutex_lock_interruptible(&tsock->lock))
1369 return -ERESTARTSYS; 1369 return -ERESTARTSYS;
1370 1370
1371 if (wait_event_interruptible(*sock->sk->sk_sleep, 1371 if (wait_event_interruptible(*sock->sk->sk_sleep,
@@ -1412,7 +1412,7 @@ static int accept(struct socket *sock, struct socket *newsock, int flags)
1412 } 1412 }
1413 } 1413 }
1414exit: 1414exit:
1415 up(&tsock->sem); 1415 mutex_unlock(&tsock->lock);
1416 return res; 1416 return res;
1417} 1417}
1418 1418
@@ -1434,7 +1434,7 @@ static int shutdown(struct socket *sock, int how)
1434 1434
1435 /* Could return -EINVAL for an invalid "how", but why bother? */ 1435 /* Could return -EINVAL for an invalid "how", but why bother? */
1436 1436
1437 if (down_interruptible(&tsock->sem)) 1437 if (mutex_lock_interruptible(&tsock->lock))
1438 return -ERESTARTSYS; 1438 return -ERESTARTSYS;
1439 1439
1440 sock_lock(tsock); 1440 sock_lock(tsock);
@@ -1484,7 +1484,7 @@ restart:
1484 1484
1485 sock_unlock(tsock); 1485 sock_unlock(tsock);
1486 1486
1487 up(&tsock->sem); 1487 mutex_unlock(&tsock->lock);
1488 return res; 1488 return res;
1489} 1489}
1490 1490
@@ -1518,7 +1518,7 @@ static int setsockopt(struct socket *sock,
1518 if ((res = get_user(value, (u32 __user *)ov))) 1518 if ((res = get_user(value, (u32 __user *)ov)))
1519 return res; 1519 return res;
1520 1520
1521 if (down_interruptible(&tsock->sem)) 1521 if (mutex_lock_interruptible(&tsock->lock))
1522 return -ERESTARTSYS; 1522 return -ERESTARTSYS;
1523 1523
1524 switch (opt) { 1524 switch (opt) {
@@ -1541,7 +1541,7 @@ static int setsockopt(struct socket *sock,
1541 res = -EINVAL; 1541 res = -EINVAL;
1542 } 1542 }
1543 1543
1544 up(&tsock->sem); 1544 mutex_unlock(&tsock->lock);
1545 return res; 1545 return res;
1546} 1546}
1547 1547
@@ -1574,7 +1574,7 @@ static int getsockopt(struct socket *sock,
1574 if ((res = get_user(len, ol))) 1574 if ((res = get_user(len, ol)))
1575 return res; 1575 return res;
1576 1576
1577 if (down_interruptible(&tsock->sem)) 1577 if (mutex_lock_interruptible(&tsock->lock))
1578 return -ERESTARTSYS; 1578 return -ERESTARTSYS;
1579 1579
1580 switch (opt) { 1580 switch (opt) {
@@ -1607,7 +1607,7 @@ static int getsockopt(struct socket *sock,
1607 res = put_user(sizeof(value), ol); 1607 res = put_user(sizeof(value), ol);
1608 } 1608 }
1609 1609
1610 up(&tsock->sem); 1610 mutex_unlock(&tsock->lock);
1611 return res; 1611 return res;
1612} 1612}
1613 1613