From patchwork Mon Jun 3 08:37:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 2651171 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 9C04CDF24C for ; Mon, 3 Jun 2013 08:38:12 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjQH1-0005VJ-Ps; Mon, 03 Jun 2013 08:37:52 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjQGt-0000aW-EB; Mon, 03 Jun 2013 08:37:43 +0000 Received: from relay1.mentorg.com ([192.94.38.131]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjQGk-0000Yu-6X for linux-arm-kernel@lists.infradead.org; Mon, 03 Jun 2013 08:37:35 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1UjQGM-0001qR-DH from Jiada_Wang@mentor.com ; Mon, 03 Jun 2013 01:37:10 -0700 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 3 Jun 2013 01:37:10 -0700 Received: from em-wv-03.wv.mentorg.com (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.2.247.3; Mon, 3 Jun 2013 01:37:10 -0700 From: Jiada Wang To: Subject: [PATCH v3] clk: implement clk_unregister Date: Mon, 3 Jun 2013 17:37:06 +0900 Message-ID: <1370248626-3760-1-git-send-email-jiada_wang@mentor.com> X-Mailer: git-send-email 1.8.1.1 MIME-Version: 1.0 X-OriginalArrivalTime: 03 Jun 2013 08:37:10.0046 (UTC) FILETIME=[89B903E0:01CE6035] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130603_043734_321167_0DAE4393 X-CRM114-Status: GOOD ( 11.95 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: u.kleine-koenig@pengutronix.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Currently clk_unregister is unimplemented, it is required in case sub modules want actually remove clk device registered by clk_register. This patch adds the implementation of clk_unregister. Signed-off-by: Jiada Wang --- drivers/clk/clk.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 934cfd1..0b9e13c 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -342,6 +342,25 @@ out: return ret; } + /** + * clk_debug_unregister - remove a clk node from the debugfs clk tree + * @clk: the clk being removed from the debugfs clk tree + * + * Dynamically removes a clk and all it's children clk nodes from the + * debugfs clk tree if clk->dentry points to debugfs created by + * clk_debug_register in __clk_init. + * + * Caller must hold prepare_lock. + * + */ +static void clk_debug_unregister(struct clk *clk) +{ + if (!clk || !clk->dentry) + return; + + debugfs_remove_recursive(clk->dentry); +} + /** * clk_debug_reparent - reparent clk node in the debugfs clk tree * @clk: the clk being reparented @@ -432,6 +451,9 @@ static inline int clk_debug_register(struct clk *clk) { return 0; } static inline void clk_debug_reparent(struct clk *clk, struct clk *new_parent) { } +static inline void clk_debug_unregister(struct clk *clk) +{ +} #endif /* caller must hold prepare_lock */ @@ -1790,9 +1812,42 @@ EXPORT_SYMBOL_GPL(clk_register); * clk_unregister - unregister a currently registered clock * @clk: clock to unregister * - * Currently unimplemented. */ -void clk_unregister(struct clk *clk) {} +void clk_unregister(struct clk *clk) +{ + int i; + + if (!clk) + return; + + mutex_lock(&prepare_lock); + if (clk->prepare_count) { + pr_debug("%s: can't unregister clk %s, it is prepared\n", + __func__, clk->name); + goto out; + } + + if (!hlist_empty(&clk->children)) { + pr_debug("%s: clk %s has registered children\n", + __func__, clk->name); + goto out; + } + + clk_debug_unregister(clk); + + hlist_del_init(&clk->child_node); + + kfree(clk->parents); + i = clk->num_parents; + while (--i >= 0) + kfree(clk->parent_names[i]); + kfree(clk->parent_names); + kfree(clk->name); + kfree(clk); +out: + mutex_unlock(&prepare_lock); + return; +} EXPORT_SYMBOL_GPL(clk_unregister); static void devm_clk_release(struct device *dev, void *res)