From patchwork Wed Oct 18 10:17:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladislav Michl X-Patchwork-Id: 10014291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3ABC4602C8 for ; Wed, 18 Oct 2017 10:17:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36A1528B1B for ; Wed, 18 Oct 2017 10:17:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B95C28B1C; Wed, 18 Oct 2017 10:17:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59CFA28B16 for ; Wed, 18 Oct 2017 10:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937577AbdJRKR0 (ORCPT ); Wed, 18 Oct 2017 06:17:26 -0400 Received: from eddie.linux-mips.org ([148.251.95.138]:37238 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933777AbdJRKR0 (ORCPT ); Wed, 18 Oct 2017 06:17:26 -0400 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23992361AbdJRKRW2Viw- (ORCPT + 1 other); Wed, 18 Oct 2017 12:17:22 +0200 Date: Wed, 18 Oct 2017 12:17:21 +0200 From: Ladislav Michl To: linux-omap@vger.kernel.org, linux-clk@vger.kernel.org Cc: Tero Kristo , Michael Turquette , Stephen Boyd Subject: [PATCH] clk: ti: omap36xx: optimize sprz319 advisory 2.1 Message-ID: <20171018101721.vqmokklnu76awr53@lenoch> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Shrink code size of omap36xx specific quirk by almost 100 bytes. gcc-5.4.0 text data bss dec hex filename 4326 168 0 4494 118e dpll3xxx.o-orig 4234 168 0 4402 1132 dpll3xxx.o gcc-6.3.0 text data bss dec hex filename 4286 168 0 4454 1166 dpll3xxx.o-orig 4190 168 0 4358 1106 dpll3xxx.o Signed-off-by: Ladislav Michl --- drivers/clk/ti/dpll3xxx.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/clk/ti/dpll3xxx.c b/drivers/clk/ti/dpll3xxx.c index 4534de2ef455..63f70e829f2b 100644 --- a/drivers/clk/ti/dpll3xxx.c +++ b/drivers/clk/ti/dpll3xxx.c @@ -844,9 +844,14 @@ static bool omap3_dpll5_apply_errata(struct clk_hw *hw, unsigned long parent_rate) { struct omap3_dpll5_settings { - unsigned int rate, m, n; + unsigned int rate; + unsigned short m, n; }; + int i; + struct dpll_data *dd; + struct clk_hw_omap *clk; + const struct omap3_dpll5_settings *p; static const struct omap3_dpll5_settings precomputed[] = { /* * From DM3730 errata advisory 2.1, table 35 and 36. @@ -861,29 +866,23 @@ static bool omap3_dpll5_apply_errata(struct clk_hw *hw, { 38400000, 25, 0 + 1 } }; - const struct omap3_dpll5_settings *d; - struct clk_hw_omap *clk = to_clk_hw_omap(hw); - struct dpll_data *dd; - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(precomputed); ++i) { - if (parent_rate == precomputed[i].rate) - break; + for (i = 0; i < ARRAY_SIZE(precomputed); i++) { + p = precomputed + i; + if (parent_rate == p->rate) { + clk = to_clk_hw_omap(hw); + dd = clk->dpll_data; + /* Update the M, N and rounded rate values */ + dd->last_rounded_m = p->m; + dd->last_rounded_n = p->n; + dd->last_rounded_rate = + div_u64((u64)parent_rate * p->m, p->n); + omap3_noncore_dpll_program(clk, 0); + + return true; + } } - if (i == ARRAY_SIZE(precomputed)) - return false; - - d = &precomputed[i]; - - /* Update the M, N and rounded rate values and program the DPLL. */ - dd = clk->dpll_data; - dd->last_rounded_m = d->m; - dd->last_rounded_n = d->n; - dd->last_rounded_rate = div_u64((u64)parent_rate * d->m, d->n); - omap3_noncore_dpll_program(clk, 0); - - return true; + return false; } /**