Linux clock framework development
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vz@mleia.com>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>
Cc: linux-clk@vger.kernel.org
Subject: [PATCH 3/3] clk: remove redundant clock parents lookup table allocations
Date: Thu,  7 Jan 2016 05:16:08 +0200	[thread overview]
Message-ID: <1452136568-478-4-git-send-email-vz@mleia.com> (raw)
In-Reply-To: <1452136568-478-1-git-send-email-vz@mleia.com>

Since clock parents lookup table for clocks with multiple parent
clocks is always allocated during clock registration, remove similar
allocations from __clk_init_parent() and clk_fetch_parent_index().

The change also corrects a pointer type of a single lookup table
entry on calculation of the lookup table size.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
---
 drivers/clk/clk.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 2fb0dae..f8872f9 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1067,13 +1067,6 @@ static int clk_fetch_parent_index(struct clk_core *core,
 {
 	int i;
 
-	if (!core->parents) {
-		core->parents = kcalloc(core->num_parents,
-					sizeof(struct clk *), GFP_KERNEL);
-		if (!core->parents)
-			return -ENOMEM;
-	}
-
 	/*
 	 * find index of new parent clock using cached parent ptrs,
 	 * or if not yet cached, use string name comparison and cache
@@ -1711,18 +1704,11 @@ static struct clk_core *__clk_init_parent(struct clk_core *core)
 	}
 
 	/*
-	 * Do our best to cache parent clocks in core->parents.  This prevents
-	 * unnecessary and expensive lookups.  We don't set core->parent here;
-	 * that is done by the calling function.
+	 * We don't set core->parent here; that is done by the calling function.
 	 */
 
 	index = core->ops->get_parent(core->hw);
 
-	if (!core->parents)
-		core->parents =
-			kcalloc(core->num_parents, sizeof(struct clk *),
-					GFP_KERNEL);
-
 	ret = clk_core_get_parent_by_index(core, index);
 
 out:
@@ -2374,8 +2360,8 @@ static int __clk_init(struct device *dev, struct clk *clk_user)
 	 * look-ups of clk's possible parents.
 	 */
 	if (core->num_parents > 1) {
-		core->parents = kcalloc(core->num_parents, sizeof(struct clk *),
-					GFP_KERNEL);
+		core->parents = kcalloc(core->num_parents,
+					sizeof(struct clk_core *), GFP_KERNEL);
 		if (!core->parents) {
 			ret = -ENOMEM;
 			goto out;
-- 
2.1.4

  parent reply	other threads:[~2016-01-07  3:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07  3:16 [PATCH 0/3] clk: remove dead code allocations of parent lookup tables Vladimir Zapolskiy
2016-01-07  3:16 ` [PATCH 1/3] clk: don't fetch parent index for non multi-parent clocks Vladimir Zapolskiy
2016-01-07  3:16 ` [PATCH 2/3] clk: simplify array allocation of clock parents for lookup Vladimir Zapolskiy
2016-01-07  3:16 ` Vladimir Zapolskiy [this message]
2016-01-07  9:00   ` [PATCH 3/3] clk: remove redundant clock parents lookup table allocations Masahiro Yamada
2016-01-07 10:44     ` Vladimir Zapolskiy
2016-01-07 11:33       ` Masahiro Yamada
2016-01-07 13:45         ` Vladimir Zapolskiy
2016-01-08  0:33 ` [PATCH 0/3] clk: remove dead code allocations of parent lookup tables Vladimir Zapolskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452136568-478-4-git-send-email-vz@mleia.com \
    --to=vz@mleia.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox