From patchwork Fri Jul 13 14:19:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 1195981 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 9F0D2DFFFD for ; Fri, 13 Jul 2012 14:31:03 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Spgjq-00005B-Me; Fri, 13 Jul 2012 14:20:58 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SpgjA-0008Rh-9w for linux-arm-kernel@lists.infradead.org; Fri, 13 Jul 2012 14:20:17 +0000 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id q6DEJqIA017800; Fri, 13 Jul 2012 09:19:52 -0500 Received: from DFLE71.ent.ti.com (dfle71.ent.ti.com [128.247.5.62]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6DEJqG0023515; Fri, 13 Jul 2012 09:19:52 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by dfle71.ent.ti.com (128.247.5.62) with Microsoft SMTP Server id 14.1.323.3; Fri, 13 Jul 2012 09:19:52 -0500 Received: from localhost.localdomain (h64-15.vpn.ti.com [172.24.64.15]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6DEJn54007873; Fri, 13 Jul 2012 09:19:50 -0500 From: Tero Kristo To: , , Subject: [PATCHv4 1/8] ARM: OMAP: clk: add support for omap_clk_for_each Date: Fri, 13 Jul 2012 17:19:38 +0300 Message-ID: <1342189185-5306-2-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1342189185-5306-1-git-send-email-t-kristo@ti.com> References: <1342189185-5306-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.94.94.41 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This works similarly to e.g. pwrdm_for_each(). Needed by enhanced usecounting debug functionality that will be added to pm-debug. Signed-off-by: Tero Kristo Cc: Paul Walmsley Cc: Kevin Hilman --- arch/arm/plat-omap/clock.c | 33 +++++++++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/clock.h | 2 + 2 files changed, 35 insertions(+), 0 deletions(-) diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c index 706b7e2..ad9dc59 100644 --- a/arch/arm/plat-omap/clock.c +++ b/arch/arm/plat-omap/clock.c @@ -355,6 +355,39 @@ int omap_clk_enable_autoidle_all(void) return 0; } +/** + * omap_clk_for_each - call a function for each registered clock + * @fn: pointer to callback function + * @data: void * data to pass to callback function + * + * Call @fn for each registered clock, passing @data to each function. + * @fn must return 0 for success or any other value for failure. If + * @fn returns non-zero, the iteration across clocks will stop and + * the non-zero return value will be passed to the caller of + * omap_clk_for_each(). @fn is called with clockfw_lock held. + */ +int omap_clk_for_each(int (*fn)(struct clk *clk, void *user), void *user) +{ + struct clk *c; + unsigned long flags; + int ret = 0; + + if (!fn) + return -EINVAL; + + spin_lock_irqsave(&clockfw_lock, flags); + + list_for_each_entry(c, &clocks, node) { + ret = fn(c, user); + if (ret) + break; + } + + spin_unlock_irqrestore(&clockfw_lock, flags); + + return ret; +} + int omap_clk_disable_autoidle_all(void) { struct clk *c; diff --git a/arch/arm/plat-omap/include/plat/clock.h b/arch/arm/plat-omap/include/plat/clock.h index d0ef57c..998947e 100644 --- a/arch/arm/plat-omap/include/plat/clock.h +++ b/arch/arm/plat-omap/include/plat/clock.h @@ -294,6 +294,8 @@ extern void propagate_rate(struct clk *clk); extern void recalculate_root_clocks(void); extern unsigned long followparent_recalc(struct clk *clk); extern void clk_enable_init_clocks(void); +extern int omap_clk_for_each(int (*fn)(struct clk *clk, void *user), + void *user); unsigned long omap_fixed_divisor_recalc(struct clk *clk); extern struct clk *omap_clk_get_by_name(const char *name); extern int omap_clk_enable_autoidle_all(void);