Skip to content

Commit

Permalink
[ARM] sa1100: use mutexes rather than semaphores
Browse files Browse the repository at this point in the history
Use a mutex in the sa1100 clock support rather than a semaphore.
Remove the unused "module" field.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Russell King authored and Russell King committed Apr 22, 2007
1 parent 235b185 commit d0a9d75
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions arch/arm/mach-sa1100/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,46 @@
#include <linux/string.h>
#include <linux/clk.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>

#include <asm/hardware.h>
#include <asm/semaphore.h>

/*
* Very simple clock implementation - we only have one clock to
* deal with at the moment, so we only match using the "name".
*/
struct clk {
struct list_head node;
unsigned long rate;
struct module *owner;
const char *name;
unsigned int enabled;
void (*enable)(void);
void (*disable)(void);
};

static LIST_HEAD(clocks);
static DECLARE_MUTEX(clocks_sem);
static DEFINE_MUTEX(clocks_mutex);
static DEFINE_SPINLOCK(clocks_lock);

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)) {
if (strcmp(id, p->name) == 0) {
clk = p;
break;
}
}
up(&clocks_sem);
mutex_unlock(&clocks_mutex);

return clk;
}
EXPORT_SYMBOL(clk_get);

void clk_put(struct clk *clk)
{
module_put(clk->owner);
}
EXPORT_SYMBOL(clk_put);

Expand Down Expand Up @@ -109,18 +111,18 @@ static struct clk clk_gpio27 = {

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);

Expand Down

0 comments on commit d0a9d75

Please sign in to comment.