Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752654AbcKHOu7 (ORCPT ); Tue, 8 Nov 2016 09:50:59 -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 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2072 Lines: 66 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 --- 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; } -- 2.9.0