Skip to content

Commit

Permalink
[ARM] clocklib: Allow dynamic alias creation
Browse files Browse the repository at this point in the history
This patch allows dynamic creation of clock aliases in order to
make it possible to have platform independent clock names for use in
device drivers.

Signed-off-by: Ian Molton <spyro@f2s.com>
  • Loading branch information
Ian Molton committed Aug 12, 2008
1 parent 67a6e80 commit 5fedd0a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
25 changes: 25 additions & 0 deletions arch/arm/mach-pxa/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,28 @@ void clks_register(struct clk *clks, size_t num)
list_add(&clks[i].node, &clocks);
mutex_unlock(&clocks_mutex);
}

int clk_add_alias(char *alias, struct device *alias_dev, char *id,
struct device *dev)
{
struct clk *r = clk_lookup(dev, id);
struct clk *new;

if (!r)
return -ENODEV;

new = kzalloc(sizeof(struct clk), GFP_KERNEL);

if (!new)
return -ENOMEM;

new->name = alias;
new->dev = alias_dev;
new->other = r;

mutex_lock(&clocks_mutex);
list_add(&new->node, &clocks);
mutex_unlock(&clocks_mutex);

return 0;
}
5 changes: 5 additions & 0 deletions arch/arm/mach-pxa/clock.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <linux/list.h>

struct clk;

struct clkops {
Expand Down Expand Up @@ -86,3 +88,6 @@ extern void clk_pxa3xx_cken_disable(struct clk *);
#endif

void clks_register(struct clk *clks, size_t num);
int clk_add_alias(char *alias, struct device *alias_dev, char *id,
struct device *dev);

0 comments on commit 5fedd0a

Please sign in to comment.