From patchwork Tue Nov 8 14:49:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9417605 X-Patchwork-Delegate: sboyd@codeaurora.org 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 10C146022E for ; Tue, 8 Nov 2016 14:51:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 034E028F20 for ; Tue, 8 Nov 2016 14:51:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC33828C7D; Tue, 8 Nov 2016 14:51:22 +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 autolearn=unavailable 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 855F428B77 for ; Tue, 8 Nov 2016 14:51:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752597AbcKHOu6 (ORCPT ); Tue, 8 Nov 2016 09:50:58 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:50989 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751668AbcKHOu1 (ORCPT ); Tue, 8 Nov 2016 09:50:27 -0500 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue101) with ESMTPA (Nemesis) id 0LpwXf-1ciyFM3uJr-00fl2h; Tue, 08 Nov 2016 15:50:08 +0100 From: Arnd Bergmann To: Stephen Boyd Cc: Arnd Bergmann , Michael Turquette , Robert Jarzmik , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] clk: pxa: fix pxa2xx_determine_rate return Date: Tue, 8 Nov 2016 15:49:31 +0100 Message-Id: <20161108144950.3472058-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20161108144950.3472058-1-arnd@arndb.de> References: <20161108144950.3472058-1-arnd@arndb.de> X-Provags-ID: V03:K0:1P34V8HV5MVADXX8mw1JaW/fNyiitzXeVaan94O+vsgACargQRb ueYYyc/8h149eB0qNI/xQowYlu+GPPJTDXNwSDZrE9FCTR0p2c2TJZdswXRSXglW1RagWNc Y3WWeMMwNm63jg8AXZfmkf1phHJH3AuI2PAbp6lfo21bwotQtN7QgUfJ5f46k0wBPKj6YvQ L8pqfd+H73L/f/JzpHgsw== X-UI-Out-Filterresults: notjunk:1; V01:K0:a+hP5+Hm9X8=:5Cj5ARhIw0enXRQ0DAULgI bphJBD1+Co8d0g8lCqn61Qwr7u1Wq+RFYdod35/heFfU9hxTmjt/nTK1OOzHRnob4glHlovu3 NHKXmMv9ZluaHMsUUl4UXLlPTNhzNnSLv6UYLT4vBD8IchIlh0R67dgxe8Fc+t6F1fwLbM4uB JPkVwzrBJ0T4A4dN8agC4BzPY7EXt4cQ8V3Gyoe+Jj0gGPnMqXCtRf/sTJVYaznc+1j9aqhIT juDsje20VfCrkEyshdM/xZIEk5TuVvX+cB+Q18LJJg8N0Wd1OD9saLXhbnc5nZ3IunVPQJWCU 5oVA2+NoZLlYF6q1fPagwZhjNwUZ9fhm+bhwtoxpKyyx8oPYZ0BNJdBLG9pR7b0OdedKF5XZd bAxfRu73BDPTOtbZN5wc7arF6lTZ8ZQceaJRz1Ll9AGVIxcsrilbQGSISYVGXKyF0ka4RxQ8Q 50VZEXKbxakMqB2k/9Ts5BFHTG0upf7EUWYtA2cqAbX+ajmcx9Lud+mSgtTj6GMXm18v1XZ3o JSwOP+0fSlDnkg/LI4An++rORdg3KbMn3VXku7U8ohvq06LuZkJ+Gcy+SgmcpslNWangUnoKq KYcOGyQh7Lq8TxOBDj+Y63Uha8KvyPjDa0N+3mKxMF4wsPfcX4Dbl2oLRZSgFUyYt0YSVxV+s EdJ3pr91RveFWNHRIhSyG2c3kkzrr7sducsCpfxFg95jzuZ1yxoucAZCDlpA6N2x80bc= 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 The new pxa2xx_determine_rate() function seems lacking in a few regards: - For an exact match or no match at all, the rate is uninitialized as reported by gcc -Wmaybe-unintialized: drivers/clk/pxa/clk-pxa.c: In function 'pxa2xx_determine_rate': drivers/clk/pxa/clk-pxa.c:243:5: error: 'rate' may be used uninitialized in this function - If we get a non-exact match, the req->rate output is never set to the actual rate but remains at the requested rate. - We should not attempt to print a rate if none could be found This rewrites the logic accordingly. Fixes: 9fe694295098 ("clk: pxa: transfer CPU clock setting from pxa2xx-cpufreq") Signed-off-by: Arnd Bergmann Acked-by: Robert Jarzmik --- drivers/clk/pxa/clk-pxa.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/clk/pxa/clk-pxa.c b/drivers/clk/pxa/clk-pxa.c index 50fb9d0ea58d..c423b064c753 100644 --- a/drivers/clk/pxa/clk-pxa.c +++ b/drivers/clk/pxa/clk-pxa.c @@ -211,7 +211,7 @@ void pxa2xx_cpll_change(struct pxa2xx_freq *freq, int pxa2xx_determine_rate(struct clk_rate_request *req, struct pxa2xx_freq *freqs, int nb_freqs) { - int i, closest_below = -1, closest_above = -1, ret = 0; + int i, closest_below = -1, closest_above = -1; unsigned long rate; for (i = 0; i < nb_freqs; i++) { @@ -230,18 +230,19 @@ int pxa2xx_determine_rate(struct clk_rate_request *req, req->best_parent_hw = NULL; - if (i < nb_freqs) - ret = 0; - else if (closest_below >= 0) + if (i < nb_freqs) { + rate = req->rate; + } else if (closest_below >= 0) { rate = freqs[closest_below].cpll; - else if (closest_above >= 0) + } else if (closest_above >= 0) { rate = freqs[closest_above].cpll; - else - ret = -EINVAL; + } else { + pr_debug("%s(rate=%lu) no match\n", __func__, req->rate); + return -EINVAL; + } - pr_debug("%s(rate=%lu) rate=%lu: %d\n", __func__, req->rate, rate, ret); - if (!rate) - req->rate = rate; + pr_debug("%s(rate=%lu) rate=%lu\n", __func__, req->rate, rate); + req->rate = rate; - return ret; + return 0; }