aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2009-06-03 12:43:14 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-06-04 12:45:43 -0400
commitc0683039207226afcffbe0fbf6a1caaee77a37b0 (patch)
treed91295ea184722929a12c772839c3d6f502ad95b
parent5926a295bb78272b3f648f62febecd19a1b6a6ca (diff)
[ARM] 5536/1: Move clk_add_alias() to arch/arm/common/clkdev.c
This can be used for other arm platforms too as discussed on the linux-arm-kernel list. Also check the return value with IS_ERR and return PTR_ERR as suggested by Russell King. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/common/clkdev.c18
-rw-r--r--arch/arm/mach-pxa/clock.c17
-rw-r--r--include/linux/clk.h13
3 files changed, 31 insertions, 17 deletions
diff --git a/arch/arm/common/clkdev.c b/arch/arm/common/clkdev.c
index 5589444ff437..f37afd9422f3 100644
--- a/arch/arm/common/clkdev.c
+++ b/arch/arm/common/clkdev.c
@@ -135,6 +135,24 @@ struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
135} 135}
136EXPORT_SYMBOL(clkdev_alloc); 136EXPORT_SYMBOL(clkdev_alloc);
137 137
138int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
139 struct device *dev)
140{
141 struct clk *r = clk_get(dev, id);
142 struct clk_lookup *l;
143
144 if (IS_ERR(r))
145 return PTR_ERR(r);
146
147 l = clkdev_alloc(r, alias, alias_dev_name);
148 clk_put(r);
149 if (!l)
150 return -ENODEV;
151 clkdev_add(l);
152 return 0;
153}
154EXPORT_SYMBOL(clk_add_alias);
155
138/* 156/*
139 * clkdev_drop - remove a clock dynamically allocated 157 * clkdev_drop - remove a clock dynamically allocated
140 */ 158 */
diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c
index db52d2c4791d..49ae38292310 100644
--- a/arch/arm/mach-pxa/clock.c
+++ b/arch/arm/mach-pxa/clock.c
@@ -86,20 +86,3 @@ void clks_register(struct clk_lookup *clks, size_t num)
86 for (i = 0; i < num; i++) 86 for (i = 0; i < num; i++)
87 clkdev_add(&clks[i]); 87 clkdev_add(&clks[i]);
88} 88}
89
90int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
91 struct device *dev)
92{
93 struct clk *r = clk_get(dev, id);
94 struct clk_lookup *l;
95
96 if (!r)
97 return -ENODEV;
98
99 l = clkdev_alloc(r, alias, alias_dev_name);
100 clk_put(r);
101 if (!l)
102 return -ENODEV;
103 clkdev_add(l);
104 return 0;
105}
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 1db9bbf444a3..1d37f42ac294 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -142,4 +142,17 @@ struct clk *clk_get_parent(struct clk *clk);
142 */ 142 */
143struct clk *clk_get_sys(const char *dev_id, const char *con_id); 143struct clk *clk_get_sys(const char *dev_id, const char *con_id);
144 144
145/**
146 * clk_add_alias - add a new clock alias
147 * @alias: name for clock alias
148 * @alias_dev_name: device name
149 * @id: platform specific clock name
150 * @dev: device
151 *
152 * Allows using generic clock names for drivers by adding a new alias.
153 * Assumes clkdev, see clkdev.h for more info.
154 */
155int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
156 struct device *dev);
157
145#endif 158#endif