Skip to content

Commit 4a3e2f7

Browse files
Arjan van de Vendavem330
authored andcommitted
[NET] sem2mutex: net/
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d4ccd08 commit 4a3e2f7

19 files changed

Lines changed: 118 additions & 101 deletions

File tree

‎include/net/xfrm.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/crypto.h>
1212
#include <linux/pfkeyv2.h>
1313
#include <linux/in6.h>
14+
#include <linux/mutex.h>
1415

1516
#include <net/sock.h>
1617
#include <net/dst.h>
@@ -24,7 +25,7 @@ extern struct sock *xfrm_nl;
2425
extern u32 sysctl_xfrm_aevent_etime;
2526
extern u32 sysctl_xfrm_aevent_rseqth;
2627

27-
extern struct semaphore xfrm_cfg_sem;
28+
extern struct mutex xfrm_cfg_mutex;
2829

2930
/* Organization of SPD aka "XFRM rules"
3031
------------------------------------

‎net/atm/ioctl.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,30 @@
1818
#include <linux/atmmpc.h>
1919
#include <net/atmclip.h>
2020
#include <linux/atmlec.h>
21+
#include <linux/mutex.h>
2122
#include <asm/ioctls.h>
2223

2324
#include "resources.h"
2425
#include "signaling.h" /* for WAITING and sigd_attach */
2526
#include "common.h"
2627

2728

28-
static DECLARE_MUTEX(ioctl_mutex);
29+
static DEFINE_MUTEX(ioctl_mutex);
2930
static LIST_HEAD(ioctl_list);
3031

3132

3233
void register_atm_ioctl(struct atm_ioctl *ioctl)
3334
{
34-
down(&ioctl_mutex);
35+
mutex_lock(&ioctl_mutex);
3536
list_add_tail(&ioctl->list, &ioctl_list);
36-
up(&ioctl_mutex);
37+
mutex_unlock(&ioctl_mutex);
3738
}
3839

3940
void deregister_atm_ioctl(struct atm_ioctl *ioctl)
4041
{
41-
down(&ioctl_mutex);
42+
mutex_lock(&ioctl_mutex);
4243
list_del(&ioctl->list);
43-
up(&ioctl_mutex);
44+
mutex_unlock(&ioctl_mutex);
4445
}
4546

4647
EXPORT_SYMBOL(register_atm_ioctl);
@@ -137,7 +138,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
137138

138139
error = -ENOIOCTLCMD;
139140

140-
down(&ioctl_mutex);
141+
mutex_lock(&ioctl_mutex);
141142
list_for_each(pos, &ioctl_list) {
142143
struct atm_ioctl * ic = list_entry(pos, struct atm_ioctl, list);
143144
if (try_module_get(ic->owner)) {
@@ -147,7 +148,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
147148
break;
148149
}
149150
}
150-
up(&ioctl_mutex);
151+
mutex_unlock(&ioctl_mutex);
151152

152153
if (error != -ENOIOCTLCMD)
153154
goto done;

‎net/bluetooth/rfcomm/core.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include <linux/wait.h>
3838
#include <linux/device.h>
3939
#include <linux/net.h>
40+
#include <linux/mutex.h>
41+
4042
#include <net/sock.h>
4143
#include <asm/uaccess.h>
4244
#include <asm/unaligned.h>
@@ -57,9 +59,9 @@ static unsigned int l2cap_mtu = RFCOMM_MAX_L2CAP_MTU;
5759

5860
static struct task_struct *rfcomm_thread;
5961

60-
static DECLARE_MUTEX(rfcomm_sem);
61-
#define rfcomm_lock() down(&rfcomm_sem);
62-
#define rfcomm_unlock() up(&rfcomm_sem);
62+
static DEFINE_MUTEX(rfcomm_mutex);
63+
#define rfcomm_lock() mutex_lock(&rfcomm_mutex)
64+
#define rfcomm_unlock() mutex_unlock(&rfcomm_mutex)
6365

