From patchwork Sun Oct 22 13:40:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10021707 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 D456A60381 for ; Sun, 22 Oct 2017 13:41:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8FD428733 for ; Sun, 22 Oct 2017 13:41:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AADBC287AA; Sun, 22 Oct 2017 13:41:36 +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=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 440DF28733 for ; Sun, 22 Oct 2017 13:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751322AbdJVNle (ORCPT ); Sun, 22 Oct 2017 09:41:34 -0400 Received: from mout.web.de ([217.72.192.78]:53555 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751292AbdJVNld (ORCPT ); Sun, 22 Oct 2017 09:41:33 -0400 Received: from [192.168.1.2] ([77.182.45.221]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MCqoJ-1dyK023SJn-009kab; Sun, 22 Oct 2017 15:40:50 +0200 To: linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Chanwoo Choi , Krzysztof Kozlowski , Kukjin Kim , MyungJoo Ham , Kyungmin Park Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] devfreq/exynos-bus: Use common error handling code in exynos_bus_target() Message-ID: <4a407cd6-020c-1750-019a-6c0ceb40e245@users.sourceforge.net> Date: Sun, 22 Oct 2017 15:40:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:73owu7nZ5rY9vmNB1QuxjDOIx3JgsZi3Inb+v0r6tONFMBI/hb6 EEAnInd1vnbh/HR3PnGy7uzQRO/EUBpzABTK0b7WencjwQnSfhHsn9Fwl83MlvbCZAaYDXX grgyjJ1l/cbTrbkl29fV0Rb4zDcL62Ka+Xf41hq17aCLZG0TGF0neHJh9yA5nnP66ROTwwc 7iSt4DEG7khQx+FttM8Ig== X-UI-Out-Filterresults: notjunk:1; V01:K0:Zp6NR40b68U=:rVbGGVMk0LKE/pR4tjPl29 kcJFHKYYR3RQ0NCqLaILvjbFvtVd0d1z2iKalW2UHg8lUbUqjWGKtkFzpE/PTQw6/ODT0EoUf gsGFLT1WDEyVaenOsPIrRHwvY6vGb5Sk1hTggw0kSnffN0kx9NT//dmLVLo/8T9/j1JiZDK3A 5sf1ZoXk4j51NGjcJ2nayNkcifhK4wPcHDVkE5Rz2YqMg2Q44dkk++ADgci5Wei3KuX+Ymcjz Q/Fs0X++byXSX6XUqzlyeiqfprsE5ym3xy+hNzgwFE2ERi/wWdI3PgKQR5+ioHie00md7QDax J8gMXQ28tDnNWlUmdalWv8PIMyUqGOvSIhrdcycsrLjp5iFoCgqngv7cKXGZLvxEvAUA/6mGB qzC9KEKbImZrT/XLTcYsaRR7/86sPJOLhRyK7T8g2rGRBJ8/7Qz+gJ/zl5zr14/pyXEzTNajI x77OpcesaBnTX1ZEb2lN28mDdFQI40fJsinCFHKKQKinuhCXeRyqw5Lz9DDUQEkm4YZ8l+VoK /s/zCwy/sSa91FXaI3AL91nnKvmfLIgMg6CDIiwj5JfZ1Qb7RhusnrL0cs5ZcjtU+zwgbNNvz xpPxZ6U7coHkDZ++7qnmj7k56ImnluFLDAKa3T8a0SmQjHuWPqD1kDCtWxXRP1mcF4vc8bGd6 nlVpM9ke05N2vnCV10sOfFMbOS5D35cGA1PsKHPGhOy+0Jr8p3A0dYjRAvzKsGjHj/wj16W3l N5RTRBRg0DmfJTDBmVta7Tn2+JOr7uzwH0HUC4HUZZSg+i7UZH8F2HPro27oDqIF8mJyFYz1j j/I4wPBp5bdsvhhdV1jBPGCyzpC+GLeu14zpjDiNK2LCHHoxPo= Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 22 Oct 2017 15:33:06 +0200 Adjust jump targets so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/devfreq/exynos-bus.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c index 49f68929e024..e38d456b2d7d 100644 --- a/drivers/devfreq/exynos-bus.c +++ b/drivers/devfreq/exynos-bus.c @@ -124,34 +124,33 @@ static int exynos_bus_target(struct device *dev, unsigned long *freq, u32 flags) if (old_freq < new_freq) { ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol); - if (ret < 0) { - dev_err(bus->dev, "failed to set voltage\n"); - goto out; - } + if (ret < 0) + goto report_failure; } ret = clk_set_rate(bus->clk, new_freq); if (ret < 0) { dev_err(dev, "failed to change clock of bus\n"); clk_set_rate(bus->clk, old_freq); - goto out; + goto unlock; } if (old_freq > new_freq) { ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol); - if (ret < 0) { - dev_err(bus->dev, "failed to set voltage\n"); - goto out; - } + if (ret < 0) + goto report_failure; } bus->curr_freq = new_freq; dev_dbg(dev, "Set the frequency of bus (%luHz -> %luHz, %luHz)\n", old_freq, new_freq, clk_get_rate(bus->clk)); -out: +unlock: mutex_unlock(&bus->lock); - return ret; + +report_failure: + dev_err(bus->dev, "failed to set voltage\n"); + goto unlock; } static int exynos_bus_get_dev_status(struct device *dev,