devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: linux-omap@vger.kernel.org, mturquette@linaro.org,
	paul@pwsan.com, tony@atomide.com, nm@ti.com, rnayak@ti.com
Cc: linux-arm-kernel@lists.infradead.org,
	devicetree-discuss@lists.ozlabs.org
Subject: [PATCHv2 03/11] CLK: divider: fix table parsing logic for DT
Date: Wed, 19 Jun 2013 16:18:54 +0300	[thread overview]
Message-ID: <1371647942-4811-4-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1371647942-4811-1-git-send-email-t-kristo@ti.com>

The existing implementation had a couple of bugs:

1) table_size was attempted to read improperly, it has to be calculated
   from the 'len' parameter of a property
2) Reading the integer entries from the table was reading only first
   two entries of the DT data

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 drivers/clk/clk-divider.c |   19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 3413602..2fa7932 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -325,15 +325,18 @@ struct clk *clk_register_divider_table(struct device *dev, const char *name,
 struct clk_div_table *of_clk_get_div_table(struct device_node *node)
 {
 	int i;
-	int table_size = 0;
+	u32 table_size;
 	struct clk_div_table *table;
-	u32 pair[2];
+	const __be32 *tablespec;
+	u32 val;
 
-	table_size = of_count_phandle_with_args(node, "table", "#clock-cells");
+	tablespec = of_get_property(node, "table", &table_size);
 
-	if (table_size < 1)
+	if (!tablespec)
 		return NULL;
 
+	table_size /= sizeof(struct clk_div_table);
+
 	table = kzalloc(sizeof(struct clk_div_table) * table_size, GFP_KERNEL);
 	if (!table) {
 		pr_err("%s: unable to allocate memory for %s table\n", __func__, node->name);
@@ -341,10 +344,10 @@ struct clk_div_table *of_clk_get_div_table(struct device_node *node)
 	}
 
 	for (i = 0; i < table_size; i++) {
-		if (!of_property_read_u32_array(node, "table", pair, ARRAY_SIZE(pair))) {
-			table[i].val = pair[0];
-			table[i].div = pair[1];
-		}
+		of_property_read_u32_index(node, "table", i * 2, &val);
+		table[i].div = val;
+		of_property_read_u32_index(node, "table", i * 2 + 1, &val);
+		table[i].val = val;
 	}
 
 	return table;
-- 
1.7.9.5


  parent reply	other threads:[~2013-06-19 13:18 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-19 13:18 [PATCHv2 00/11] ARM: OMAP4 clock data conversion to DT Tero Kristo
2013-06-19 13:18 ` [PATCHv2 01/11] CLK: clkdev: add support for looking up clocks from DT Tero Kristo
2013-06-19 13:18 ` [PATCHv2 02/11] CLK: use of_property_read_u32 instead of read_u8 Tero Kristo
     [not found]   ` <1371647942-4811-3-git-send-email-t-kristo-l0cyMroinI0@public.gmane.org>
2013-06-21  0:57     ` Mike Turquette
2013-06-21 12:45       ` Nishanth Menon
2013-06-21 16:21         ` Mike Turquette
2013-06-19 13:18 ` Tero Kristo [this message]
2013-06-19 13:18 ` [PATCHv2 04/11] clk: omap: introduce clock driver Tero Kristo
2013-06-19 13:18 ` [PATCHv2 05/11] CLK: OMAP4: Add DPLL clock support Tero Kristo
2013-06-19 13:18 ` [PATCHv2 06/11] CLK: omap: move part of the machine specific clock header contents to driver Tero Kristo
2013-06-21  7:32   ` Tony Lindgren
2013-06-24  7:42     ` Tero Kristo
2013-06-19 13:18 ` [PATCHv2 07/11] ARM: OMAP: clock: add DT duplicate clock registration mechanism Tero Kristo
2013-06-19 13:18 ` [PATCHv2 08/11] CLK: omap: add autoidle support Tero Kristo
2013-06-19 13:19 ` [PATCHv2 09/11] CLK: omap: add support for OMAP gate clock Tero Kristo
2013-06-19 13:19 ` [PATCHv2 10/11] ARM: dts: omap4 clock data Tero Kristo
2013-06-19 13:30   ` Nishanth Menon
2013-06-19 13:49     ` Tero Kristo
2013-06-19 13:56       ` Nishanth Menon
2013-06-21  1:24   ` Stephen Boyd
2013-06-24  7:39     ` Tero Kristo
2013-06-19 13:19 ` [PATCHv2 11/11] ARM: OMAP4: register DT clocks and remove old data Tero Kristo
2013-06-21  7:25   ` Tony Lindgren
2013-06-24  7:45     ` Tero Kristo
2013-06-24  7:50       ` Tony Lindgren

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=1371647942-4811-4-git-send-email-t-kristo@ti.com \
    --to=t-kristo@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=nm@ti.com \
    --cc=paul@pwsan.com \
    --cc=rnayak@ti.com \
    --cc=tony@atomide.com \
    /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;
as well as URLs for NNTP newsgroup(s).