6466
static unsigned long rfcomm_event;
6567

‎net/core/dev.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#include <linux/types.h>
8282
#include <linux/kernel.h>
8383
#include <linux/sched.h>
84+
#include <linux/mutex.h>
8485
#include <linux/string.h>
8586
#include <linux/mm.h>
8687
#include <linux/socket.h>
@@ -2931,15 +2932,15 @@ static void netdev_wait_allrefs(struct net_device *dev)
29312932
* 2) Since we run with the RTNL semaphore not held, we can sleep
29322933
* safely in order to wait for the netdev refcnt to drop to zero.
29332934
*/
2934-
static DECLARE_MUTEX(net_todo_run_mutex);
2935+
static DEFINE_MUTEX(net_todo_run_mutex);
29352936
void netdev_run_todo(void)
29362937
{
29372938
struct list_head list = LIST_HEAD_INIT(list);
29382939
int err;
29392940

29402941

29412942
/* Need to guard against multiple cpu's getting out of order. */
2942-
down(&net_todo_run_mutex);
2943+
mutex_lock(&net_todo_run_mutex);
29432944

29442945
/* Not safe to do outside the semaphore. We must not return
29452946
* until all unregister events invoked by the local processor
@@ -2996,7 +2997,7 @@ void netdev_run_todo(void)
29962997
}
29972998

29982999
out:
2999-
up(&net_todo_run_mutex);
3000+
mutex_unlock(&net_todo_run_mutex);
30003001
}
30013002

30023003
/**

‎net/core/flow.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/notifier.h>
2121
#include <linux/cpu.h>
2222
#include <linux/cpumask.h>
23+
#include <linux/mutex.h>
2324
#include <net/flow.h>
2425
#include <asm/atomic.h>
2526
#include <asm/semaphore.h>
@@ -287,11 +288,11 @@ static void flow_cache_flush_per_cpu(void *data)
287288
void flow_cache_flush(void)
288289
{
289290
struct flow_flush_info info;
290-
static DECLARE_MUTEX(flow_flush_sem);
291+
static DEFINE_MUTEX(flow_flush_sem);
291292

292293
/* Don't want cpus going down or up during this. */
293294
lock_cpu_hotplug();
294-
down(&flow_flush_sem);
295+
mutex_lock(&flow_flush_sem);
295296
atomic_set(&info.cpuleft, num_online_cpus());
296297
init_completion(&info.completion);
297298

@@ -301,7 +302,7 @@ void flow_cache_flush(void)
301302
local_bh_enable();
302303

303304
wait_for_completion(&info.completion);
304-
up(&flow_flush_sem);
305+
mutex_unlock(&flow_flush_sem);
305306
unlock_cpu_hotplug();
306307
}
307308

‎net/ipv4/ipcomp.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/list.h>
2525
#include <linux/vmalloc.h>
2626
#include <linux/rtnetlink.h>
27+
#include <linux/mutex.h>
2728
#include <net/ip.h>
2829
#include <net/xfrm.h>
2930
#include <net/icmp.h>
@@ -36,7 +37,7 @@ struct ipcomp_tfms {
3637
int users;
3738
};
3839

39-
static DECLARE_MUTEX(ipcomp_resource_sem);
40+
static DEFINE_MUTEX(ipcomp_resource_mutex);
4041
static void **ipcomp_scratches;
4142
static int ipcomp_scratch_users;
4243
static LIST_HEAD(ipcomp_tfms_list);
@@ -253,7 +254,7 @@ static struct xfrm_state *ipcomp_tunnel_create(struct xfrm_state *x)
253254
}
254255

