[ARM] Convert some arm semaphores to mutexes

The arm clock semaphores are strict mutexes, convert them to the new
mutex implementation

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
Arjan van de Ven 2006-01-12 18:42:23 +00:00 committed by Russell King
parent f4619025a5
commit 00431707be
9 changed files with 67 additions and 58 deletions

View File

@ -18,6 +18,7 @@
#include <linux/miscdevice.h>
#include <linux/spinlock.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <asm/rtc.h>
#include <asm/semaphore.h>
@ -34,7 +35,7 @@ static unsigned long rtc_irq_data;
/*
* rtc_sem protects rtc_inuse and rtc_ops
*/
static DECLARE_MUTEX(rtc_sem);
static DEFINE_MUTEX(rtc_mutex);
static unsigned long rtc_inuse;
static struct rtc_ops *rtc_ops;
@ -355,7 +356,7 @@ static int rtc_open(struct inode *inode, struct file *file)
{
int ret;
down(&rtc_sem);
mutex_lock(&rtc_mutex);
if (rtc_inuse) {
ret = -EBUSY;
@ -373,7 +374,7 @@ static int rtc_open(struct inode *inode, struct file *file)
rtc_inuse = 1;
}
}
up(&rtc_sem);
mutex_unlock(&rtc_mutex);
return ret;
}
@ -479,7 +480,7 @@ int register_rtc(struct rtc_ops *ops)
{
int ret = -EBUSY;
down(&rtc_sem);
mutex_lock(&rtc_mutex);
if (rtc_ops == NULL) {
rtc_ops = ops;
@ -488,7 +489,7 @@ int register_rtc(struct rtc_ops *ops)
create_proc_read_entry("driver/rtc", 0, NULL,
rtc_read_proc, ops);
}
up(&rtc_sem);
mutex_unlock(&rtc_mutex);
return ret;
}
@ -496,12 +497,12 @@ EXPORT_SYMBOL(register_rtc);
void unregister_rtc(struct rtc_ops *rtc)
{
down(&rtc_sem);
mutex_lock(&rtc_mutex);
if (rtc == rtc_ops) {
remove_proc_entry("driver/rtc", NULL);
misc_deregister(&rtc_miscdev);
rtc_ops = NULL;
}
up(&rtc_sem);
mutex_unlock(&rtc_mutex);
}
EXPORT_SYMBOL(unregister_rtc);

View File

@ -40,6 +40,7 @@
#include <linux/proc_fs.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/mutex.h>
#include <asm/dma.h>
#include <asm/ecard.h>
@ -206,7 +207,7 @@ static void ecard_task_readbytes(struct ecard_request *req)
static DECLARE_WAIT_QUEUE_HEAD(ecard_wait);
static struct ecard_request *ecard_req;
static DECLARE_MUTEX(ecard_sem);
static DEFINE_MUTEX(ecard_mutex);
/*
* Set up the expansion card daemon's page tables.
@ -299,7 +300,7 @@ static void ecard_call(struct ecard_request *req)
req->complete = &completion;
down(&ecard_sem);
mutex_lock(&ecard_mutex);
ecard_req = req;
wake_up(&ecard_wait);
@ -307,7 +308,7 @@ static void ecard_call(struct ecard_request *req)
* Now wait for kecardd to run.
*/
wait_for_completion(&completion);
up(&ecard_sem);
mutex_unlock(&ecard_mutex);
}
/* ======================= Mid-level card control ===================== */

View File

@ -16,26 +16,27 @@
#include <linux/err.h>
#include <linux/string.h>
#include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/semaphore.h>
#include "clock.h"
static LIST_HEAD(clocks);
static DECLARE_MUTEX(clocks_sem);
static DEFINE_MUTEX(clocks_mutex);
struct clk *clk_get(struct device *dev, const char *id)
{
struct clk *p, *clk = ERR_PTR(-ENOENT);
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p;
break;
}
}
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
return clk;
}
@ -78,18 +79,18 @@ EXPORT_SYMBOL(clk_set_rate);
int clk_register(struct clk *clk)
{
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_add(&clk->node, &clocks);
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
return 0;
}
EXPORT_SYMBOL(clk_register);
void clk_unregister(struct clk *clk)
{
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_del(&clk->node);
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
}
EXPORT_SYMBOL(clk_unregister);

View File

