From patchwork Mon Dec 16 10:47:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXJ0dXIgxZp3aWdvxYQ=?= X-Patchwork-Id: 11293763 X-Patchwork-Delegate: cw00.choi@samsung.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA1CE138D for ; Mon, 16 Dec 2019 10:48:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 930AD206D3 for ; Mon, 16 Dec 2019 10:48:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="g5VB92M6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727229AbfLPKsU (ORCPT ); Mon, 16 Dec 2019 05:48:20 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:53936 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727099AbfLPKsT (ORCPT ); Mon, 16 Dec 2019 05:48:19 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20191216104817euoutp01a77b64d1575925894f1fb4b11a195244~g1E0f7jHt1733917339euoutp01H for ; Mon, 16 Dec 2019 10:48:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20191216104817euoutp01a77b64d1575925894f1fb4b11a195244~g1E0f7jHt1733917339euoutp01H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1576493297; bh=O6pcI0nl3cOacuyyeqkh+QDKkG1plk0wyzWw1uJR2cE=; h=From:To:Cc:Subject:Date:References:From; b=g5VB92M6Z/Gb0NzDoxraG1SidA2yRFf6Z13SC4rK9w/JX8I/lJkw+1R9n7dGDNrjt pZkek2PjXcTrpwA56TCD9tKGMggwkHKZQ43RqO+CdMY+EJRi0o8car0nfgJMgOKwaB UlFJ9mb35RFQvSheB4N81/i0JDToq35rtR+9lCbg= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20191216104817eucas1p13ae3217a6d97b3a7d1cab1c2fe4cb125~g1E0Qi9FP2735027350eucas1p1S; Mon, 16 Dec 2019 10:48:17 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 51.A3.60679.0F067FD5; Mon, 16 Dec 2019 10:48:16 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20191216104816eucas1p1775a0dac98f507e10ee2fa15dccdc216~g1Ez4YgmL1561015610eucas1p19; Mon, 16 Dec 2019 10:48:16 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20191216104816eusmtrp11c9a18d77c49ef7645a8040290858ebc~g1Ez3laSb1051110511eusmtrp1f; Mon, 16 Dec 2019 10:48:16 +0000 (GMT) X-AuditID: cbfec7f4-0e5ff7000001ed07-86-5df760f096b7 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 79.EF.08375.0F067FD5; Mon, 16 Dec 2019 10:48:16 +0000 (GMT) Received: from AMDC3555.digital.local (unknown [106.120.51.67]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20191216104815eusmtip167d0578b820b91814462f43866d8600d~g1EzJV3692559025590eusmtip1H; Mon, 16 Dec 2019 10:48:15 +0000 (GMT) From: =?utf-8?b?QXJ0dXIgxZp3aWdvxYQ=?= To: linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: =?utf-8?b?QXJ0dXIgxZp3aWdvxYQ=?= , cw00.choi@samsung.com, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, kgene@kernel.org, krzk@kernel.org, b.zolnierkie@samsung.com, m.szyprowski@samsung.com, inki.dae@samsung.com, sw0312.kim@samsung.com Subject: [PATCH v2] PM / devfreq: exynos-bus: Reduce the numer of goto statements and remove unused headers Date: Mon, 16 Dec 2019 11:47:48 +0100 Message-Id: <20191216104748.18877-1-a.swigon@samsung.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJKsWRmVeSWpSXmKPExsWy7djP87ofEr7HGixaZGNxf14ro8XGGetZ La5/ec5qMen+BBaL/sevmS3On9/AbnG26Q27xabH11gtLu+aw2bxufcIo8WM8/uYLNYeuctu cbtxBZvFjMkv2Rz4PDat6mTz2Lyk3qNvyypGj8+b5AJYorhsUlJzMstSi/TtErgyvrXnFJxU rti48QhjA+MmmS5GTg4JAROJAzf2s4LYQgIrGCUuPFPuYuQCsr8wSnz/95QRwvnMKLHgzDZ2 mI7l35pYIRLLGSW6W1qY4Vp6H99jBKliE3CUmDT1AViHiEAro8TMJnUQm1lgGpPExt0OILaw QK7Eg57FTCA2i4CqxIHbc1lAbF4BS4lZM6ayQWyTl1i94QAzRFxQ4uTMJywQc+QlmrfOBlss IbCNXeJnazsLRIOLxKRlL6CahSVeHd8CdbaMxOnJPVA1xRJPd95nhWhuYJTYtOwIM0TCWuLw 8YtACQ6gDZoS63fpQ4QdJbb1dICFJQT4JG68FYS4gU9i0rbpzBBhXomONiEIU0li10w+iEYJ iabV16Bme0jc3zcPGtKxEme2vGeewKgwC8ljs5A8NgvhhAWMzKsYxVNLi3PTU4uN8lLL9YoT c4tL89L1kvNzNzECE9Tpf8e/7GDc9SfpEKMAB6MSD69D9rdYIdbEsuLK3EOMEhzMSiK8OxS+ xwrxpiR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IeGUGj/OS5HB95dWddndkmdaA871vx1K+nQ4/MrFo6VcHvmbC+qhePlfMf9y6RY3eU WIozEg21mIuKEwGyNPL6vAIAAA== X-CMS-MailID: 20191216104816eucas1p1775a0dac98f507e10ee2fa15dccdc216 X-Msg-Generator: CA X-RootMTR: 20191216104816eucas1p1775a0dac98f507e10ee2fa15dccdc216 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20191216104816eucas1p1775a0dac98f507e10ee2fa15dccdc216 References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This patch improves code readability by changing the following construct: if (cond) goto passive; foo(); goto out; passive: bar(); out: into this: if (cond) bar(); else foo(); as well as eliminating a few more goto statements (related to return paths). Moreover, this patch removes unused header file includes and adds a missing include . Signed-off-by: Artur Świgoń --- drivers/devfreq/exynos-bus.c | 54 +++++++++++++----------------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c index 19d9f9f8ced2..7f5917d59072 100644 --- a/drivers/devfreq/exynos-bus.c +++ b/drivers/devfreq/exynos-bus.c @@ -15,11 +15,10 @@ #include #include #include -#include +#include #include #include #include -#include #define DEFAULT_SATURATION_RATIO 40 @@ -301,10 +300,9 @@ static int exynos_bus_profile_init(struct exynos_bus *bus, profile->exit = exynos_bus_exit; ondemand_data = devm_kzalloc(dev, sizeof(*ondemand_data), GFP_KERNEL); - if (!ondemand_data) { - ret = -ENOMEM; - goto err; - } + if (!ondemand_data) + return -ENOMEM; + ondemand_data->upthreshold = 40; ondemand_data->downdifferential = 5; @@ -314,15 +312,14 @@ static int exynos_bus_profile_init(struct exynos_bus *bus, ondemand_data); if (IS_ERR(bus->devfreq)) { dev_err(dev, "failed to add devfreq device\n"); - ret = PTR_ERR(bus->devfreq); - goto err; + return PTR_ERR(bus->devfreq); } /* Register opp_notifier to catch the change of OPP */ ret = devm_devfreq_register_opp_notifier(dev, bus->devfreq); if (ret < 0) { dev_err(dev, "failed to register opp notifier\n"); - goto err; + return ret; } /* @@ -332,17 +329,16 @@ static int exynos_bus_profile_init(struct exynos_bus *bus, ret = exynos_bus_enable_edev(bus); if (ret < 0) { dev_err(dev, "failed to enable devfreq-event devices\n"); - goto err; + return ret; } ret = exynos_bus_set_event(bus); if (ret < 0) { dev_err(dev, "failed to set event to devfreq-event devices\n"); - goto err; + return ret; } -err: - return ret; + return 0; } static int exynos_bus_profile_init_passive(struct exynos_bus *bus, @@ -351,7 +347,6 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus, struct device *dev = bus->dev; struct devfreq_passive_data *passive_data; struct devfreq *parent_devfreq; - int ret = 0; /* Initialize the struct profile and governor data for passive device */ profile->target = exynos_bus_target; @@ -359,16 +354,13 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus, /* Get the instance of parent devfreq device */ parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0); - if (IS_ERR(parent_devfreq)) { - ret = -EPROBE_DEFER; - goto err; - } + if (IS_ERR(parent_devfreq)) + return -EPROBE_DEFER; passive_data = devm_kzalloc(dev, sizeof(*passive_data), GFP_KERNEL); - if (!passive_data) { - ret = -ENOMEM; - goto err; - } + if (!passive_data) + return -ENOMEM; + passive_data->parent = parent_devfreq; /* Add devfreq device for exynos bus with passive governor */ @@ -377,12 +369,10 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus, if (IS_ERR(bus->devfreq)) { dev_err(dev, "failed to add devfreq dev with passive governor\n"); - ret = PTR_ERR(bus->devfreq); - goto err; + return PTR_ERR(bus->devfreq); } -err: - return ret; + return 0; } static int exynos_bus_probe(struct platform_device *pdev) @@ -427,19 +417,13 @@ static int exynos_bus_probe(struct platform_device *pdev) goto err_reg; if (passive) - goto passive; - - ret = exynos_bus_profile_init(bus, profile); - if (ret < 0) - goto err; + ret = exynos_bus_profile_init_passive(bus, profile); + else + ret = exynos_bus_profile_init(bus, profile); - goto out; -passive: - ret = exynos_bus_profile_init_passive(bus, profile); if (ret < 0) goto err; -out: max_state = bus->devfreq->profile->max_state; min_freq = (bus->devfreq->profile->freq_table[0] / 1000); max_freq = (bus->devfreq->profile->freq_table[max_state - 1] / 1000);