diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2012-09-11 14:56:23 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-09-15 16:55:27 -0400 |
commit | 8ef997b67f0d779c82e7e533a792c5a6837594cd (patch) | |
tree | c92fa5117845856ee236c7c51a4f664762c411c6 /drivers | |
parent | 55d512e245bc7699a8800e23df1a24195dd08217 (diff) |
ARM: 7534/1: clk: Make the managed clk functions generically available
The managed clk functions are currently only available when the generic clk
lookup framework is build. But the managed clk functions are merely wrappers
around clk_get and clk_put and do not depend on any specifics of the generic
lookup functions and there are still quite a few custom implementations of the
clk API. So make the managed functions available whenever the clk API is
implemented.
The patch also removes the custom implementation of devm_clk_get for the
coldfire platform.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Greg Ungerer <gerg@uclinux.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/clk/Makefile | 1 | ||||
-rw-r--r-- | drivers/clk/clk-devres.c | 55 | ||||
-rw-r--r-- | drivers/clk/clkdev.c | 45 |
3 files changed, 56 insertions, 45 deletions
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 5869ea387054..72ce247a0e8d 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile | |||
@@ -1,4 +1,5 @@ | |||
1 | # common clock types | 1 | # common clock types |
2 | obj-$(CONFIG_HAVE_CLK) += clk-devres.o | ||
2 | obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o | 3 | obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o |
3 | obj-$(CONFIG_COMMON_CLK) += clk.o clk-fixed-rate.o clk-gate.o \ | 4 | obj-$(CONFIG_COMMON_CLK) += clk.o clk-fixed-rate.o clk-gate.o \ |
4 | clk-mux.o clk-divider.o clk-fixed-factor.o | 5 | clk-mux.o clk-divider.o clk-fixed-factor.o |
diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c new file mode 100644 index 000000000000..f1e7a83426cc --- /dev/null +++ b/drivers/clk/clk-devres.c | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or modify | ||
3 | * it under the terms of the GNU General Public License version 2 as | ||
4 | * published by the Free Software Foundation. | ||
5 | */ | ||
6 | |||
7 | #include <linux/clk.h> | ||
8 | #include <linux/device.h> | ||
9 | #include <linux/export.h> | ||
10 | #include <linux/gfp.h> | ||
11 | |||
12 | static void devm_clk_release(struct device *dev, void *res) | ||
13 | { | ||
14 | clk_put(*(struct clk **)res); | ||
15 | } | ||
16 | |||
17 | struct clk *devm_clk_get(struct device *dev, const char *id) | ||
18 | { | ||
19 | struct clk **ptr, *clk; | ||
20 | |||
21 | ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL); | ||
22 | if (!ptr) | ||
23 | return ERR_PTR(-ENOMEM); | ||
24 | |||
25 | clk = clk_get(dev, id); | ||
26 | if (!IS_ERR(clk)) { | ||
27 | *ptr = clk; | ||
28 | devres_add(dev, ptr); | ||
29 | } else { | ||
30 | devres_free(ptr); | ||
31 | } | ||
32 | |||
33 | return clk; | ||
34 | } | ||
35 | EXPORT_SYMBOL(devm_clk_get); | ||
36 | |||
37 | static int devm_clk_match(struct device *dev, void *res, void *data) | ||
38 | { | ||
39 | struct clk **c = res; | ||
40 | if (!c || !*c) { | ||
41 | WARN_ON(!c || !*c); | ||
42 | return 0; | ||
43 | } | ||
44 | return *c == data; | ||
45 | } | ||
46 | |||
47 | void devm_clk_put(struct device *dev, struct clk *clk) | ||
48 | { | ||
49 | int ret; | ||
50 | |||
51 | ret = devres_destroy(dev, devm_clk_release, devm_clk_match, clk); | ||
52 | |||
53 | WARN_ON(ret); | ||
54 | } | ||
55 | EXPORT_SYMBOL(devm_clk_put); | ||
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index d423c9bdd71a..442a31363873 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c | |||
@@ -171,51 +171,6 @@ void clk_put(struct clk *clk) | |||
171 | } | 171 | } |
172 | EXPORT_SYMBOL(clk_put); | 172 | EXPORT_SYMBOL(clk_put); |
173 | 173 | ||
174 | static void devm_clk_release(struct device *dev, void *res) | ||
175 | { | ||
176 | clk_put(*(struct clk **)res); | ||
177 | } | ||
178 | |||
179 | struct clk *devm_clk_get(struct device *dev, const char *id) | ||
180 | { | ||
181 | struct clk **ptr, *clk; | ||
182 | |||
183 | ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL); | ||
184 | if (!ptr) | ||
185 | return ERR_PTR(-ENOMEM); | ||
186 | |||
187 | clk = clk_get(dev, id); | ||
188 | if (!IS_ERR(clk)) { | ||
189 | *ptr = clk; | ||
190 | devres_add(dev, ptr); | ||
191 | } else { | ||
192 | devres_free(ptr); | ||
193 | } | ||
194 | |||
195 | return clk; | ||
196 | } | ||
197 | EXPORT_SYMBOL(devm_clk_get); | ||
198 | |||
199 | static int devm_clk_match(struct device *dev, void *res, void *data) | ||
200 | { | ||
201 | struct clk **c = res; | ||
202 | if (!c || !*c) { | ||
203 | WARN_ON(!c || !*c); | ||
204 | return 0; | ||
205 | } | ||
206 | return *c == data; | ||
207 | } | ||
208 | |||
209 | void devm_clk_put(struct device *dev, struct clk *clk) | ||
210 | { | ||
211 | int ret; | ||
212 | |||
213 | ret = devres_destroy(dev, devm_clk_release, devm_clk_match, clk); | ||
214 | |||
215 | WARN_ON(ret); | ||
216 | } | ||
217 | EXPORT_SYMBOL(devm_clk_put); | ||
218 | |||
219 | void clkdev_add(struct clk_lookup *cl) | 174 | void clkdev_add(struct clk_lookup *cl) |
220 | { | 175 | { |
221 | mutex_lock(&clocks_mutex); | 176 | mutex_lock(&clocks_mutex); |