@ -15,6 +15,7 @@
#include <linux/err.h>
#include <linux/string.h>
#include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/semaphore.h>
#include <asm/hardware/icst525.h>
@ -22,20 +23,20 @@
#include "clock.h"
static LIST_HEAD(clocks);
static DECLARE_MUTEX(clocks_sem);
static DEFINE_MUTEX(clocks_mutex);
struct clk *clk_get(struct device *dev, const char *id)
{
struct clk *p, *clk = ERR_PTR(-ENOENT);
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p;
break;
}
}
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
return clk;
}
@ -107,18 +108,18 @@ static struct clk uart_clk = {
int clk_register(struct clk *clk)
{
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_add(&clk->node, &clocks);
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
return 0;
}
EXPORT_SYMBOL(clk_register);
void clk_unregister(struct clk *clk)
{
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_del(&clk->node);
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
}
EXPORT_SYMBOL(clk_unregister);

View File

@ -31,6 +31,7 @@
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/init.h>
#include <linux/mutex.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/hardware.h>
@ -59,7 +60,7 @@ static const struct ssp_info_ ssp_info[PXA_SSP_PORTS] = {
#endif
};
static DECLARE_MUTEX(sem);
static DEFINE_MUTEX(mutex);
static int use_count[PXA_SSP_PORTS] = {0, 0, 0};
static irqreturn_t ssp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
@ -239,16 +240,16 @@ int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags)
if (port > PXA_SSP_PORTS || port == 0)
return -ENODEV;
down(&sem);
mutex_lock(&mutex);
if (use_count[port - 1]) {
up(&sem);
mutex_unlock(&mutex);
return -EBUSY;
}
use_count[port - 1]++;
if (!request_mem_region(__PREG(SSCR0_P(port)), 0x2c, "SSP")) {
use_count[port - 1]--;
up(&sem);
mutex_unlock(&mutex);
return -EBUSY;
}
dev->port = port;
@ -265,13 +266,13 @@ int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags)
/* turn on SSP port clock */
pxa_set_cken(ssp_info[port-1].clock, 1);
up(&sem);
mutex_unlock(&mutex);
return 0;
out_region:
release_mem_region(__PREG(SSCR0_P(port)), 0x2c);
use_count[port - 1]--;
up(&sem);
mutex_unlock(&mutex);
return ret;
}
@ -282,7 +283,7 @@ out_region:
*/
void ssp_exit(struct ssp_dev *dev)
{
down(&sem);
mutex_lock(&mutex);
SSCR0_P(dev->port) &= ~SSCR0_SSE;
if (dev->port > PXA_SSP_PORTS || dev->port == 0) {
@ -295,7 +296,7 @@ void ssp_exit(struct ssp_dev *dev)
free_irq(dev->irq, dev);
release_mem_region(__PREG(SSCR0_P(dev->port)), 0x2c);
use_count[dev->port - 1]--;
up(&sem);
mutex_unlock(&mutex);
}
EXPORT_SYMBOL(ssp_write_word);

View File

@ -14,6 +14,7 @@
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/semaphore.h>
#include <asm/hardware/icst307.h>
@ -21,20 +22,20 @@
#include "clock.h"
static LIST_HEAD(clocks);
static DECLARE_MUTEX(clocks_sem);
static DEFINE_MUTEX(clocks_mutex);
struct clk *clk_get(struct device *dev, const char *id)
{
struct clk *p, *clk = ERR_PTR(-ENOENT);
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p;
break;
}
}
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
return clk;
}
@ -109,18 +110,18 @@ static struct clk mmci_clk = {
int clk_register(struct clk *clk)
{
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_add(&clk->node, &clocks);
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
return 0;
}
EXPORT_SYMBOL(clk_register);
void clk_unregister(struct clk *clk)
{
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_del(&clk->node);
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
}
EXPORT_SYMBOL(clk_unregister);

View File

@ -37,6 +37,7 @@
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/hardware.h>
#include <asm/atomic.h>
@ -51,7 +52,7 @@
/* clock information */
static LIST_HEAD(clocks);
static DECLARE_MUTEX(clocks_sem);
static DEFINE_MUTEX(clocks_mutex);
/* old functions */
@ -102,7 +103,7 @@ struct clk *clk_get(struct device *dev, const char *id)
else
idno = to_platform_device(dev)->id;
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, list) {
if (p->id == idno &&
@ -126,7 +127,7 @@ struct clk *clk_get(struct device *dev, const char *id)
}
}
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
return clk;
}
@ -362,9 +363,9 @@ int s3c24xx_register_clock(struct clk *clk)
/* add to the list of available clocks */
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_add(&clk->list, &clocks);
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
return 0;
}

View File

@ -15,6 +15,7 @@
#include <linux/err.h>
#include <linux/string.h>
#include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/semaphore.h>
#include <asm/hardware/icst307.h>
@ -22,20 +23,20 @@
#include "clock.h"
static LIST_HEAD(clocks);
static DECLARE_MUTEX(clocks_sem);
static DEFINE_MUTEX(clocks_mutex);
struct clk *clk_get(struct device *dev, const char *id)
{
struct clk *p, *clk = ERR_PTR(-ENOENT);
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p;
break;
}
}
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
return clk;
}
@ -110,18 +111,18 @@ static struct clk mmci_clk = {
int clk_register(struct clk *clk)
{
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_add(&clk->node, &clocks);
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
return 0;
}
EXPORT_SYMBOL(clk_register);
void clk_unregister(struct clk *clk)
{
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_del(&clk->node);
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
}
EXPORT_SYMBOL(clk_unregister);

View File

@ -20,6 +20,7 @@
#include <linux/err.h>
#include <linux/string.h>
#include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/io.h>
#include <asm/semaphore.h>
@ -27,7 +28,7 @@
#include <asm/arch/clock.h>
LIST_HEAD(clocks);
static DECLARE_MUTEX(clocks_sem);
static DEFINE_MUTEX(clocks_mutex);
DEFINE_SPINLOCK(clockfw_lock);
static struct clk_functions *arch_clock;
@ -40,14 +41,14 @@ struct clk * clk_get(struct device *dev, const char *id)
{
struct clk *p, *clk = ERR_PTR(-ENOENT);
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p;
break;
}
}
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
return clk;
}
@ -249,11 +250,11 @@ void propagate_rate(struct clk * tclk)
int clk_register(struct clk *clk)
{
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_add(&clk->node, &clocks);
if (clk->init)
clk->init(clk);
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
return 0;
}
@ -261,9 +262,9 @@ EXPORT_SYMBOL(clk_register);
void clk_unregister(struct clk *clk)
{
down(&clocks_sem);
mutex_lock(&clocks_mutex);
list_del(&clk->node);
up(&clocks_sem);
mutex_unlock(&clocks_mutex);
}
EXPORT_SYMBOL(clk_unregister);