diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-03-18 17:39:55 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-03-18 17:39:55 -0400 |
commit | 38f6b38dbb0896511c509fbb6ceabbedbee8e87d (patch) | |
tree | 00553b841e8af3add37162c6a189991d7dba30df /drivers | |
parent | aee94467d9858b5441c278ffa39dcd19bef548cf (diff) |
PNP: Convert pnp_lock into a mutex
pnp_lock is a spinlock, but it is only acquired from process context,
so it may be a mutex just fine.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pnp/base.h | 2 | ||||
-rw-r--r-- | drivers/pnp/card.c | 25 | ||||
-rw-r--r-- | drivers/pnp/core.c | 19 | ||||
-rw-r--r-- | drivers/pnp/driver.c | 10 |
4 files changed, 29 insertions, 27 deletions
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index c8873b0ca551..3151fd164614 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h | |||
@@ -3,7 +3,7 @@ | |||
3 | * Bjorn Helgaas <bjorn.helgaas@hp.com> | 3 | * Bjorn Helgaas <bjorn.helgaas@hp.com> |
4 | */ | 4 | */ |
5 | 5 | ||
6 | extern spinlock_t pnp_lock; | 6 | extern struct mutex pnp_lock; |
7 | extern const struct attribute_group *pnp_dev_groups[]; | 7 | extern const struct attribute_group *pnp_dev_groups[]; |
8 | void *pnp_alloc(long size); | 8 | void *pnp_alloc(long size); |
9 | 9 | ||
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c index 874c236ac1a7..31ad9fc3f701 100644 --- a/drivers/pnp/card.c +++ b/drivers/pnp/card.c | |||
@@ -5,6 +5,7 @@ | |||
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/mutex.h> | ||
8 | #include <linux/ctype.h> | 9 | #include <linux/ctype.h> |
9 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
10 | #include <linux/pnp.h> | 11 | #include <linux/pnp.h> |
@@ -244,10 +245,10 @@ int pnp_add_card(struct pnp_card *card) | |||
244 | } | 245 | } |
245 | 246 | ||
246 | pnp_interface_attach_card(card); | 247 | pnp_interface_attach_card(card); |
247 | spin_lock(&pnp_lock); | 248 | mutex_lock(&pnp_lock); |
248 | list_add_tail(&card->global_list, &pnp_cards); | 249 | list_add_tail(&card->global_list, &pnp_cards); |
249 | list_add_tail(&card->protocol_list, &card->protocol->cards); | 250 | list_add_tail(&card->protocol_list, &card->protocol->cards); |
250 | spin_unlock(&pnp_lock); | 251 | mutex_unlock(&pnp_lock); |
251 | 252 | ||
252 | /* we wait until now to add devices in order to ensure the drivers | 253 | /* we wait until now to add devices in order to ensure the drivers |
253 | * will be able to use all of the related devices on the card | 254 | * will be able to use all of the related devices on the card |
@@ -276,10 +277,10 @@ void pnp_remove_card(struct pnp_card *card) | |||
276 | struct list_head *pos, *temp; | 277 | struct list_head *pos, *temp; |
277 | 278 | ||
278 | device_unregister(&card->dev); | 279 | device_unregister(&card->dev); |
279 | spin_lock(&pnp_lock); | 280 | mutex_lock(&pnp_lock); |
280 | list_del(&card->global_list); | 281 | list_del(&card->global_list); |
281 | list_del(&card->protocol_list); | 282 | list_del(&card->protocol_list); |
282 | spin_unlock(&pnp_lock); | 283 | mutex_unlock(&pnp_lock); |
283 | list_for_each_safe(pos, temp, &card->devices) { | 284 | list_for_each_safe(pos, temp, &card->devices) { |
284 | struct pnp_dev *dev = card_to_pnp_dev(pos); | 285 | struct pnp_dev *dev = card_to_pnp_dev(pos); |
285 | pnp_remove_card_device(dev); | 286 | pnp_remove_card_device(dev); |
@@ -297,10 +298,10 @@ int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) | |||
297 | dev->card_link = NULL; | 298 | dev->card_link = NULL; |
298 | dev_set_name(&dev->dev, "%02x:%02x.%02x", | 299 | dev_set_name(&dev->dev, "%02x:%02x.%02x", |
299 | dev->protocol->number, card->number, dev->number); | 300 | dev->protocol->number, card->number, dev->number); |
300 | spin_lock(&pnp_lock); | 301 | mutex_lock(&pnp_lock); |
301 | dev->card = card; | 302 | dev->card = card; |
302 | list_add_tail(&dev->card_list, &card->devices); | 303 | list_add_tail(&dev->card_list, &card->devices); |
303 | spin_unlock(&pnp_lock); | 304 | mutex_unlock(&pnp_lock); |
304 | return 0; | 305 | return 0; |
305 | } | 306 | } |
306 | 307 | ||
@@ -310,10 +311,10 @@ int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) | |||
310 | */ | 311 | */ |
311 | void pnp_remove_card_device(struct pnp_dev *dev) | 312 | void pnp_remove_card_device(struct pnp_dev *dev) |
312 | { | 313 | { |
313 | spin_lock(&pnp_lock); | 314 | mutex_lock(&pnp_lock); |
314 | dev->card = NULL; | 315 | dev->card = NULL; |
315 | list_del(&dev->card_list); | 316 | list_del(&dev->card_list); |
316 | spin_unlock(&pnp_lock); | 317 | mutex_unlock(&pnp_lock); |
317 | __pnp_remove_device(dev); | 318 | __pnp_remove_device(dev); |
318 | } | 319 | } |
319 | 320 | ||
@@ -426,9 +427,9 @@ int pnp_register_card_driver(struct pnp_card_driver *drv) | |||
426 | if (error < 0) | 427 | if (error < 0) |
427 | return error; | 428 | return error; |
428 | 429 | ||
429 | spin_lock(&pnp_lock); | 430 | mutex_lock(&pnp_lock); |
430 | list_add_tail(&drv->global_list, &pnp_card_drivers); | 431 | list_add_tail(&drv->global_list, &pnp_card_drivers); |
431 | spin_unlock(&pnp_lock); | 432 | mutex_unlock(&pnp_lock); |
432 | 433 | ||
433 | list_for_each_safe(pos, temp, &pnp_cards) { | 434 | list_for_each_safe(pos, temp, &pnp_cards) { |
434 | struct pnp_card *card = | 435 | struct pnp_card *card = |
@@ -444,9 +445,9 @@ int pnp_register_card_driver(struct pnp_card_driver *drv) | |||
444 | */ | 445 | */ |
445 | void pnp_unregister_card_driver(struct pnp_card_driver *drv) | 446 | void pnp_unregister_card_driver(struct pnp_card_driver *drv) |
446 | { | 447 | { |
447 | spin_lock(&pnp_lock); | 448 | mutex_lock(&pnp_lock); |
448 | list_del(&drv->global_list); | 449 | list_del(&drv->global_list); |
449 | spin_unlock(&pnp_lock); | 450 | mutex_unlock(&pnp_lock); |
450 | pnp_unregister_driver(&drv->link); | 451 | pnp_unregister_driver(&drv->link); |
451 | } | 452 | } |
452 | 453 | ||
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index cb6ce42f8e77..ef2f59c4e57c 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/list.h> | 9 | #include <linux/list.h> |
10 | #include <linux/device.h> | 10 | #include <linux/device.h> |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/mutex.h> | ||
12 | #include <linux/init.h> | 13 | #include <linux/init.h> |
13 | #include <linux/string.h> | 14 | #include <linux/string.h> |
14 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
@@ -19,7 +20,7 @@ | |||
19 | 20 | ||
20 | static LIST_HEAD(pnp_protocols); | 21 | static LIST_HEAD(pnp_protocols); |
21 | LIST_HEAD(pnp_global); | 22 | LIST_HEAD(pnp_global); |
22 | DEFINE_SPINLOCK(pnp_lock); | 23 | DEFINE_MUTEX(pnp_lock); |
23 | 24 | ||
24 | /* | 25 | /* |
25 | * ACPI or PNPBIOS should tell us about all platform devices, so we can | 26 | * ACPI or PNPBIOS should tell us about all platform devices, so we can |
@@ -55,7 +56,7 @@ int pnp_register_protocol(struct pnp_protocol *protocol) | |||
55 | INIT_LIST_HEAD(&protocol->devices); | 56 | INIT_LIST_HEAD(&protocol->devices); |
56 | INIT_LIST_HEAD(&protocol->cards); | 57 | INIT_LIST_HEAD(&protocol->cards); |
57 | nodenum = 0; | 58 | nodenum = 0; |
58 | spin_lock(&pnp_lock); | 59 | mutex_lock(&pnp_lock); |
59 | 60 | ||
60 | /* assign the lowest unused number */ | 61 | /* assign the lowest unused number */ |
61 | list_for_each(pos, &pnp_protocols) { | 62 | list_for_each(pos, &pnp_protocols) { |
@@ -67,7 +68,7 @@ int pnp_register_protocol(struct pnp_protocol *protocol) | |||
67 | } | 68 | } |
68 | 69 | ||
69 | list_add_tail(&protocol->protocol_list, &pnp_protocols); | 70 | list_add_tail(&protocol->protocol_list, &pnp_protocols); |
70 | spin_unlock(&pnp_lock); | 71 | mutex_unlock(&pnp_lock); |
71 | 72 | ||
72 | protocol->number = nodenum; | 73 | protocol->number = nodenum; |
73 | dev_set_name(&protocol->dev, "pnp%d", nodenum); | 74 | dev_set_name(&protocol->dev, "pnp%d", nodenum); |
@@ -80,9 +81,9 @@ int pnp_register_protocol(struct pnp_protocol *protocol) | |||
80 | */ | 81 | */ |
81 | void pnp_unregister_protocol(struct pnp_protocol *protocol) | 82 | void pnp_unregister_protocol(struct pnp_protocol *protocol) |
82 | { | 83 | { |
83 | spin_lock(&pnp_lock); | 84 | mutex_lock(&pnp_lock); |
84 | list_del(&protocol->protocol_list); | 85 | list_del(&protocol->protocol_list); |
85 | spin_unlock(&pnp_lock); | 86 | mutex_unlock(&pnp_lock); |
86 | device_unregister(&protocol->dev); | 87 | device_unregister(&protocol->dev); |
87 | } | 88 | } |
88 | 89 | ||
@@ -161,10 +162,10 @@ int __pnp_add_device(struct pnp_dev *dev) | |||
161 | { | 162 | { |
162 | pnp_fixup_device(dev); | 163 | pnp_fixup_device(dev); |
163 | dev->status = PNP_READY; | 164 | dev->status = PNP_READY; |
164 | spin_lock(&pnp_lock); | 165 | mutex_lock(&pnp_lock); |
165 | list_add_tail(&dev->global_list, &pnp_global); | 166 | list_add_tail(&dev->global_list, &pnp_global); |
166 | list_add_tail(&dev->protocol_list, &dev->protocol->devices); | 167 | list_add_tail(&dev->protocol_list, &dev->protocol->devices); |
167 | spin_unlock(&pnp_lock); | 168 | mutex_unlock(&pnp_lock); |
168 | if (dev->protocol->can_wakeup) | 169 | if (dev->protocol->can_wakeup) |
169 | device_set_wakeup_capable(&dev->dev, | 170 | device_set_wakeup_capable(&dev->dev, |
170 | dev->protocol->can_wakeup(dev)); | 171 | dev->protocol->can_wakeup(dev)); |
@@ -203,10 +204,10 @@ int pnp_add_device(struct pnp_dev *dev) | |||
203 | 204 | ||
204 | void __pnp_remove_device(struct pnp_dev *dev) | 205 | void __pnp_remove_device(struct pnp_dev *dev) |
205 | { | 206 | { |
206 | spin_lock(&pnp_lock); | 207 | mutex_lock(&pnp_lock); |
207 | list_del(&dev->global_list); | 208 | list_del(&dev->global_list); |
208 | list_del(&dev->protocol_list); | 209 | list_del(&dev->protocol_list); |
209 | spin_unlock(&pnp_lock); | 210 | mutex_unlock(&pnp_lock); |
210 | device_unregister(&dev->dev); | 211 | device_unregister(&dev->dev); |
211 | } | 212 | } |
212 | 213 | ||
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index 4e57d3370368..153a493b5413 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c | |||
@@ -58,22 +58,22 @@ static const struct pnp_device_id *match_device(struct pnp_driver *drv, | |||
58 | 58 | ||
59 | int pnp_device_attach(struct pnp_dev *pnp_dev) | 59 | int pnp_device_attach(struct pnp_dev *pnp_dev) |
60 | { | 60 | { |
61 | spin_lock(&pnp_lock); | 61 | mutex_lock(&pnp_lock); |
62 | if (pnp_dev->status != PNP_READY) { | 62 | if (pnp_dev->status != PNP_READY) { |
63 | spin_unlock(&pnp_lock); | 63 | mutex_unlock(&pnp_lock); |
64 | return -EBUSY; | 64 | return -EBUSY; |
65 | } | 65 | } |
66 | pnp_dev->status = PNP_ATTACHED; | 66 | pnp_dev->status = PNP_ATTACHED; |
67 | spin_unlock(&pnp_lock); | 67 | mutex_unlock(&pnp_lock); |
68 | return 0; | 68 | return 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | void pnp_device_detach(struct pnp_dev *pnp_dev) | 71 | void pnp_device_detach(struct pnp_dev *pnp_dev) |
72 | { | 72 | { |
73 | spin_lock(&pnp_lock); | 73 | mutex_lock(&pnp_lock); |
74 | if (pnp_dev->status == PNP_ATTACHED) | 74 | if (pnp_dev->status == PNP_ATTACHED) |
75 | pnp_dev->status = PNP_READY; | 75 | pnp_dev->status = PNP_READY; |
76 | spin_unlock(&pnp_lock); | 76 | mutex_unlock(&pnp_lock); |
77 | pnp_disable_dev(pnp_dev); | 77 | pnp_disable_dev(pnp_dev); |
78 | } | 78 | } |
79 | 79 | ||