From patchwork Tue Apr 2 21:09:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 15826 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 2F9F14C13C2 for ; Tue, 2 Apr 2013 21:10:08 +0000 (UTC) Received: from mail-ve0-f198.google.com (mail-ve0-f198.google.com [209.85.128.198]) by fiordland.canonical.com (Postfix) with ESMTP id 8C39BA1A5D9 for ; Tue, 2 Apr 2013 21:10:07 +0000 (UTC) Received: by mail-ve0-f198.google.com with SMTP id ox1sf1445477veb.1 for ; Tue, 02 Apr 2013 14:10:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf: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:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=5PDwZvpps4S6Pzwu92UHMtDgQyNctbt92sCucCcJ3MA=; b=CCIVgOAZYNDKRyStSCfiFhOdqZc4aDJKVuuDKoLyUT6Mwa6RKHh/aLT7IpZcaQtORB 8lE1r/O+ah2k5Famf1pSOBJRQeGf4bBrKwILmZR7UNiKAnv/1pANpR9tRHGk2cOqlsoe MKt+0nwXykOsYctwg+ZJHWIfzjR/1DGa6GqZVYPU1ovA20jxUTftZCeX/JmYgT5GFA+f i3Nh7WD0Igr0CcjehQymtixLbDd/eKEFaFgeVUgvjPlJvnOsvzm1D4CAxhKAPy/oPNO9 6YM8mXJxdmDdQlTr+a+4SoWhyW+jfVCtbJEHL95l683eqsvKcYAW8KcPAfQwXGyidggq geXw== X-Received: by 10.236.159.233 with SMTP id s69mr7005380yhk.54.1364937007039; Tue, 02 Apr 2013 14:10:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.76 with SMTP id 12ls545176qec.40.gmail; Tue, 02 Apr 2013 14:10:06 -0700 (PDT) X-Received: by 10.220.8.4 with SMTP id f4mr14031452vcf.20.1364937006792; Tue, 02 Apr 2013 14:10:06 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id oy17si2641863vcb.56.2013.04.02.14.10.06 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Apr 2013 14:10:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id cy12so1120296veb.32 for ; Tue, 02 Apr 2013 14:10:06 -0700 (PDT) X-Received: by 10.52.76.103 with SMTP id j7mr12101794vdw.90.1364937006598; Tue, 02 Apr 2013 14:10:06 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp143065ved; Tue, 2 Apr 2013 14:10:06 -0700 (PDT) X-Received: by 10.14.173.67 with SMTP id u43mr53267175eel.22.1364937005457; Tue, 02 Apr 2013 14:10:05 -0700 (PDT) Received: from eu1sys200aog120.obsmtp.com (eu1sys200aog120.obsmtp.com [207.126.144.149]) by mx.google.com with SMTP id g3si5278429eev.50.2013.04.02.14.10.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Apr 2013 14:10:05 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.149 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.149; Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob120.postini.com ([207.126.147.11]) with SMTP ID DSNKUVtJKGBoyDmKBJE+tK2a4bjInB+X0vnf@postini.com; Tue, 02 Apr 2013 21:10:05 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EAB0CC9; Tue, 2 Apr 2013 21:09:51 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8CCECA153; Tue, 2 Apr 2013 21:09:51 +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 9D17F24C07C; Tue, 2 Apr 2013 23:09:40 +0200 (CEST) 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.279.5; Tue, 2 Apr 2013 23:09:50 +0200 From: Ulf Hansson To: , Mike Turquette Cc: Linus Walleij , Par-Olof Hakansson , Ulf Hansson , Rajagopal Venkat Subject: [PATCH V4 1/3] clk: Restructure code for __clk_reparent Date: Tue, 2 Apr 2013 23:09:37 +0200 Message-ID: <1364936979-20805-2-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1364936979-20805-1-git-send-email-ulf.hansson@stericsson.com> References: <1364936979-20805-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmLrxvssQjenNoR+w7rdMsD8UvcMkY6RDCfHHlraqAZb5xSi6IoIhk7q9ssjkyDJ0OnPJry X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Ulf Hansson 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 Cc: Rajagopal Venkat --- drivers/clk/clk.c | 70 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0230c9d..013a3c7 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -343,6 +343,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 @@ -396,6 +429,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 */ @@ -1277,16 +1313,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) @@ -1294,27 +1322,13 @@ 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; +} +void __clk_reparent(struct clk *clk, struct clk *new_parent) +{ + clk_reparent(clk, new_parent); + clk_debug_reparent(clk, new_parent); __clk_recalc_rates(clk, POST_RATE_CHANGE); }