From patchwork Thu Jan 20 05:33:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajendra Nayak X-Patchwork-Id: 491041 X-Patchwork-Delegate: paul@pwsan.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0K5WdDK010492 for ; Thu, 20 Jan 2011 05:33:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753691Ab1ATFdm (ORCPT ); Thu, 20 Jan 2011 00:33:42 -0500 Received: from na3sys009aog102.obsmtp.com ([74.125.149.69]:58398 "EHLO na3sys009aog102.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752461Ab1ATFdm (ORCPT ); Thu, 20 Jan 2011 00:33:42 -0500 Received: from source ([209.85.161.49]) (using TLSv1) by na3sys009aob102.postini.com ([74.125.148.12]) with SMTP ID DSNKTTfJNN9L7x6rg2yRVZcrdxbGAnmqNM6c@postini.com; Wed, 19 Jan 2011 21:33:41 PST Received: by mail-fx0-f49.google.com with SMTP id 19so222626fxm.22 for ; Wed, 19 Jan 2011 21:33:40 -0800 (PST) Received: by 10.103.214.5 with SMTP id r5mr948994muq.134.1295501620622; Wed, 19 Jan 2011 21:33:40 -0800 (PST) From: Rajendra Nayak References: <1295446466-23655-1-git-send-email-rnayak@ti.com> <1295446466-23655-2-git-send-email-rnayak@ti.com> <20110119151924.GA3552@legolas.emea.dhcp.ti.com> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <20110119151924.GA3552@legolas.emea.dhcp.ti.com> Thread-index: Acu37EeBnsHzsqadTyiVJC1sEV7jcQAdGOMw X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Date: Thu, 20 Jan 2011 11:03:38 +0530 Message-ID: <504b9356bcc91cc2316b1623095e4f64@mail.gmail.com> Subject: RE: [RFC 1/3] OMAP: clocks: Use clk names instead of clk pointers To: balbi@ti.com Cc: linux-omap@vger.kernel.org, paul@pwsan.com, khilman@deeprootsystems.com Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 20 Jan 2011 05:33:43 +0000 (UTC) diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c index fc62fb5..9bfd193 100644 --- a/arch/arm/plat-omap/clock.c +++ b/arch/arm/plat-omap/clock.c @@ -308,6 +308,16 @@ void clk_enable_init_clocks(void) } } +static struct clk *_omap_clk_get_by_name(const char *name) +{ + struct clk *c; + + list_for_each_entry(c, &clocks, node) + if (!strcmp(c->name, name)) + return c; + return NULL; +} + /** * omap_clk_get_by_name - locate OMAP struct clk by its name * @name: name of the struct clk to locate @@ -318,21 +328,45 @@ void clk_enable_init_clocks(void) */ struct clk *omap_clk_get_by_name(const char *name) { - struct clk *c; struct clk *ret = NULL; mutex_lock(&clocks_mutex); + ret = _omap_clk_get_by_name(name); + mutex_unlock(&clocks_mutex); + + return ret; +} + +static inline void omap_init_dpll_data_clk_pts(struct dpll_data *dd) +{ + if (!dd->clk_ref && dd->clk_ref_name) + dd->clk_ref = _omap_clk_get_by_name(dd->clk_ref_name); + if (!dd->clk_bypass && dd->clk_bypass_name) + dd->clk_bypass = _omap_clk_get_by_name(dd->clk_bypass_name); +} + +static inline void omap_init_clksel_clk_pts(struct clksel *clks) +{ + if (!clks->parent && clks->parent_name) + clks->parent = _omap_clk_get_by_name(clks->parent_name); +} + +void omap_init_clk_pts(void) +{ + struct clk *c; + + mutex_lock(&clocks_mutex); list_for_each_entry(c, &clocks, node) { - if (!strcmp(c->name, name)) { - ret = c; - break; - } + if (!c->parent && c->parent_name) + c->parent = _omap_clk_get_by_name(c->parent_name); + if (c->dpll_data) + omap_init_dpll_data_clk_pts(c->dpll_data); + if (c->clksel) + omap_init_clksel_clk_pts(c->clksel); } mutex_unlock(&clocks_mutex); - - return ret; } /* diff --git a/arch/arm/plat-omap/include/plat/clock.h b/arch/arm/plat-omap/include/plat/clock.h index 8eb0ada..dc0d9fd 100644 --- a/arch/arm/plat-omap/include/plat/clock.h +++ b/arch/arm/plat-omap/include/plat/clock.h @@ -85,6 +85,7 @@ struct clksel_rate { /** * struct clksel - available parent clocks, and a pointer to their divisors * @parent: struct clk * to a possible parent clock + * @parent_name: Name of the possible parent clock * @rates: available divisors for this parent clock *