255256
/*
256-
* Must be protected by xfrm_cfg_sem. State and tunnel user references are
257+
* Must be protected by xfrm_cfg_mutex. State and tunnel user references are
257258
* always incremented on success.
258259
*/
259260
static int ipcomp_tunnel_attach(struct xfrm_state *x)
@@ -411,9 +412,9 @@ static void ipcomp_destroy(struct xfrm_state *x)
411412
if (!ipcd)
412413
return;
413414
xfrm_state_delete_tunnel(x);
414-
down(&ipcomp_resource_sem);
415+
mutex_lock(&ipcomp_resource_mutex);
415416
ipcomp_free_data(ipcd);
416-
up(&ipcomp_resource_sem);
417+
mutex_unlock(&ipcomp_resource_mutex);
417418
kfree(ipcd);
418419
}
419420

@@ -440,14 +441,14 @@ static int ipcomp_init_state(struct xfrm_state *x)
440441
if (x->props.mode)
441442
x->props.header_len += sizeof(struct iphdr);
442443

443-
down(&ipcomp_resource_sem);
444+
mutex_lock(&ipcomp_resource_mutex);
444445
if (!ipcomp_alloc_scratches())
445446
goto error;
446447

447448
ipcd->tfms = ipcomp_alloc_tfms(x->calg->alg_name);
448449
if (!ipcd->tfms)
449450
goto error;
450-
up(&ipcomp_resource_sem);
451+
mutex_unlock(&ipcomp_resource_mutex);
451452

452453
if (x->props.mode) {
453454
err = ipcomp_tunnel_attach(x);
@@ -464,10 +465,10 @@ static int ipcomp_init_state(struct xfrm_state *x)
464465
return err;
465466

466467
error_tunnel:
467-
down(&ipcomp_resource_sem);
468+
mutex_lock(&ipcomp_resource_mutex);
468469
error:
469470
ipcomp_free_data(ipcd);
470-
up(&ipcomp_resource_sem);
471+
mutex_unlock(&ipcomp_resource_mutex);
471472
kfree(ipcd);
472473
goto out;
473474
}

‎net/ipv4/netfilter/ip_queue.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/sysctl.h>
3636
#include <linux/proc_fs.h>
3737
#include <linux/security.h>
38+
#include <linux/mutex.h>
3839
#include <net/sock.h>
3940
#include <net/route.h>
4041

@@ -61,7 +62,7 @@ static unsigned int queue_dropped = 0;
6162
static unsigned int queue_user_dropped = 0;
6263
static struct sock *ipqnl;
6364
static LIST_HEAD(queue_list);
64-
static DECLARE_MUTEX(ipqnl_sem);
65+
static DEFINE_MUTEX(ipqnl_mutex);
6566

6667
static void
6768
ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict)
@@ -539,15 +540,15 @@ ipq_rcv_sk(struct sock *sk, int len)
539540
struct sk_buff *skb;
540541
unsigned int qlen;
541542

542-
down(&ipqnl_sem);
543+
mutex_lock(&ipqnl_mutex);
543544

544545
for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) {
545546
skb = skb_dequeue(&sk->sk_receive_queue);
546547
ipq_rcv_skb(skb);
547548
kfree_skb(skb);
548549
}
549550

550-
up(&ipqnl_sem);
551+
mutex_unlock(&ipqnl_mutex);
551552
}
552553

553554
static int
@@ -708,8 +709,8 @@ init_or_cleanup(int init)
708709

709710
cleanup_ipqnl:
710711
sock_release(ipqnl->sk_socket);
711-
down(&ipqnl_sem);
712-
up(&ipqnl_sem);
712+
mutex_lock(&ipqnl_mutex);
713+
mutex_unlock(&ipqnl_mutex);
713714

714715
cleanup_netlink_notifier:
715716
netlink_unregister_notifier(&ipq_nl_notifier);

‎net/ipv4/xfrm4_tunnel.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <linux/skbuff.h>
77
#include <linux/module.h>
8+
#include <linux/mutex.h>
89
#include <net/xfrm.h>
910
#include <net/ip.h>
1011
#include <net/protocol.h>
@@ -26,19 +27,19 @@ static int ipip_xfrm_rcv(struct xfrm_state *x, struct xfrm_decap_state *decap, s
2627
}
2728

