Commit 3142788b authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Greg Kroah-Hartman

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: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 190e8370
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/genhd.h> #include <linux/genhd.h>
#include <linux/kallsyms.h> #include <linux/kallsyms.h>
#include <linux/semaphore.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/async.h> #include <linux/async.h>
...@@ -559,7 +558,7 @@ void device_initialize(struct device *dev) ...@@ -559,7 +558,7 @@ void device_initialize(struct device *dev)
dev->kobj.kset = devices_kset; dev->kobj.kset = devices_kset;
kobject_init(&dev->kobj, &device_ktype); kobject_init(&dev->kobj, &device_ktype);
INIT_LIST_HEAD(&dev->dma_pools); INIT_LIST_HEAD(&dev->dma_pools);
init_MUTEX(&dev->sem); mutex_init(&dev->mutex);
spin_lock_init(&dev->devres_lock); spin_lock_init(&dev->devres_lock);
INIT_LIST_HEAD(&dev->devres_head); INIT_LIST_HEAD(&dev->devres_head);
device_pm_init(dev); device_pm_init(dev);
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/radix-tree.h> #include <linux/radix-tree.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/semaphore.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/mlx4/device.h> #include <linux/mlx4/device.h>
......
...@@ -48,6 +48,7 @@ Devices: [Quatech] DAQP-208 (daqp), DAQP-308 ...@@ -48,6 +48,7 @@ Devices: [Quatech] DAQP-208 (daqp), DAQP-308
*/ */
#include "../comedidev.h" #include "../comedidev.h"
#include <linux/semaphore.h>
#include <pcmcia/cs_types.h> #include <pcmcia/cs_types.h>
#include <pcmcia/cs.h> #include <pcmcia/cs.h>
......
...@@ -573,7 +573,7 @@ int usb_lock_device_for_reset(struct usb_device *udev, ...@@ -573,7 +573,7 @@ int usb_lock_device_for_reset(struct usb_device *udev,
iface->condition == USB_INTERFACE_UNBOUND)) iface->condition == USB_INTERFACE_UNBOUND))
return -EINTR; return -EINTR;
while (usb_trylock_device(udev) != 0) { while (!usb_trylock_device(udev)) {
/* If we can't acquire the lock after waiting one second, /* If we can't acquire the lock after waiting one second,
* we're probably deadlocked */ * we're probably deadlocked */
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/semaphore.h>
#include <asm/atomic.h> #include <asm/atomic.h>
#include <asm/device.h> #include <asm/device.h>
...@@ -404,7 +403,7 @@ struct device { ...@@ -404,7 +403,7 @@ struct device {
const char *init_name; /* initial name of the device */ const char *init_name; /* initial name of the device */
struct device_type *type; struct device_type *type;
struct semaphore sem; /* semaphore to synchronize calls to struct mutex mutex; /* mutex to synchronize calls to
* its driver. * its driver.
*/ */
...@@ -514,17 +513,17 @@ static inline bool device_async_suspend_enabled(struct device *dev) ...@@ -514,17 +513,17 @@ static inline bool device_async_suspend_enabled(struct device *dev)
static inline void device_lock(struct device *dev) static inline void device_lock(struct device *dev)
{ {
down(&dev->sem); mutex_lock(&dev->mutex);
} }
static inline int device_trylock(struct device *dev) static inline int device_trylock(struct device *dev)
{ {
return down_trylock(&dev->sem); return mutex_trylock(&dev->mutex);
} }
static inline void device_unlock(struct device *dev) static inline void device_unlock(struct device *dev)
{ {
up(&dev->sem); mutex_unlock(&dev->mutex);
} }
void driver_init(void); void driver_init(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment