Commit 00431707 authored by Arjan van de Ven's avatar Arjan van de Ven Committed by Russell King

[ARM] Convert some arm semaphores to mutexes

The arm clock semaphores are strict mutexes, convert them to the new
mutex implementation
Signed-off-by: default avatarArjan van de Ven <arjan@infradead.org>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent f4619025
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/mutex.h>
#include <asm/rtc.h> #include <asm/rtc.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
...@@ -34,7 +35,7 @@ static unsigned long rtc_irq_data; ...@@ -34,7 +35,7 @@ static unsigned long rtc_irq_data;
/* /*
* rtc_sem protects rtc_inuse and rtc_ops * rtc_sem protects rtc_inuse and rtc_ops
*/ */
static DECLARE_MUTEX(rtc_sem); static DEFINE_MUTEX(rtc_mutex);
static unsigned long rtc_inuse; static unsigned long rtc_inuse;
static struct rtc_ops *rtc_ops; static struct rtc_ops *rtc_ops;
...@@ -355,7 +356,7 @@ static int rtc_open(struct inode *inode, struct file *file) ...@@ -355,7 +356,7 @@ static int rtc_open(struct inode *inode, struct file *file)
{ {
int ret; int ret;
down(&rtc_sem); mutex_lock(&rtc_mutex);
if (rtc_inuse) { if (rtc_inuse) {
ret = -EBUSY; ret = -EBUSY;
...@@ -373,7 +374,7 @@ static int rtc_open(struct inode *inode, struct file *file) ...@@ -373,7 +374,7 @@ static int rtc_open(struct inode *inode, struct file *file)
rtc_inuse = 1; rtc_inuse = 1;
} }
} }
up(&rtc_sem); mutex_unlock(&rtc_mutex);
return ret; return ret;
} }
...@@ -479,7 +480,7 @@ int register_rtc(struct rtc_ops *ops) ...@@ -479,7 +480,7 @@ int register_rtc(struct rtc_ops *ops)
{ {
int ret = -EBUSY; int ret = -EBUSY;
down(&rtc_sem); mutex_lock(&rtc_mutex);
if (rtc_ops == NULL) { if (rtc_ops == NULL) {
rtc_ops = ops; rtc_ops = ops;
...@@ -488,7 +489,7 @@ int register_rtc(struct rtc_ops *ops) ...@@ -488,7 +489,7 @@ int register_rtc(struct rtc_ops *ops)
create_proc_read_entry("driver/rtc", 0, NULL, create_proc_read_entry("driver/rtc", 0, NULL,
rtc_read_proc, ops); rtc_read_proc, ops);
} }
up(&rtc_sem); mutex_unlock(&rtc_mutex);
return ret; return ret;
} }
...@@ -496,12 +497,12 @@ EXPORT_SYMBOL(register_rtc); ...@@ -496,12 +497,12 @@ EXPORT_SYMBOL(register_rtc);
void unregister_rtc(struct rtc_ops *rtc) void unregister_rtc(struct rtc_ops *rtc)
{ {
down(&rtc_sem); mutex_lock(&rtc_mutex);
if (rtc == rtc_ops) { if (rtc == rtc_ops) {
remove_proc_entry("driver/rtc", NULL); remove_proc_entry("driver/rtc", NULL);
misc_deregister(&rtc_miscdev); misc_deregister(&rtc_miscdev);
rtc_ops = NULL; rtc_ops = NULL;
} }
up(&rtc_sem); mutex_unlock(&rtc_mutex);
} }
EXPORT_SYMBOL(unregister_rtc); EXPORT_SYMBOL(unregister_rtc);
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/mutex.h>
#include <asm/dma.h> #include <asm/dma.h>
#include <asm/ecard.h> #include <asm/ecard.h>
...@@ -206,7 +207,7 @@ static void ecard_task_readbytes(struct ecard_request *req) ...@@ -206,7 +207,7 @@ static void ecard_task_readbytes(struct ecard_request *req)
static DECLARE_WAIT_QUEUE_HEAD(ecard_wait); static DECLARE_WAIT_QUEUE_HEAD(ecard_wait);
static struct ecard_request *ecard_req; 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. * Set up the expansion card daemon's page tables.
...@@ -299,7 +300,7 @@ static void ecard_call(struct ecard_request *req) ...@@ -299,7 +300,7 @@ static void ecard_call(struct ecard_request *req)
req->complete = &completion; req->complete = &completion;
down(&ecard_sem); mutex_lock(&ecard_mutex);
ecard_req = req; ecard_req = req;
wake_up(&ecard_wait); wake_up(&ecard_wait);
...@@ -307,7 +308,7 @@ static void ecard_call(struct ecard_request *req) ...@@ -307,7 +308,7 @@ static void ecard_call(struct ecard_request *req)
* Now wait for kecardd to run. * Now wait for kecardd to run.
*/ */
wait_for_completion(&completion); wait_for_completion(&completion);
up(&ecard_sem); mutex_unlock(&ecard_mutex);
} }
/* ======================= Mid-level card control ===================== */ /* ======================= Mid-level card control ===================== */
......
...@@ -16,26 +16,27 @@ ...@@ -16,26 +16,27 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include "clock.h" #include "clock.h"
static LIST_HEAD(clocks); 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 *clk_get(struct device *dev, const char *id)
{ {
struct clk *p, *clk = ERR_PTR(-ENOENT); struct clk *p, *clk = ERR_PTR(-ENOENT);
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) { list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p; clk = p;
break; break;
} }
} }
up(&clocks_sem); mutex_unlock(&clocks_mutex);
return clk; return clk;
} }
...@@ -78,18 +79,18 @@ EXPORT_SYMBOL(clk_set_rate); ...@@ -78,18 +79,18 @@ EXPORT_SYMBOL(clk_set_rate);
int clk_register(struct clk *clk) int clk_register(struct clk *clk)
{ {
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_add(&clk->node, &clocks); list_add(&clk->node, &clocks);
up(&clocks_sem); mutex_unlock(&clocks_mutex);
return 0; return 0;
} }
EXPORT_SYMBOL(clk_register); EXPORT_SYMBOL(clk_register);
void clk_unregister(struct clk *clk) void clk_unregister(struct clk *clk)
{ {
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_del(&clk->node); list_del(&clk->node);
up(&clocks_sem); mutex_unlock(&clocks_mutex);
} }
EXPORT_SYMBOL(clk_unregister); EXPORT_SYMBOL(clk_unregister);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/hardware/icst525.h> #include <asm/hardware/icst525.h>
...@@ -22,20 +23,20 @@ ...@@ -22,20 +23,20 @@
#include "clock.h" #include "clock.h"
static LIST_HEAD(clocks); 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 *clk_get(struct device *dev, const char *id)
{ {
struct clk *p, *clk = ERR_PTR(-ENOENT); struct clk *p, *clk = ERR_PTR(-ENOENT);
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) { list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p; clk = p;
break; break;
} }
} }
up(&clocks_sem); mutex_unlock(&clocks_mutex);
return clk; return clk;
} }
...@@ -107,18 +108,18 @@ static struct clk uart_clk = { ...@@ -107,18 +108,18 @@ static struct clk uart_clk = {
int clk_register(struct clk *clk) int clk_register(struct clk *clk)
{ {
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_add(&clk->node, &clocks); list_add(&clk->node, &clocks);
up(&clocks_sem); mutex_unlock(&clocks_mutex);
return 0; return 0;
} }
EXPORT_SYMBOL(clk_register); EXPORT_SYMBOL(clk_register);
void clk_unregister(struct clk *clk) void clk_unregister(struct clk *clk)
{ {
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_del(&clk->node); list_del(&clk->node);
up(&clocks_sem); mutex_unlock(&clocks_mutex);
} }
EXPORT_SYMBOL(clk_unregister); EXPORT_SYMBOL(clk_unregister);
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/mutex.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/hardware.h> #include <asm/hardware.h>
...@@ -59,7 +60,7 @@ static const struct ssp_info_ ssp_info[PXA_SSP_PORTS] = { ...@@ -59,7 +60,7 @@ static const struct ssp_info_ ssp_info[PXA_SSP_PORTS] = {
#endif #endif
}; };
static DECLARE_MUTEX(sem); static DEFINE_MUTEX(mutex);
static int use_count[PXA_SSP_PORTS] = {0, 0, 0}; static int use_count[PXA_SSP_PORTS] = {0, 0, 0};
static irqreturn_t ssp_interrupt(int irq, void *dev_id, struct pt_regs *regs) 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) ...@@ -239,16 +240,16 @@ int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags)
if (port > PXA_SSP_PORTS || port == 0) if (port > PXA_SSP_PORTS || port == 0)
return -ENODEV; return -ENODEV;
down(&sem); mutex_lock(&mutex);
if (use_count[port - 1]) { if (use_count[port - 1]) {
up(&sem); mutex_unlock(&mutex);
return -EBUSY; return -EBUSY;
} }
use_count[port - 1]++; use_count[port - 1]++;
if (!request_mem_region(__PREG(SSCR0_P(port)), 0x2c, "SSP")) { if (!request_mem_region(__PREG(SSCR0_P(port)), 0x2c, "SSP")) {
use_count[port - 1]--; use_count[port - 1]--;
up(&sem); mutex_unlock(&mutex);
return -EBUSY; return -EBUSY;
} }
dev->port = port; dev->port = port;
...@@ -265,13 +266,13 @@ int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags) ...@@ -265,13 +266,13 @@ int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags)
/* turn on SSP port clock */ /* turn on SSP port clock */
pxa_set_cken(ssp_info[port-1].clock, 1); pxa_set_cken(ssp_info[port-1].clock, 1);
up(&sem); mutex_unlock(&mutex);
return 0; return 0;
out_region: out_region:
release_mem_region(__PREG(SSCR0_P(port)), 0x2c); release_mem_region(__PREG(SSCR0_P(port)), 0x2c);
use_count[port - 1]--; use_count[port - 1]--;
up(&sem); mutex_unlock(&mutex);
return ret; return ret;
} }
...@@ -282,7 +283,7 @@ int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags) ...@@ -282,7 +283,7 @@ int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags)
*/ */
void ssp_exit(struct ssp_dev *dev) void ssp_exit(struct ssp_dev *dev)
{ {
down(&sem); mutex_lock(&mutex);
SSCR0_P(dev->port) &= ~SSCR0_SSE; SSCR0_P(dev->port) &= ~SSCR0_SSE;
if (dev->port > PXA_SSP_PORTS || dev->port == 0) { if (dev->port > PXA_SSP_PORTS || dev->port == 0) {
...@@ -295,7 +296,7 @@ void ssp_exit(struct ssp_dev *dev) ...@@ -295,7 +296,7 @@ void ssp_exit(struct ssp_dev *dev)
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
release_mem_region(__PREG(SSCR0_P(dev->port)), 0x2c); release_mem_region(__PREG(SSCR0_P(dev->port)), 0x2c);
use_count[dev->port - 1]--; use_count[dev->port - 1]--;
up(&sem); mutex_unlock(&mutex);
} }
EXPORT_SYMBOL(ssp_write_word); EXPORT_SYMBOL(ssp_write_word);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/hardware/icst307.h> #include <asm/hardware/icst307.h>
...@@ -21,20 +22,20 @@ ...@@ -21,20 +22,20 @@
#include "clock.h" #include "clock.h"
static LIST_HEAD(clocks); 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 *clk_get(struct device *dev, const char *id)
{ {
struct clk *p, *clk = ERR_PTR(-ENOENT); struct clk *p, *clk = ERR_PTR(-ENOENT);
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) { list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p; clk = p;
break; break;
} }
} }
up(&clocks_sem); mutex_unlock(&clocks_mutex);
return clk; return clk;
} }
...@@ -109,18 +110,18 @@ static struct clk mmci_clk = { ...@@ -109,18 +110,18 @@ static struct clk mmci_clk = {
int clk_register(struct clk *clk) int clk_register(struct clk *clk)
{ {
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_add(&clk->node, &clocks); list_add(&clk->node, &clocks);
up(&clocks_sem); mutex_unlock(&clocks_mutex);
return 0; return 0;
} }
EXPORT_SYMBOL(clk_register); EXPORT_SYMBOL(clk_register);
void clk_unregister(struct clk *clk) void clk_unregister(struct clk *clk)
{ {
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_del(&clk->node); list_del(&clk->node);
up(&clocks_sem); mutex_unlock(&clocks_mutex);
} }
EXPORT_SYMBOL(clk_unregister); EXPORT_SYMBOL(clk_unregister);
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/hardware.h> #include <asm/hardware.h>
#include <asm/atomic.h> #include <asm/atomic.h>
...@@ -51,7 +52,7 @@ ...@@ -51,7 +52,7 @@
/* clock information */ /* clock information */
static LIST_HEAD(clocks); static LIST_HEAD(clocks);
static DECLARE_MUTEX(clocks_sem); static DEFINE_MUTEX(clocks_mutex);
/* old functions */ /* old functions */
...@@ -102,7 +103,7 @@ struct clk *clk_get(struct device *dev, const char *id) ...@@ -102,7 +103,7 @@ struct clk *clk_get(struct device *dev, const char *id)
else else
idno = to_platform_device(dev)->id; idno = to_platform_device(dev)->id;
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, list) { list_for_each_entry(p, &clocks, list) {
if (p->id == idno && if (p->id == idno &&
...@@ -126,7 +127,7 @@ struct clk *clk_get(struct device *dev, const char *id) ...@@ -126,7 +127,7 @@ struct clk *clk_get(struct device *dev, const char *id)
} }
} }
up(&clocks_sem); mutex_unlock(&clocks_mutex);
return clk; return clk;
} }
...@@ -362,9 +363,9 @@ int s3c24xx_register_clock(struct clk *clk) ...@@ -362,9 +363,9 @@ int s3c24xx_register_clock(struct clk *clk)
/* add to the list of available clocks */ /* add to the list of available clocks */
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_add(&clk->list, &clocks); list_add(&clk->list, &clocks);
up(&clocks_sem); mutex_unlock(&clocks_mutex);
return 0; return 0;
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/hardware/icst307.h> #include <asm/hardware/icst307.h>
...@@ -22,20 +23,20 @@ ...@@ -22,20 +23,20 @@
#include "clock.h" #include "clock.h"
static LIST_HEAD(clocks); 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 *clk_get(struct device *dev, const char *id)
{ {
struct clk *p, *clk = ERR_PTR(-ENOENT); struct clk *p, *clk = ERR_PTR(-ENOENT);
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) { list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p; clk = p;
break; break;
} }
} }
up(&clocks_sem); mutex_unlock(&clocks_mutex);
return clk; return clk;
} }
...@@ -110,18 +111,18 @@ static struct clk mmci_clk = { ...@@ -110,18 +111,18 @@ static struct clk mmci_clk = {
int clk_register(struct clk *clk) int clk_register(struct clk *clk)
{ {
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_add(&clk->node, &clocks); list_add(&clk->node, &clocks);
up(&clocks_sem); mutex_unlock(&clocks_mutex);
return 0; return 0;
} }
EXPORT_SYMBOL(clk_register); EXPORT_SYMBOL(clk_register);
void clk_unregister(struct clk *clk) void clk_unregister(struct clk *clk)
{ {
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_del(&clk->node); list_del(&clk->node);
up(&clocks_sem); mutex_unlock(&clocks_mutex);
} }
EXPORT_SYMBOL(clk_unregister); EXPORT_SYMBOL(clk_unregister);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
...@@ -27,7 +28,7 @@ ...@@ -27,7 +28,7 @@
#include <asm/arch/clock.h> #include <asm/arch/clock.h>
LIST_HEAD(clocks); LIST_HEAD(clocks);
static DECLARE_MUTEX(clocks_sem); static DEFINE_MUTEX(clocks_mutex);
DEFINE_SPINLOCK(clockfw_lock); DEFINE_SPINLOCK(clockfw_lock);
static struct clk_functions *arch_clock; static struct clk_functions *arch_clock;
...@@ -40,14 +41,14 @@ struct clk * clk_get(struct device *dev, const char *id) ...@@ -40,14 +41,14 @@ struct clk * clk_get(struct device *dev, const char *id)
{ {
struct clk *p, *clk = ERR_PTR(-ENOENT); struct clk *p, *clk = ERR_PTR(-ENOENT);
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) { list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p; clk = p;
break; break;
} }
} }
up(&clocks_sem); mutex_unlock(&clocks_mutex);
return clk; return clk;
} }
...@@ -249,11 +250,11 @@ void propagate_rate(struct clk * tclk) ...@@ -249,11 +250,11 @@ void propagate_rate(struct clk * tclk)
int clk_register(struct clk *clk) int clk_register(struct clk *clk)
{ {
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_add(&clk->node, &clocks); list_add(&clk->node, &clocks);
if (clk->init) if (clk->init)
clk->init(clk); clk->init(clk);
up(&clocks_sem); mutex_unlock(&clocks_mutex);
return 0; return 0;
} }
...@@ -261,9 +262,9 @@ EXPORT_SYMBOL(clk_register); ...@@ -261,9 +262,9 @@ EXPORT_SYMBOL(clk_register);
void clk_unregister(struct clk *clk) void clk_unregister(struct clk *clk)
{ {
down(&clocks_sem); mutex_lock(&clocks_mutex);
list_del(&clk->node); list_del(&clk->node);
up(&clocks_sem); mutex_unlock(&clocks_mutex);
} }
EXPORT_SYMBOL(clk_unregister); EXPORT_SYMBOL(clk_unregister);
......
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