aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2010-01-29 15:39:02 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-21 12:37:30 -0400
commit3142788b7967ccfd2f1813ee9e11aeb1e1cf7de2 (patch)
tree292a6e3a21e237789c91a8d0ccd021321990a265
parent190e8370b8033f746db5289e9324174564a6f5a7 (diff)
drivers/base: Convert dev->sem to mutex
The semaphore is semantically a mutex. Convert it to a real mutex and fix up a few places where code was relying on semaphore.h to be included by device.h, as well as the users of the trylock function, as that value is now reversed. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/base/core.c3
-rw-r--r--drivers/net/mlx4/mlx4.h1
-rw-r--r--drivers/staging/comedi/drivers/quatech_daqp_cs.c1
-rw-r--r--drivers/usb/core/usb.c2
-rw-r--r--include/linux/device.h9
5 files changed, 8 insertions, 8 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index e11c8c3e7416..cf507a7d200c 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -20,7 +20,6 @@
20#include <linux/notifier.h> 20#include <linux/notifier.h>
21#include <linux/genhd.h> 21#include <linux/genhd.h>
22#include <linux/kallsyms.h> 22#include <linux/kallsyms.h>
23#include <linux/semaphore.h>
24#include <linux/mutex.h> 23#include <linux/mutex.h>
25#include <linux/async.h> 24#include <linux/async.h>
26 25
@@ -559,7 +558,7 @@ void device_initialize(struct device *dev)
559 dev->kobj.kset = devices_kset; 558 dev->kobj.kset = devices_kset;
560 kobject_init(&dev->kobj, &device_ktype); 559 kobject_init(&dev->kobj, &device_ktype);
561 INIT_LIST_HEAD(&dev->dma_pools); 560 INIT_LIST_HEAD(&dev->dma_pools);
562 init_MUTEX(&dev->sem); 561 mutex_init(&dev->mutex);
563 spin_lock_init(&dev->devres_lock); 562 spin_lock_init(&dev->devres_lock);
564 INIT_LIST_HEAD(&dev->devres_head); 563 INIT_LIST_HEAD(&dev->devres_head);
565 device_pm_init(dev); 564 device_pm_init(dev);
diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h
index bc72d6e4919b..13343e884999 100644
--- a/drivers/net/mlx4/mlx4.h
+++ b/drivers/net/mlx4/mlx4.h
@@ -40,6 +40,7 @@
40#include <linux/mutex.h> 40#include <linux/mutex.h>
41#include <linux/radix-tree.h> 41#include <linux/radix-tree.h>
42#include <linux/timer.h> 42#include <linux/timer.h>
43#include <linux/semaphore.h>
43#include <linux/workqueue.h> 44#include <linux/workqueue.h>
44 45
45#include <linux/mlx4/device.h> 46#include <linux/mlx4/device.h>
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index 1786db2f3378..8b274b708259 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -48,6 +48,7 @@ Devices: [Quatech] DAQP-208 (daqp), DAQP-308
48*/ 48*/
49 49
50#include "../comedidev.h" 50#include "../comedidev.h"
51#include <linux/semaphore.h>
51 52
52#include <pcmcia/cs_types.h> 53#include <pcmcia/cs_types.h>
53#include <pcmcia/cs.h> 54#include <pcmcia/cs.h>
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 397b678f1c47..5ae14f6c1e7a 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -573,7 +573,7 @@ int usb_lock_device_for_reset(struct usb_device *udev,
573 iface->condition == USB_INTERFACE_UNBOUND)) 573 iface->condition == USB_INTERFACE_UNBOUND))
574 return -EINTR; 574 return -EINTR;
575 575
576 while (usb_trylock_device(udev) != 0) { 576 while (!usb_trylock_device(udev)) {
577 577
578 /* If we can't acquire the lock after waiting one second, 578 /* If we can't acquire the lock after waiting one second,
579 * we're probably deadlocked */ 579 * we're probably deadlocked */
diff --git a/include/linux/device.h b/include/linux/device.h
index 241b96bcd7ad..6f9619190aaf 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -22,7 +22,6 @@
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/pm.h> 24#include <linux/pm.h>
25#include <linux/semaphore.h>
26#include <asm/atomic.h> 25#include <asm/atomic.h>
27#include <asm/device.h> 26#include <asm/device.h>
28 27
@@ -404,7 +403,7 @@ struct device {
404 const char *init_name; /* initial name of the device */ 403 const char *init_name; /* initial name of the device */
405 struct device_type *type; 404 struct device_type *type;
406 405
407 struct semaphore sem; /* semaphore to synchronize calls to 406 struct mutex mutex; /* mutex to synchronize calls to
408 * its driver. 407 * its driver.
409 */ 408 */
410 409
@@ -514,17 +513,17 @@ static inline bool device_async_suspend_enabled(struct device *dev)
514 513
515static inline void device_lock(struct device *dev) 514static inline void device_lock(struct device *dev)
516{ 515{
517 down(&dev->sem); 516 mutex_lock(&dev->mutex);
518} 517}
519 518
520static inline int device_trylock(struct device *dev) 519static inline int device_trylock(struct device *dev)
521{ 520{
522 return down_trylock(&dev->sem); 521 return mutex_trylock(&dev->mutex);
523} 522}
524 523
525static inline void device_unlock(struct device *dev) 524static inline void device_unlock(struct device *dev)
526{ 525{
527 up(&dev->sem); 526 mutex_unlock(&dev->mutex);
528} 527}
529 528
530void driver_init(void); 529void driver_init(void);