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: 1195871 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 187EA3FC4C for ; Fri, 13 Jul 2012 14:20:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161041Ab2GMOUU (ORCPT ); Fri, 13 Jul 2012 10:20:20 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:35592 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933265Ab2GMOUS (ORCPT ); Fri, 13 Jul 2012 10:20:18 -0400 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: , , CC: 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 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.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);