From patchwork Wed Jun 19 13:18:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 2749291 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 88A099F3A0 for ; Wed, 19 Jun 2013 13:22:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6382C20279 for ; Wed, 19 Jun 2013 13:22:13 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E4E042026D for ; Wed, 19 Jun 2013 13:22:11 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UpIJd-0007I4-I8; Wed, 19 Jun 2013 13:20:50 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UpIJG-0002nW-7q; Wed, 19 Jun 2013 13:20:26 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UpIIX-0002hs-4h for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2013 13:19:43 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5JDJFZD020916; Wed, 19 Jun 2013 08:19:15 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r5JDJFmq026212; Wed, 19 Jun 2013 08:19:15 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Wed, 19 Jun 2013 08:19:15 -0500 Received: from sokoban.tieu.ti.com (h79-27.vpn.ti.com [172.24.79.27]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r5JDJ40Y024678; Wed, 19 Jun 2013 08:19:13 -0500 From: Tero Kristo To: , , , , , Subject: [PATCHv2 03/11] CLK: divider: fix table parsing logic for DT Date: Wed, 19 Jun 2013 16:18:54 +0300 Message-ID: <1371647942-4811-4-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1371647942-4811-1-git-send-email-t-kristo@ti.com> References: <1371647942-4811-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130619_091941_447487_C6A17C17 X-CRM114-Status: GOOD ( 10.88 ) X-Spam-Score: -8.2 (--------) Cc: devicetree-discuss@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;