diff options
author | Ulf Hansson <ulf.hansson@linaro.org> | 2013-04-02 17:09:37 -0400 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2013-04-08 21:19:15 -0400 |
commit | b33d212f4910ca44bd37d5e08422230687bd1378 (patch) | |
tree | 8aa26057bdee65cae17d2d3fcc579bdbd4347ae1 /drivers/clk/clk.c | |
parent | 918d7f6f68620e0721bb31402ebf87e15f826831 (diff) |
clk: Restructure code for __clk_reparent
Split __clk_reparent into three pieces, one for doing the actual
reparent for updating the clock tree topology, one for the
COMMON_CLK_DEBUG code and one for doing the rate recalculation.
This patch also makes it possible to hold the spinlock over the
update of the clock tree topology, which could not be done before
when both debugfs updates and clock rate updates was done within
the same function.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Rajagopal Venkat <rajagopal.venkat@linaro.org>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r-- | drivers/clk/clk.c | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0230c9d95975..013a3c7fea5b 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -343,6 +343,39 @@ out: | |||
343 | } | 343 | } |
344 | 344 | ||
345 | /** | 345 | /** |
346 | * clk_debug_reparent - reparent clk node in the debugfs clk tree | ||
347 | * @clk: the clk being reparented | ||
348 | * @new_parent: the new clk parent, may be NULL | ||
349 | * | ||
350 | * Rename clk entry in the debugfs clk tree if debugfs has been | ||
351 | * initialized. Otherwise it bails out early since the debugfs clk tree | ||
352 | * will be created lazily by clk_debug_init as part of a late_initcall. | ||
353 | * | ||
354 | * Caller must hold prepare_lock. | ||
355 | */ | ||
356 | static void clk_debug_reparent(struct clk *clk, struct clk *new_parent) | ||
357 | { | ||
358 | struct dentry *d; | ||
359 | struct dentry *new_parent_d; | ||
360 | |||
361 | if (!inited) | ||
362 | return; | ||
363 | |||
364 | if (new_parent) | ||
365 | new_parent_d = new_parent->dentry; | ||
366 | else | ||
367 | new_parent_d = orphandir; | ||
368 | |||
369 | d = debugfs_rename(clk->dentry->d_parent, clk->dentry, | ||
370 | new_parent_d, clk->name); | ||
371 | if (d) | ||
372 | clk->dentry = d; | ||
373 | else | ||
374 | pr_debug("%s: failed to rename debugfs entry for %s\n", | ||
375 | __func__, clk->name); | ||
376 | } | ||
377 | |||
378 | /** | ||
346 | * clk_debug_init - lazily create the debugfs clk tree visualization | 379 | * clk_debug_init - lazily create the debugfs clk tree visualization |
347 | * | 380 | * |
348 | * clks are often initialized very early during boot before memory can | 381 | * clks are often initialized very early during boot before memory can |
@@ -396,6 +429,9 @@ static int __init clk_debug_init(void) | |||
396 | late_initcall(clk_debug_init); | 429 | late_initcall(clk_debug_init); |
397 | #else | 430 | #else |
398 | static inline int clk_debug_register(struct clk *clk) { return 0; } | 431 | static inline int clk_debug_register(struct clk *clk) { return 0; } |
432 | static inline void clk_debug_reparent(struct clk *clk, struct clk *new_parent) | ||
433 | { | ||
434 | } | ||
399 | #endif | 435 | #endif |
400 | 436 | ||
401 | /* caller must hold prepare_lock */ | 437 | /* caller must hold prepare_lock */ |
@@ -1277,16 +1313,8 @@ out: | |||
1277 | return ret; | 1313 | return ret; |
1278 | } | 1314 | } |
1279 | 1315 | ||
1280 | void __clk_reparent(struct clk *clk, struct clk *new_parent) | 1316 | static void clk_reparent(struct clk *clk, struct clk *new_parent) |
1281 | { | 1317 | { |
1282 | #ifdef CONFIG_COMMON_CLK_DEBUG | ||
1283 | struct dentry *d; | ||
1284 | struct dentry *new_parent_d; | ||
1285 | #endif | ||
1286 | |||
1287 | if (!clk || !new_parent) | ||
1288 | return; | ||
1289 | |||
1290 | hlist_del(&clk->child_node); | 1318 | hlist_del(&clk->child_node); |
1291 | 1319 | ||
1292 | if (new_parent) | 1320 | if (new_parent) |
@@ -1294,27 +1322,13 @@ void __clk_reparent(struct clk *clk, struct clk *new_parent) | |||
1294 | else | 1322 | else |
1295 | hlist_add_head(&clk->child_node, &clk_orphan_list); | 1323 | hlist_add_head(&clk->child_node, &clk_orphan_list); |
1296 | 1324 | ||
1297 | #ifdef CONFIG_COMMON_CLK_DEBUG | ||
1298 | if (!inited) | ||
1299 | goto out; | ||
1300 | |||
1301 | if (new_parent) | ||
1302 | new_parent_d = new_parent->dentry; | ||
1303 | else | ||
1304 | new_parent_d = orphandir; | ||
1305 | |||
1306 | d = debugfs_rename(clk->dentry->d_parent, clk->dentry, | ||
1307 | new_parent_d, clk->name); | ||
1308 | if (d) | ||
1309 | clk->dentry = d; | ||
1310 | else | ||
1311 | pr_debug("%s: failed to rename debugfs entry for %s\n", | ||
1312 | __func__, clk->name); | ||
1313 | out: | ||
1314 | #endif | ||
1315 | |||
1316 | clk->parent = new_parent; | 1325 | clk->parent = new_parent; |
1326 | } | ||
1317 | 1327 | ||
1328 | void __clk_reparent(struct clk *clk, struct clk *new_parent) | ||
1329 | { | ||
1330 | clk_reparent(clk, new_parent); | ||
1331 | clk_debug_reparent(clk, new_parent); | ||
1318 | __clk_recalc_rates(clk, POST_RATE_CHANGE); | 1332 | __clk_recalc_rates(clk, POST_RATE_CHANGE); |
1319 | } | 1333 | } |
1320 | 1334 | ||