aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/clockdomain.c
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2010-01-26 22:13:00 -0500
committerPaul Walmsley <paul@pwsan.com>2010-01-26 22:13:00 -0500
commite909d62a8afda7a224a7e322cf2f387d69ca771f (patch)
tree7d082ca294ac927fc3599900f291d7ccdc80e713 /arch/arm/mach-omap2/clockdomain.c
parent3d309cdef37e238c108cade95a8192d5688bd56a (diff)
OMAP clockdomain/powerdomain: remove runtime register/unregister
OMAP clockdomains and powerdomains are currently defined statically, only registered at boot, and never unregistered, so we can remove the unregister function and the locking. A variant of this was originally suggested a while ago by Dmitry Baryshkov <dbaryshkov@gmail.com>. This version of this patch contains an additional fix from Kevin Hilman <khilman@deeprootsystems.com> to address one of the pwrdm_for_each_nolock() users in mach-omap2/pm-debug.c. Thanks Kevin. Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Dmitry Baryshkov <dbaryshkov@gmail.com> Cc: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/mach-omap2/clockdomain.c')
-rw-r--r--arch/arm/mach-omap2/clockdomain.c118
1 files changed, 40 insertions, 78 deletions
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index a70ba29f66cc..2af9996f010b 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -39,9 +39,6 @@
39/* clkdm_list contains all registered struct clockdomains */ 39/* clkdm_list contains all registered struct clockdomains */
40static LIST_HEAD(clkdm_list); 40static LIST_HEAD(clkdm_list);
41 41
42/* clkdm_mutex protects clkdm_list add and del ops */
43static DEFINE_MUTEX(clkdm_mutex);
44
45/* array of clockdomain deps to be added/removed when clkdm in hwsup mode */ 42/* array of clockdomain deps to be added/removed when clkdm in hwsup mode */
46static struct clkdm_autodep *autodeps; 43static struct clkdm_autodep *autodeps;
47 44
@@ -67,6 +64,45 @@ static struct clockdomain *_clkdm_lookup(const char *name)
67 return clkdm; 64 return clkdm;
68} 65}
69 66
67/**
68 * _clkdm_register - register a clockdomain
69 * @clkdm: struct clockdomain * to register
70 *
71 * Adds a clockdomain to the internal clockdomain list.
72 * Returns -EINVAL if given a null pointer, -EEXIST if a clockdomain is
73 * already registered by the provided name, or 0 upon success.
74 */
75static int _clkdm_register(struct clockdomain *clkdm)
76{
77 struct powerdomain *pwrdm;
78
79 if (!clkdm || !clkdm->name)
80 return -EINVAL;
81
82 if (!omap_chip_is(clkdm->omap_chip))
83 return -EINVAL;
84
85 pwrdm = pwrdm_lookup(clkdm->pwrdm.name);
86 if (!pwrdm) {
87 pr_err("clockdomain: %s: powerdomain %s does not exist\n",
88 clkdm->name, clkdm->pwrdm.name);
89 return -EINVAL;
90 }
91 clkdm->pwrdm.ptr = pwrdm;
92
93 /* Verify that the clockdomain is not already registered */
94 if (_clkdm_lookup(clkdm->name))
95 return -EEXIST;
96
97 list_add(&clkdm->node, &clkdm_list);
98
99 pwrdm_add_clkdm(pwrdm, clkdm);
100
101 pr_debug("clockdomain: registered %s\n", clkdm->name);
102
103 return 0;
104}
105
70/* _clkdm_deps_lookup - look up the specified clockdomain in a clkdm list */ 106/* _clkdm_deps_lookup - look up the specified clockdomain in a clkdm list */
71static struct clkdm_dep *_clkdm_deps_lookup(struct clockdomain *clkdm, 107static struct clkdm_dep *_clkdm_deps_lookup(struct clockdomain *clkdm,
72 struct clkdm_dep *deps) 108 struct clkdm_dep *deps)
@@ -240,7 +276,7 @@ void clkdm_init(struct clockdomain **clkdms,
240 276
241 if (clkdms) 277 if (clkdms)
242 for (c = clkdms; *c; c++) 278 for (c = clkdms; *c; c++)
243 clkdm_register(*c); 279 _clkdm_register(*c);
244 280
245 autodeps = init_autodeps; 281 autodeps = init_autodeps;
246 if (autodeps) 282 if (autodeps)
@@ -249,76 +285,6 @@ void clkdm_init(struct clockdomain **clkdms,
249} 285}
250 286
251/** 287/**
252 * clkdm_register - register a clockdomain
253 * @clkdm: struct clockdomain * to register
254 *
255 * Adds a clockdomain to the internal clockdomain list.
256 * Returns -EINVAL if given a null pointer, -EEXIST if a clockdomain is
257 * already registered by the provided name, or 0 upon success.
258 */
259int clkdm_register(struct clockdomain *clkdm)
260{
261 int ret = -EINVAL;
262 struct powerdomain *pwrdm;
263
264 if (!clkdm || !clkdm->name)
265 return -EINVAL;
266
267 if (!omap_chip_is(clkdm->omap_chip))
268 return -EINVAL;
269
270 pwrdm = pwrdm_lookup(clkdm->pwrdm.name);
271 if (!pwrdm) {
272 pr_err("clockdomain: %s: powerdomain %s does not exist\n",
273 clkdm->name, clkdm->pwrdm.name);
274 return -EINVAL;
275 }
276 clkdm->pwrdm.ptr = pwrdm;
277
278 mutex_lock(&clkdm_mutex);
279 /* Verify that the clockdomain is not already registered */
280 if (_clkdm_lookup(clkdm->name)) {
281 ret = -EEXIST;
282 goto cr_unlock;
283 }
284
285 list_add(&clkdm->node, &clkdm_list);
286
287 pwrdm_add_clkdm(pwrdm, clkdm);
288
289 pr_debug("clockdomain: registered %s\n", clkdm->name);
290 ret = 0;
291
292cr_unlock:
293 mutex_unlock(&clkdm_mutex);
294
295 return ret;
296}
297
298/**
299 * clkdm_unregister - unregister a clockdomain
300 * @clkdm: struct clockdomain * to unregister
301 *
302 * Removes a clockdomain from the internal clockdomain list. Returns
303 * -EINVAL if clkdm argument is NULL.
304 */
305int clkdm_unregister(struct clockdomain *clkdm)
306{
307 if (!clkdm)
308 return -EINVAL;
309
310 pwrdm_del_clkdm(clkdm->pwrdm.ptr, clkdm);
311
312 mutex_lock(&clkdm_mutex);
313 list_del(&clkdm->node);
314 mutex_unlock(&clkdm_mutex);
315
316 pr_debug("clockdomain: unregistered %s\n", clkdm->name);
317
318 return 0;
319}
320
321/**
322 * clkdm_lookup - look up a clockdomain by name, return a pointer 288 * clkdm_lookup - look up a clockdomain by name, return a pointer
323 * @name: name of clockdomain 289 * @name: name of clockdomain
324 * 290 *
@@ -334,14 +300,12 @@ struct clockdomain *clkdm_lookup(const char *name)
334 300
335 clkdm = NULL; 301 clkdm = NULL;
336 302
337 mutex_lock(&clkdm_mutex);
338 list_for_each_entry(temp_clkdm, &clkdm_list, node) { 303 list_for_each_entry(temp_clkdm, &clkdm_list, node) {
339 if (!strcmp(name, temp_clkdm->name)) { 304 if (!strcmp(name, temp_clkdm->name)) {
340 clkdm = temp_clkdm; 305 clkdm = temp_clkdm;
341 break; 306 break;
342 } 307 }
343 } 308 }
344 mutex_unlock(&clkdm_mutex);
345 309
346 return clkdm; 310 return clkdm;
347} 311}
@@ -369,13 +333,11 @@ int clkdm_for_each(int (*fn)(struct clockdomain *clkdm, void *user),
369 if (!fn) 333 if (!fn)
370 return -EINVAL; 334 return -EINVAL;
371 335
372 mutex_lock(&clkdm_mutex);
373 list_for_each_entry(clkdm, &clkdm_list, node) { 336 list_for_each_entry(clkdm, &clkdm_list, node) {
374 ret = (*fn)(clkdm, user); 337 ret = (*fn)(clkdm, user);
375 if (ret) 338 if (ret)
376 break; 339 break;
377 } 340 }
378 mutex_unlock(&clkdm_mutex);
379 341
380 return ret; 342 return ret;
381} 343}