blob: 677f6dcbb09cdae1e4ee624bc0624dd4848e7d3f [file] [log] [blame]
From 8dbc7a12cfa50a6a9d0c86f1dcf520682446039c Mon Sep 17 00:00:00 2001
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sun, 26 Jul 2009 00:11:46 +0200
Subject: [PATCH] drivers/base: Convert dev->sem to mutex
commit 97dd538e3998fcada84d8106a4d974fdab729cb1 in tip.
The semaphore is used as mutex so make it a mutex.
[PG: upstream abstraction of all users in 8e9394ce2412 drastically
reduces the footprint of this vs. the original tip commit.]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
diff --git a/drivers/base/core.c b/drivers/base/core.c
index ef55df3..09c10e9 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -20,7 +20,6 @@
#include <linux/notifier.h>
#include <linux/genhd.h>
#include <linux/kallsyms.h>
-#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/async.h>
@@ -559,7 +558,7 @@ void device_initialize(struct device *dev)
dev->kobj.kset = devices_kset;
kobject_init(&dev->kobj, &device_ktype);
INIT_LIST_HEAD(&dev->dma_pools);
- init_MUTEX(&dev->sem);
+ mutex_init(&dev->mutex);
spin_lock_init(&dev->devres_lock);
INIT_LIST_HEAD(&dev->devres_head);
device_init_wakeup(dev, 0);
diff --git a/include/linux/device.h b/include/linux/device.h
index 1821928..d0fd2b4 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -22,7 +22,6 @@
#include <linux/types.h>
#include <linux/module.h>
#include <linux/pm.h>
-#include <linux/semaphore.h>
#include <asm/atomic.h>
#include <asm/device.h>
@@ -404,7 +403,7 @@ struct device {
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
* its driver.
*/
@@ -510,17 +509,17 @@ static inline bool device_async_suspend_enabled(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)
{
- return down_trylock(&dev->sem);
+ return !mutex_trylock(&dev->mutex);
}
static inline void device_unlock(struct device *dev)
{
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
}
void driver_init(void);
--
1.7.1.1