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>
#include <linux/notifier.h>
#include <linux/genhd.h>
#include <linux/kallsyms.h>
#include <linux/notifier.h>
#include <linux/genhd.h>
#include <linux/kallsyms.h>
-#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/async.h>
#include <linux/mutex.h>
#include <linux/async.h>
dev->kobj.kset = devices_kset;
kobject_init(&dev->kobj, &device_ktype);
INIT_LIST_HEAD(&dev->dma_pools);
dev->kobj.kset = devices_kset;
kobject_init(&dev->kobj, &device_ktype);
INIT_LIST_HEAD(&dev->dma_pools);
+ mutex_init(&dev->mutex);
spin_lock_init(&dev->devres_lock);
INIT_LIST_HEAD(&dev->devres_head);
device_pm_init(dev);
spin_lock_init(&dev->devres_lock);
INIT_LIST_HEAD(&dev->devres_head);
device_pm_init(dev);
#include <linux/mutex.h>
#include <linux/radix-tree.h>
#include <linux/timer.h>
#include <linux/mutex.h>
#include <linux/radix-tree.h>
#include <linux/timer.h>
+#include <linux/semaphore.h>
#include <linux/workqueue.h>
#include <linux/mlx4/device.h>
#include <linux/workqueue.h>
#include <linux/mlx4/device.h>
*/
#include "../comedidev.h"
*/
#include "../comedidev.h"
+#include <linux/semaphore.h>
#include <pcmcia/cs_types.h>
#include <pcmcia/cs.h>
#include <pcmcia/cs_types.h>
#include <pcmcia/cs.h>
iface->condition == USB_INTERFACE_UNBOUND))
return -EINTR;
iface->condition == USB_INTERFACE_UNBOUND))
return -EINTR;
- while (usb_trylock_device(udev) != 0) {
+ while (!usb_trylock_device(udev)) {
/* If we can't acquire the lock after waiting one second,
* we're probably deadlocked */
/* If we can't acquire the lock after waiting one second,
* we're probably deadlocked */
#include <linux/types.h>
#include <linux/module.h>
#include <linux/pm.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/pm.h>
-#include <linux/semaphore.h>
#include <asm/atomic.h>
#include <asm/device.h>
#include <asm/atomic.h>
#include <asm/device.h>
const char *init_name; /* initial name of the device */
struct device_type *type;
const char *init_name; /* initial name of the device */
struct device_type *type;
- struct semaphore sem; /* semaphore to synchronize calls to
+ struct mutex mutex; /* mutex to synchronize calls to
static inline void device_lock(struct device *dev)
{
static inline void device_lock(struct device *dev)
{
+ 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)
{
+ mutex_unlock(&dev->mutex);
}
void driver_init(void);
}
void driver_init(void);