2829
static struct xfrm_tunnel *ipip_handler;
29-
static DECLARE_MUTEX(xfrm4_tunnel_sem);
30+
static DEFINE_MUTEX(xfrm4_tunnel_mutex);
3031

3132
int xfrm4_tunnel_register(struct xfrm_tunnel *handler)
3233
{
3334
int ret;
3435

35-
down(&xfrm4_tunnel_sem);
36+
mutex_lock(&xfrm4_tunnel_mutex);
3637
ret = 0;
3738
if (ipip_handler != NULL)
3839
ret = -EINVAL;
3940
if (!ret)
4041
ipip_handler = handler;
41-
up(&xfrm4_tunnel_sem);
42+
mutex_unlock(&xfrm4_tunnel_mutex);
4243

4344
return ret;
4445
}
@@ -49,13 +50,13 @@ int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler)
4950
{
5051
int ret;
5152

52-
down(&xfrm4_tunnel_sem);
53+
mutex_lock(&xfrm4_tunnel_mutex);
5354
ret = 0;
5455
if (ipip_handler != handler)
5556
ret = -EINVAL;
5657
if (!ret)
5758
ipip_handler = NULL;
58-
up(&xfrm4_tunnel_sem);
59+
mutex_unlock(&xfrm4_tunnel_mutex);
5960

6061
synchronize_net();
6162

‎net/ipv6/ipcomp6.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@
5050
#include <net/protocol.h>
5151
#include <linux/ipv6.h>
5252
#include <linux/icmpv6.h>
53+
#include <linux/mutex.h>
5354

5455
struct ipcomp6_tfms {
5556
struct list_head list;
5657
struct crypto_tfm **tfms;
5758
int users;
5859
};
5960

60-
static DECLARE_MUTEX(ipcomp6_resource_sem);
61+
static DEFINE_MUTEX(ipcomp6_resource_mutex);
6162
static void **ipcomp6_scratches;
6263
static int ipcomp6_scratch_users;
6364
static LIST_HEAD(ipcomp6_tfms_list);
@@ -405,9 +406,9 @@ static void ipcomp6_destroy(struct xfrm_state *x)
405406
if (!ipcd)
406407
return;
407408
xfrm_state_delete_tunnel(x);
408-
down(&ipcomp6_resource_sem);
409+
mutex_lock(&ipcomp6_resource_mutex);
409410
ipcomp6_free_data(ipcd);
410-
up(&ipcomp6_resource_sem);
411+
mutex_unlock(&ipcomp6_resource_mutex);
411412
kfree(ipcd);
412413

413414
xfrm6_tunnel_free_spi((xfrm_address_t *)&x->props.saddr);
@@ -436,14 +437,14 @@ static int ipcomp6_init_state(struct xfrm_state *x)
436437
if (x->props.mode)
437438
x->props.header_len += sizeof(struct ipv6hdr);
438439

439-
down(&ipcomp6_resource_sem);
440+
mutex_lock(&ipcomp6_resource_mutex);
440441
if (!ipcomp6_alloc_scratches())
441442
goto error;
442443

443444
ipcd->tfms = ipcomp6_alloc_tfms(x->calg->alg_name);
444445
if (!ipcd->tfms)
445446
goto error;
446-
up(&ipcomp6_resource_sem);
447+
mutex_unlock(&ipcomp6_resource_mutex);
447448

448449
if (x->props.mode) {
449450
err = ipcomp6_tunnel_attach(x);
@@ -459,10 +460,10 @@ static int ipcomp6_init_state(struct xfrm_state *x)
459460
out:
460461
return err;
461462
error_tunnel:
462-
down(&ipcomp6_resource_sem);
463+
mutex_lock(&ipcomp6_resource_mutex);
463464
error:
464465
ipcomp6_free_data(ipcd);
465-
up(&ipcomp6_resource_sem);
466+
mutex_unlock(&ipcomp6_resource_mutex);
466467
kfree(ipcd);
467468

468469
goto out;

0 commit comments

Comments
 (0)