From patchwork Tue Mar 12 19:20:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 15304 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B877023E2C for ; Tue, 12 Mar 2013 19:21:14 +0000 (UTC) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by fiordland.canonical.com (Postfix) with ESMTP id 4DA5DA183D7 for ; Tue, 12 Mar 2013 19:21:14 +0000 (UTC) Received: by mail-ve0-f175.google.com with SMTP id cy12so169927veb.20 for ; Tue, 12 Mar 2013 12:21:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:mime-version:content-type:x-gm-message-state; bh=4ciLsuhBkiBYVgQVqSHoV1CWkOA7/mdOeXfg5Fv2+IA=; b=QukO4PUAB9v7EO9GCHiPph4XqkoQ7+rih3NSChDCSIGVUEPOeI1LIr0SxKz634Dxow qrMY7DphNnT32dA+jbN/kdszWq1eEsb0LsV3OOTIzAERv491+Yu1ZZhwNZwL5723Lf+h jNDwVmMuzIFgTIpQLqG79yKLJnOTL2xq9jhkDTmhLAhPKOW0nsTGlAj6M/32au4NTCbV eLbB65aTtWTM4EpNbo7PQPmjyKUrwBtPPL5xToAfljd5Sg3SHcol1LqQ//P6RsqkGqP1 e0Rdf9XpHUBgDI1U4jcaVqZ2k+HnWxEkrRPATFXp6vQzhmIINUfyX02cXNmO7Bz2Ue/o iZtg== X-Received: by 10.220.214.6 with SMTP id gy6mr3773350vcb.8.1363116073645; Tue, 12 Mar 2013 12:21:13 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp144394veb; Tue, 12 Mar 2013 12:21:12 -0700 (PDT) X-Received: by 10.180.81.164 with SMTP id b4mr22309760wiy.34.1363116071992; Tue, 12 Mar 2013 12:21:11 -0700 (PDT) Received: from eu1sys200aog113.obsmtp.com (eu1sys200aog113.obsmtp.com [207.126.144.135]) by mx.google.com with SMTP id x44si37292106eey.256.2013.03.12.12.21.06 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 12 Mar 2013 12:21:11 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.135 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.135; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.135 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) smtp.mail=ulf.hansson@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob113.postini.com ([207.126.147.11]) with SMTP ID DSNKUT+AIrV9OV3vJrx+jzYAHDjn7KFWdT5q@postini.com; Tue, 12 Mar 2013 19:21:11 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 95F539A; Tue, 12 Mar 2013 19:12:55 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 0AF0A563; Tue, 12 Mar 2013 19:21:03 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id CC14C24C07C; Tue, 12 Mar 2013 20:20:52 +0100 (CET) Received: from steludxu1397.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 12 Mar 2013 20:21:01 +0100 From: Ulf Hansson To: , Mike Turquette Cc: Linus Walleij , Par-Olof Hakansson , Ulf Hansson Subject: [RESEND PATCH 1/3] clk: Remove _clk_reparent from API and restructure code Date: Tue, 12 Mar 2013 20:20:48 +0100 Message-ID: <1363116050-3882-2-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1363116050-3882-1-git-send-email-ulf.hansson@stericsson.com> References: <1363116050-3882-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQnuDhumY5b524kLiRVpNi4lRWsxKNd7+gB4L5lBXMjvEScPIjDxX03O/hB/c9W1fqluRxgv From: Ulf Hansson There shall be no reason for keeping this API available for clock providers. So we remove it from the API and restrcuture the code so for example the COMMON_CLK_DEBUG part is separated. This patch will also make it possible to hold the spinlock over the actual 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 --- drivers/clk/clk.c | 82 ++++++++++++++++++++++++------------------ include/linux/clk-provider.h | 1 - 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 593a2e4..2e10cc1 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -284,6 +284,39 @@ out: } /** + * clk_debug_reparent - reparent clk node in the debugfs clk tree + * @clk: the clk being reparented + * @new_parent: the new clk parent, may be NULL + * + * Rename clk entry in the debugfs clk tree if debugfs has been + * initialized. Otherwise it bails out early since the debugfs clk tree + * will be created lazily by clk_debug_init as part of a late_initcall. + * + * Caller must hold prepare_lock. + */ +static void clk_debug_reparent(struct clk *clk, struct clk *new_parent) +{ + struct dentry *d; + struct dentry *new_parent_d; + + if (!inited) + return; + + if (new_parent) + new_parent_d = new_parent->dentry; + else + new_parent_d = orphandir; + + d = debugfs_rename(clk->dentry->d_parent, clk->dentry, + new_parent_d, clk->name); + if (d) + clk->dentry = d; + else + pr_debug("%s: failed to rename debugfs entry for %s\n", + __func__, clk->name); +} + +/** * clk_debug_init - lazily create the debugfs clk tree visualization * * clks are often initialized very early during boot before memory can @@ -338,6 +371,9 @@ static int __init clk_debug_init(void) late_initcall(clk_debug_init); #else static inline int clk_debug_register(struct clk *clk) { return 0; } +static inline void clk_debug_reparent(struct clk *clk, struct clk *new_parent) +{ +} #endif /* caller must hold prepare_lock */ @@ -1179,16 +1215,8 @@ out: return ret; } -void __clk_reparent(struct clk *clk, struct clk *new_parent) +static void clk_reparent(struct clk *clk, struct clk *new_parent) { -#ifdef CONFIG_COMMON_CLK_DEBUG - struct dentry *d; - struct dentry *new_parent_d; -#endif - - if (!clk || !new_parent) - return; - hlist_del(&clk->child_node); if (new_parent) @@ -1196,28 +1224,7 @@ void __clk_reparent(struct clk *clk, struct clk *new_parent) else hlist_add_head(&clk->child_node, &clk_orphan_list); -#ifdef CONFIG_COMMON_CLK_DEBUG - if (!inited) - goto out; - - if (new_parent) - new_parent_d = new_parent->dentry; - else - new_parent_d = orphandir; - - d = debugfs_rename(clk->dentry->d_parent, clk->dentry, - new_parent_d, clk->name); - if (d) - clk->dentry = d; - else - pr_debug("%s: failed to rename debugfs entry for %s\n", - __func__, clk->name); -out: -#endif - clk->parent = new_parent; - - __clk_recalc_rates(clk, POST_RATE_CHANGE); } static int __clk_set_parent(struct clk *clk, struct clk *parent) @@ -1329,7 +1336,9 @@ int clk_set_parent(struct clk *clk, struct clk *parent) } /* propagate rate recalculation downstream */ - __clk_reparent(clk, parent); + clk_reparent(clk, parent); + clk_debug_reparent(clk, parent); + __clk_recalc_rates(clk, POST_RATE_CHANGE); out: mutex_unlock(&prepare_lock); @@ -1453,14 +1462,19 @@ int __clk_init(struct device *dev, struct clk *clk) hlist_for_each_entry_safe(orphan, tmp, tmp2, &clk_orphan_list, child_node) { if (orphan->ops->get_parent) { i = orphan->ops->get_parent(orphan->hw); - if (!strcmp(clk->name, orphan->parent_names[i])) - __clk_reparent(orphan, clk); + if (!strcmp(clk->name, orphan->parent_names[i])) { + clk_reparent(orphan, clk); + clk_debug_reparent(orphan, clk); + __clk_recalc_rates(orphan, POST_RATE_CHANGE); + } continue; } for (i = 0; i < orphan->num_parents; i++) if (!strcmp(clk->name, orphan->parent_names[i])) { - __clk_reparent(orphan, clk); + clk_reparent(orphan, clk); + clk_debug_reparent(orphan, clk); + __clk_recalc_rates(orphan, POST_RATE_CHANGE); break; } } diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 4989b8a..87a7c2c 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -359,7 +359,6 @@ struct clk *__clk_lookup(const char *name); */ int __clk_prepare(struct clk *clk); void __clk_unprepare(struct clk *clk); -void __clk_reparent(struct clk *clk, struct clk *new_parent); unsigned long __clk_round_rate(struct clk *clk, unsigned long rate); struct of_device_id;