From patchwork Mon Oct 18 03:50:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 260911 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 o9I3nxKS021018 for ; Mon, 18 Oct 2010 03:50:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751245Ab0JRDud (ORCPT ); Sun, 17 Oct 2010 23:50:33 -0400 Received: from mail.renesas.com ([202.234.163.13]:50344 "EHLO mail06.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751002Ab0JRDuc (ORCPT ); Sun, 17 Oct 2010 23:50:32 -0400 X-AuditID: ac14038a-0000000a000001f2-f7-4cbbc4067bd4 Received: from guardian05.idc.renesas.com ([172.20.8.207]) by mail06.idc.renesas.com (sendmail) with ESMTP id o9I3oU0J029061; Mon, 18 Oct 2010 12:50:30 +0900 (JST) Received: (from root@localhost) by guardian05.idc.renesas.com with id o9I3oUqY007184; Mon, 18 Oct 2010 12:50:30 +0900 (JST) Received: from mta06.idc.renesas.com (localhost [127.0.0.1]) by mta06.idc.renesas.com with ESMTP id o9I3oUQ1019238; Mon, 18 Oct 2010 12:50:30 +0900 (JST) Received: from PG10870.renesas.com ([172.30.8.159]) by ims05.idc.renesas.com (Sendmail) with ESMTPA id <0LAG00CZJW05FO@ims05.idc.renesas.com>; Mon, 18 Oct 2010 12:50:29 +0900 (JST) Date: Mon, 18 Oct 2010 12:50:29 +0900 (JST) Date-warning: Date header was inserted by ims05.idc.renesas.com From: Kuninori Morimoto Subject: [PATCH 1/2] sh: clkfwk: modify for_each_frequency end condition In-reply-to: To: Paul Mundt Cc: Linux-SH Message-id: MIME-version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-type: text/plain; charset=US-ASCII User-Agent: SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (=?ISO-2022-JP-2?B?U2Fuag==?= =?ISO-2022-JP-2?B?GyQoRCtXGyhC?=) APEL/10.6 Emacs/23.2 (i386-mingw-nt5.1.2600) MULE/6.0 (HANACHIRUSATO) References: <20101015061630.GA7489@linux-sh.org> <20101015093922.GC7489@linux-sh.org> <20101015155042.GA14975@linux-sh.org> X-Brightmail-Tracker: AAAAAA== Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 18 Oct 2010 03:50:33 +0000 (UTC) diff --git a/drivers/sh/clk.c b/drivers/sh/clk.c index c76f972..dae64ee 100644 --- a/drivers/sh/clk.c +++ b/drivers/sh/clk.c @@ -82,7 +82,7 @@ struct clk_rate_round_data { #define for_each_frequency(pos, r, freq) \ for (pos = r->min, freq = r->func(pos, r); \ - pos < r->max; pos++, freq = r->func(pos, r)) \ + pos <= r->max; pos++, freq = r->func(pos, r)) \ if (unlikely(freq == 0)) \ ; \ else @@ -139,12 +139,15 @@ long clk_rate_table_round(struct clk *clk, { struct clk_rate_round_data table_round = { .min = 0, - .max = clk->nr_freqs, + .max = clk->nr_freqs - 1, .func = clk_rate_table_iter, .arg = freq_table, .rate = rate, }; + if (clk->nr_freqs < 1) + return 0; + return clk_rate_round_helper(&table_round); }