diff options
author | Corey Minyard <minyard@acm.org> | 2006-03-31 05:30:41 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-31 15:18:54 -0500 |
commit | d6dfd1310d3562698fd7c3c086f6c239f96394ac (patch) | |
tree | ff6c77f2d2e8bcb5b765bdaa4198243e043031aa /drivers/char/ipmi/ipmi_msghandler.c | |
parent | 8a3628d53fe5eb1d1401dd1ce16655182c1c5ffc (diff) |
[PATCH] IPMI: convert from semaphores to mutexes
Convert the remaining semaphores to mutexes in the IPMI driver. The
watchdog was using a semaphore as a real semaphore (for IPC), so the
conversion there required adding a completion.
Signed-off-by: Corey Minyard <minyard@acm.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/ipmi/ipmi_msghandler.c')
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index c0c862cce1c3..0ded046d5aa8 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/sched.h> | 38 | #include <linux/sched.h> |
39 | #include <linux/poll.h> | 39 | #include <linux/poll.h> |
40 | #include <linux/spinlock.h> | 40 | #include <linux/spinlock.h> |
41 | #include <linux/mutex.h> | ||
41 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
42 | #include <linux/ipmi.h> | 43 | #include <linux/ipmi.h> |
43 | #include <linux/ipmi_smi.h> | 44 | #include <linux/ipmi_smi.h> |
@@ -234,7 +235,7 @@ struct ipmi_smi | |||
234 | 235 | ||
235 | /* The list of command receivers that are registered for commands | 236 | /* The list of command receivers that are registered for commands |
236 | on this interface. */ | 237 | on this interface. */ |
237 | struct semaphore cmd_rcvrs_lock; | 238 | struct mutex cmd_rcvrs_mutex; |
238 | struct list_head cmd_rcvrs; | 239 | struct list_head cmd_rcvrs; |
239 | 240 | ||
240 | /* Events that were queues because no one was there to receive | 241 | /* Events that were queues because no one was there to receive |
@@ -387,10 +388,10 @@ static void clean_up_interface_data(ipmi_smi_t intf) | |||
387 | 388 | ||
388 | /* Wholesale remove all the entries from the list in the | 389 | /* Wholesale remove all the entries from the list in the |
389 | * interface and wait for RCU to know that none are in use. */ | 390 | * interface and wait for RCU to know that none are in use. */ |
390 | down(&intf->cmd_rcvrs_lock); | 391 | mutex_lock(&intf->cmd_rcvrs_mutex); |
391 | list_add_rcu(&list, &intf->cmd_rcvrs); | 392 | list_add_rcu(&list, &intf->cmd_rcvrs); |
392 | list_del_rcu(&intf->cmd_rcvrs); | 393 | list_del_rcu(&intf->cmd_rcvrs); |
393 | up(&intf->cmd_rcvrs_lock); | 394 | mutex_unlock(&intf->cmd_rcvrs_mutex); |
394 | synchronize_rcu(); | 395 | synchronize_rcu(); |
395 | 396 | ||
396 | list_for_each_entry_safe(rcvr, rcvr2, &list, link) | 397 | list_for_each_entry_safe(rcvr, rcvr2, &list, link) |
@@ -846,7 +847,7 @@ int ipmi_destroy_user(ipmi_user_t user) | |||
846 | * since other things may be using it till we do | 847 | * since other things may be using it till we do |
847 | * synchronize_rcu()) then free everything in that list. | 848 | * synchronize_rcu()) then free everything in that list. |
848 | */ | 849 | */ |
849 | down(&intf->cmd_rcvrs_lock); | 850 | mutex_lock(&intf->cmd_rcvrs_mutex); |
850 | list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link) { | 851 | list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link) { |
851 | if (rcvr->user == user) { | 852 | if (rcvr->user == user) { |
852 | list_del_rcu(&rcvr->link); | 853 | list_del_rcu(&rcvr->link); |
@@ -854,7 +855,7 @@ int ipmi_destroy_user(ipmi_user_t user) | |||
854 | rcvrs = rcvr; | 855 | rcvrs = rcvr; |
855 | } | 856 | } |
856 | } | 857 | } |
857 | up(&intf->cmd_rcvrs_lock); | 858 | mutex_unlock(&intf->cmd_rcvrs_mutex); |
858 | synchronize_rcu(); | 859 | synchronize_rcu(); |
859 | while (rcvrs) { | 860 | while (rcvrs) { |
860 | rcvr = rcvrs; | 861 | rcvr = rcvrs; |
@@ -984,7 +985,7 @@ int ipmi_register_for_cmd(ipmi_user_t user, | |||
984 | rcvr->netfn = netfn; | 985 | rcvr->netfn = netfn; |
985 | rcvr->user = user; | 986 | rcvr->user = user; |
986 | 987 | ||
987 | down(&intf->cmd_rcvrs_lock); | 988 | mutex_lock(&intf->cmd_rcvrs_mutex); |
988 | /* Make sure the command/netfn is not already registered. */ | 989 | /* Make sure the command/netfn is not already registered. */ |
989 | entry = find_cmd_rcvr(intf, netfn, cmd); | 990 | entry = find_cmd_rcvr(intf, netfn, cmd); |
990 | if (entry) { | 991 | if (entry) { |
@@ -995,7 +996,7 @@ int ipmi_register_for_cmd(ipmi_user_t user, | |||
995 | list_add_rcu(&rcvr->link, &intf->cmd_rcvrs); | 996 | list_add_rcu(&rcvr->link, &intf->cmd_rcvrs); |
996 | 997 | ||
997 | out_unlock: | 998 | out_unlock: |
998 | up(&intf->cmd_rcvrs_lock); | 999 | mutex_unlock(&intf->cmd_rcvrs_mutex); |
999 | if (rv) | 1000 | if (rv) |
1000 | kfree(rcvr); | 1001 | kfree(rcvr); |
1001 | 1002 | ||
@@ -1009,17 +1010,17 @@ int ipmi_unregister_for_cmd(ipmi_user_t user, | |||
1009 | ipmi_smi_t intf = user->intf; | 1010 | ipmi_smi_t intf = user->intf; |
1010 | struct cmd_rcvr *rcvr; | 1011 | struct cmd_rcvr *rcvr; |
1011 | 1012 | ||
1012 | down(&intf->cmd_rcvrs_lock); | 1013 | mutex_lock(&intf->cmd_rcvrs_mutex); |
1013 | /* Make sure the command/netfn is not already registered. */ | 1014 | /* Make sure the command/netfn is not already registered. */ |
1014 | rcvr = find_cmd_rcvr(intf, netfn, cmd); | 1015 | rcvr = find_cmd_rcvr(intf, netfn, cmd); |
1015 | if ((rcvr) && (rcvr->user == user)) { | 1016 | if ((rcvr) && (rcvr->user == user)) { |
1016 | list_del_rcu(&rcvr->link); | 1017 | list_del_rcu(&rcvr->link); |
1017 | up(&intf->cmd_rcvrs_lock); | 1018 | mutex_unlock(&intf->cmd_rcvrs_mutex); |
1018 | synchronize_rcu(); | 1019 | synchronize_rcu(); |
1019 | kfree(rcvr); | 1020 | kfree(rcvr); |
1020 | return 0; | 1021 | return 0; |
1021 | } else { | 1022 | } else { |
1022 | up(&intf->cmd_rcvrs_lock); | 1023 | mutex_unlock(&intf->cmd_rcvrs_mutex); |
1023 | return -ENOENT; | 1024 | return -ENOENT; |
1024 | } | 1025 | } |
1025 | } | 1026 | } |
@@ -2365,7 +2366,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, | |||
2365 | spin_lock_init(&intf->events_lock); | 2366 | spin_lock_init(&intf->events_lock); |
2366 | INIT_LIST_HEAD(&intf->waiting_events); | 2367 | INIT_LIST_HEAD(&intf->waiting_events); |
2367 | intf->waiting_events_count = 0; | 2368 | intf->waiting_events_count = 0; |
2368 | init_MUTEX(&intf->cmd_rcvrs_lock); | 2369 | mutex_init(&intf->cmd_rcvrs_mutex); |
2369 | INIT_LIST_HEAD(&intf->cmd_rcvrs); | 2370 | INIT_LIST_HEAD(&intf->cmd_rcvrs); |
2370 | init_waitqueue_head(&intf->waitq); | 2371 | init_waitqueue_head(&intf->waitq); |
2371 | 2372 | ||